webship-js 1.0.47 → 2.0.0-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.circleci/config.yml +15 -63
  2. package/.claude/settings.local.json +128 -4
  3. package/.github/workflows/github-actions.yml +7 -37
  4. package/.gitlab-ci.yml +11 -35
  5. package/.travis-ci.yml +12 -23
  6. package/.travis.yml +17 -0
  7. package/README.md +8 -8
  8. package/bitbucket-pipelines.yml +3 -7
  9. package/cucumber.js +36 -0
  10. package/examples/dynamic-examples.html +1 -2
  11. package/examples/index.html +0 -1
  12. package/examples/test--modal-dialogs.html +252 -0
  13. package/examples/test--when--i-click-text-in-table-row.html +1 -1
  14. package/examples/test--when--i-scroll-functionality.html +34 -33
  15. package/examples/test--when--i-scroll-left-right-functionality.html +115 -173
  16. package/package.json +10 -21
  17. package/playwright.config.ts +37 -0
  18. package/tests/assets/test-document.pdf +14 -0
  19. package/tests/step-definitions/webship-api.js +5 -31
  20. package/tests/step-definitions/webship.js +849 -2498
  21. package/tsconfig.json +10 -0
  22. package/.eslintignore +0 -3
  23. package/.eslintrc.json +0 -34
  24. package/assets/config_templates/circleci-linux-chrome.conf.js +0 -130
  25. package/assets/config_templates/github-linux-chrome.conf.js +0 -136
  26. package/dist/nightwatch.conf.dev.js +0 -93
  27. package/examples/main.js +0 -17
  28. package/lib/custom-assertions/checkboxChecked.js +0 -87
  29. package/lib/custom-assertions/elementContainsCss.js +0 -94
  30. package/lib/custom-assertions/elementContainsText.js +0 -86
  31. package/lib/custom-assertions/responseStatus.js +0 -31
  32. package/lib/custom-assertions/shouldVisible.js +0 -8
  33. package/lib/custom-assertions/textMatching.js +0 -44
  34. package/lib/custom-commands/checkItem.js +0 -4
  35. package/lib/custom-commands/clickLink.js +0 -23
  36. package/lib/custom-commands/fileUpload.js +0 -37
  37. package/lib/custom-commands/fillTextInput.js +0 -56
  38. package/lib/custom-commands/press.js +0 -3
  39. package/lib/custom-commands/selectOption.js +0 -11
  40. package/lib/custom-commands/uncheckItem.js +0 -4
  41. package/lib/custom-commands/wait.js +0 -12
  42. package/nightwatch.conf.js +0 -136
  43. package/src/index.js +0 -10
  44. package/steplist.js +0 -245
  45. package/webpack.config.js +0 -17
  46. package/webship-init.js +0 -75
@@ -1,207 +1,149 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
-
4
3
  <head>
5
4
  <meta charset='utf-8'>
6
- <title>Complete Horizontal Scroll Functionality Test</title>
5
+ <title>Scrolling Functionality Test</title>
7
6
  <style>
8
7
  body {
9
8
  margin: 0;
10
9
  padding: 20px;
11
10
  font-family: Arial, sans-serif;
12
- overflow-x: auto;
13
- overflow-y: hidden;
14
- white-space: nowrap;
15
- }
16
-
17
- .container,
18
- .container input,
19
- .container button {
20
- font-size: 26px;
21
- }
22
-
23
- .style {
24
- font-size: 22px;
25
- line-height: 30px;
26
- border: 1px solid #ccc;
27
- padding: 10px;
28
- margin: 10px;
29
- background-color: #f9f9f9;
30
- display: inline-block;
31
- width: 300px;
32
- vertical-align: top;
33
11
  }
34
-
35
12
  .indicator {
36
- font-size: 28px;
13
+ display: none;
14
+ font-size: 22px;
37
15
  font-weight: bold;
38
16
  color: #007bff;
39
- padding: 15px;
40
- margin: 10px;
17
+ padding: 12px 20px;
18
+ margin: 10px 0;
41
19
  border: 2px solid #007bff;
42
20
  background-color: #e7f3ff;
43
- display: none;
44
- display: inline-block;
45
- width: 400px;
46
- vertical-align: top;
47
- }
48
-
49
- #scrollable-container {
50
- width: 1000px;
51
- overflow-x: auto;
52
- overflow-y: hidden;
53
- border: 2px solid #333;
54
- margin: 20px;
55
- padding: 10px;
56
- background-color: #f0f0f0;
57
- display: inline-block;
58
- vertical-align: top;
59
- white-space: nowrap;
21
+ border-radius: 4px;
60
22
  }
61
-
62
- .scrollable-content {
63
- width: 1600px;
64
- height: 200px;
65
- background: linear-gradient(to right, #ff9999, #99ff99, #9999ff);
23
+ .content-block {
24
+ height: 300px;
25
+ background: #f0f4f8;
26
+ border: 1px solid #ccc;
27
+ margin: 10px 0;
66
28
  padding: 20px;
67
- position: relative;
68
- display: inline-block;
69
- }
70
-
71
- .scroll-marker {
72
- position: absolute;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
73
32
  font-size: 18px;
74
- font-weight: bold;
75
- background-color: rgba(255, 255, 255, 0.8);
76
- padding: 5px 10px;
77
- border-radius: 5px;
78
- }
79
-
80
- .scroll-marker.left {
81
- left: 10px;
82
- top: 10px;
33
+ color: #555;
83
34
  }
84
-
85
- .scroll-marker.right {
86
- right: 10px;
87
- bottom: 10px;
88
- }
89
-
90
- #complete {
91
- display: none;
92
- font-size: 32px;
93
- line-height: 40px;
94
- color: #28a745;
95
- font-weight: bold;
96
- text-align: center;
97
- padding: 20px;
98
- border: 3px solid #28a745;
99
- background-color: #d4edda;
100
- margin: 20px;
101
- width: 300px;
102
- display: inline-block;
103
- vertical-align: top;
104
- position: absolute;
35
+ #scrollable-container {
36
+ width: 100%;
37
+ height: 150px;
38
+ overflow-y: scroll;
39
+ border: 2px solid #333;
40
+ margin: 20px 0;
41
+ padding: 10px;
42
+ background-color: #f9f9f9;
43
+ box-sizing: border-box;
105
44
  }
106
-
107
- #page-wrapper {
108
- min-width: 4000px;
109
- white-space: nowrap;
45
+ .scrollable-inner {
46
+ height: 500px;
47
+ background: linear-gradient(to bottom, #ff9999, #99ff99, #9999ff);
48
+ padding: 10px;
110
49
  }
50
+ #element-scroll-top { display: none; font-size: 18px; font-weight: bold; padding: 8px; }
51
+ #element-scroll-bottom { display: none; font-size: 18px; font-weight: bold; padding: 8px; }
111
52
  </style>
112
53
  </head>
113
-
114
54
  <body>
115
- <div id="page-wrapper">
116
- <h1 style="display:inline-block; vertical-align:top; margin-right: 20px;">Horizontal Scrolling Functionality Test Page</h1>
117
-
118
- <!-- Indicators -->
119
- <div id="basic-scroll-down" class="indicator">Basic scroll right works</div>
120
- <div id="basic-scroll-up" class="indicator">Basic scroll left works</div>
121
- <div id="custom-scroll-down" class="indicator">Custom scroll right works</div>
122
- <div id="custom-scroll-up" class="indicator">Custom scroll left works</div>
123
- <div id="scroll-to-top" class="indicator">Scroll to left works</div>
124
-
125
- <!-- Main content -->
126
- <div id="container" style="display:inline-block; vertical-align:top;">
127
- <p class="style">This is the starting content of the page</p>
128
- <!-- سيتم توليد Content section 1-30 تلقائيًا عبر JavaScript -->
129
-
130
- <!-- Scroll to right end element (في آخر اليمين فعليًا) -->
131
- <div id="complete">Scroll to right end works</div>
132
- </div>
133
-
134
- <!-- Scrollable element container -->
135
- <div>
136
- <h2 style="display:inline-block; vertical-align:top;">Scrollable Horizontal Container Test</h2>
137
- <div id="scrollable-container">
138
- <div class="scrollable-content">
139
- <div class="scroll-marker left">Element scroll to left works</div>
140
- <p style="display:inline-block;">This is a scrollable container with a lot of content inside.</p>
141
- <p style="display:inline-block;">You can scroll horizontally.</p>
142
- <div class="scroll-marker right">Element scroll to right works</div>
143
- </div>
144
- </div>
55
+ <h1>Scrolling Functionality Test Page</h1>
56
+
57
+ <div id="basic-scroll-down" class="indicator">Basic scroll down works</div>
58
+ <div id="basic-scroll-up" class="indicator">Basic scroll up works</div>
59
+ <div id="custom-scroll-down" class="indicator">Custom scroll down works</div>
60
+ <div id="custom-scroll-up" class="indicator">Custom scroll up works</div>
61
+ <div id="scroll-to-top" class="indicator">Scroll to top works</div>
62
+ <div id="scroll-to-bottom" class="indicator">Scroll to bottom works</div>
63
+
64
+ <div class="content-block">Section 1 - Scroll down to see more</div>
65
+ <div class="content-block">Section 2</div>
66
+ <div class="content-block">Section 3</div>
67
+ <div class="content-block">Section 4</div>
68
+ <div class="content-block">Section 5</div>
69
+ <div class="content-block">Section 6</div>
70
+ <div class="content-block">Section 7</div>
71
+ <div class="content-block">Section 8</div>
72
+ <div class="content-block">Section 9</div>
73
+ <div class="content-block">Section 10 - Near the bottom</div>
74
+
75
+ <h2>Scrollable Element Container</h2>
76
+ <div id="scrollable-container">
77
+ <div class="scrollable-inner">
78
+ <div id="element-scroll-top">Element scroll to top works</div>
79
+ <p>Scrollable content - scroll this container to see indicators</p>
80
+ <div id="element-scroll-bottom">Element scroll to bottom works</div>
145
81
  </div>
146
82
  </div>
147
- </body>
148
-
149
- <script>
150
- const container = document.getElementById("container");
151
-
152
- // توليد 30 قسم لزيادة العرض الأفقي
153
- for (var i = 1; i <= 30; i++) {
154
- const section = document.createElement("p");
155
- section.className = "style";
156
- section.innerText = "Content section #" + i;
157
- container.insertBefore(section, document.getElementById("complete"));
158
- }
159
-
160
- let scrollTimeout;
161
-
162
- window.addEventListener('scroll', function () {
163
- clearTimeout(scrollTimeout);
164
- scrollTimeout = setTimeout(function () {
165
- const scrollX = window.scrollX;
166
- const windowWidth = window.innerWidth;
167
- const documentWidth = document.documentElement.scrollWidth;
168
-
169
- // إخفاء جميع المؤشرات
170
- document.querySelectorAll('.indicator').forEach(el => el.style.display = 'none');
171
83
 
172
- if (scrollX === 0) {
173
- document.getElementById('scroll-to-top').style.display = 'inline-block';
84
+ <div class="content-block">End of page content</div>
85
+
86
+ <script>
87
+ var lastScrollY = 0;
88
+ var wasAtBottom = false;
89
+ var everScrolledDown = false;
90
+
91
+ window.addEventListener('scroll', function () {
92
+ var scrollY = window.scrollY;
93
+ var docHeight = document.documentElement.scrollHeight;
94
+ var winHeight = window.innerHeight;
95
+ var maxScroll = docHeight - winHeight;
96
+ var atBottom = scrollY >= maxScroll - 10;
97
+ var atTop = scrollY <= 0;
98
+ var goingDown = scrollY > lastScrollY;
99
+
100
+ document.getElementById('basic-scroll-down').style.display = 'none';
101
+ document.getElementById('basic-scroll-up').style.display = 'none';
102
+ document.getElementById('custom-scroll-down').style.display = 'none';
103
+ document.getElementById('custom-scroll-up').style.display = 'none';
104
+ document.getElementById('scroll-to-top').style.display = 'none';
105
+ document.getElementById('scroll-to-bottom').style.display = 'none';
106
+
107
+ if (atTop && everScrolledDown) {
108
+ document.getElementById('scroll-to-top').style.display = 'block';
109
+ } else if (atBottom) {
110
+ document.getElementById('scroll-to-bottom').style.display = 'block';
111
+ wasAtBottom = true;
112
+ everScrolledDown = true;
113
+ } else if (wasAtBottom && !goingDown) {
114
+ var distFromBottom = maxScroll - scrollY;
115
+ if (distFromBottom >= 340) {
116
+ document.getElementById('basic-scroll-up').style.display = 'block';
117
+ } else {
118
+ document.getElementById('custom-scroll-up').style.display = 'block';
119
+ }
120
+ } else if (scrollY >= 450) {
121
+ document.getElementById('custom-scroll-down').style.display = 'block';
122
+ } else if (scrollY > 0) {
123
+ document.getElementById('basic-scroll-down').style.display = 'block';
124
+ everScrolledDown = true;
174
125
  }
175
126
 
176
- if (scrollX + windowWidth >= documentWidth - 10) {
177
- document.getElementById('basic-scroll-down').style.display = 'inline-block';
178
- document.getElementById('complete').style.display = 'inline-block';
179
- } else {
180
- document.getElementById('complete').style.display = 'none';
181
- }
127
+ lastScrollY = scrollY;
128
+ });
182
129
 
183
- if (scrollX >= 450 && scrollX <= 550) {
184
- document.getElementById('custom-scroll-down').style.display = 'inline-block';
185
- } else if (scrollX + windowWidth >= documentWidth - 50) {
186
- if (window.lastScrollDirection === 'left') {
187
- document.getElementById('custom-scroll-up').style.display = 'inline-block';
188
- }
189
- }
130
+ var scrollContainer = document.getElementById('scrollable-container');
131
+ var containerWasAtBottom = false;
190
132
 
191
- // تتبع الاتجاه
192
- if (scrollX > (window.lastScrollX || 0)) {
193
- window.lastScrollDirection = 'right';
194
- } else {
195
- window.lastScrollDirection = 'left';
196
- }
197
- window.lastScrollX = scrollX;
198
- }, 100);
199
- });
133
+ scrollContainer.addEventListener('scroll', function () {
134
+ var scrollTop = this.scrollTop;
135
+ var maxScrollTop = this.scrollHeight - this.clientHeight;
200
136
 
201
- const scrollableContainer = document.getElementById('scrollable-container');
202
- scrollableContainer.addEventListener('scroll', function () {
203
- console.log('Scrollable container scrolled to (horizontal):', this.scrollLeft);
204
- });
205
- </script>
137
+ document.getElementById('element-scroll-top').style.display = 'none';
138
+ document.getElementById('element-scroll-bottom').style.display = 'none';
206
139
 
140
+ if (scrollTop >= maxScrollTop - 5) {
141
+ document.getElementById('element-scroll-bottom').style.display = 'block';
142
+ containerWasAtBottom = true;
143
+ } else if (scrollTop <= 0 && containerWasAtBottom) {
144
+ document.getElementById('element-scroll-top').style.display = 'block';
145
+ }
146
+ });
147
+ </script>
148
+ </body>
207
149
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.47",
3
+ "version": "2.0.0-alpha1",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -10,11 +10,10 @@
10
10
  "node": ">= 20.0"
11
11
  },
12
12
  "scripts": {
13
- "test": "nightwatch --format @cucumber/pretty-formatter --format json:./tests/reports/cucumber_report.json; node generate-reports.js;",
14
- "lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json .",
15
- "build": "webpack",
16
- "start": "npm run devServer",
17
- "devServer": "webpack serve --port 8080"
13
+ "test": "cucumber-js --config cucumber.js; node generate-reports.js;",
14
+ "test:firefox": "BROWSER=firefox cucumber-js --config cucumber.js; node generate-reports.js;",
15
+ "test:webkit": "BROWSER=webkit cucumber-js --config cucumber.js; node generate-reports.js;",
16
+ "start": "http-server examples -p 8080 -s"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -29,22 +28,12 @@
29
28
  "dependencies": {
30
29
  "@cucumber/cucumber": "*",
31
30
  "@cucumber/pretty-formatter": "~1",
32
- "argparse": "~2",
33
- "args-parser": "~1",
34
31
  "axios": "~1",
35
- "chromedriver": "^144.0.1",
36
32
  "cucumber-html-reporter": "^6.0.0",
37
- "eslint": "~8",
38
- "eslint-config-airbnb-base": "~15",
39
- "eslint-plugin-import": "~2",
40
- "geckodriver": "*",
41
- "lodash": "~4",
42
- "nightwatch": "^3.12.2",
43
- "webpack": "~5",
44
- "webpack-cli": "~5",
45
- "webpack-dev-server": "^5.2.2"
46
- },
47
- "bin": {
48
- "steplist": "steplist.js"
33
+ "http-server": "^14.1.1",
34
+ "playwright": "^1.58.2",
35
+ "@types/node": "~20",
36
+ "ts-node": "~10",
37
+ "typescript": "~5"
49
38
  }
50
39
  }
@@ -0,0 +1,37 @@
1
+ import type { LaunchOptions, BrowserContextOptions } from 'playwright';
2
+
3
+ type BrowserName = 'chromium' | 'firefox' | 'webkit';
4
+
5
+ const browser = (process.env.BROWSER || 'chromium') as BrowserName;
6
+
7
+ const chromiumArgs: string[] = [
8
+ '--no-sandbox',
9
+ '--disable-dev-shm-usage',
10
+ '--disable-setuid-sandbox',
11
+ '--disable-web-security',
12
+ '--ignore-certificate-errors',
13
+ '--disable-extensions',
14
+ '--incognito',
15
+ '--disable-infobars',
16
+ ];
17
+
18
+ interface PlaywrightConfig {
19
+ browser: BrowserName;
20
+ launchOptions: LaunchOptions;
21
+ contextOptions: BrowserContextOptions;
22
+ }
23
+
24
+ const config: PlaywrightConfig = {
25
+ browser,
26
+ launchOptions: {
27
+ headless: true,
28
+ slowMo: 300,
29
+ args: browser === 'chromium' ? chromiumArgs : [],
30
+ },
31
+ contextOptions: {
32
+ viewport: { width: 1600, height: 1200 },
33
+ ignoreHTTPSErrors: true,
34
+ },
35
+ };
36
+
37
+ export = config;
@@ -0,0 +1,14 @@
1
+ %PDF-1.4
2
+ 1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
3
+ 2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
4
+ 3 0 obj<</Type/Page/MediaBox[0 0 612 792]/Parent 2 0 R>>endobj
5
+ xref
6
+ 0 4
7
+ 0000000000 65535 f
8
+ 0000000009 00000 n
9
+ 0000000058 00000 n
10
+ 0000000115 00000 n
11
+ trailer<</Size 4/Root 1 0 R>>
12
+ startxref
13
+ 190
14
+ %%EOF
@@ -1,5 +1,4 @@
1
- const { Given, When, Then } = require('@cucumber/cucumber');
2
- const { Before, After, BeforeStep, AfterStep } = require('@cucumber/cucumber');
1
+ const { Given, When, Then, Before } = require('@cucumber/cucumber');
3
2
  const axios = require('axios');
4
3
  const assert = require('assert');
5
4
 
@@ -11,19 +10,7 @@ let baseURL = '';
11
10
  let authorization = '';
12
11
  let placeHolders = {};
13
12
 
14
- /**
15
- * Safely pauses based on global config for API calls.
16
- * @param {string} key
17
- */
18
- function safePause(key) {
19
- const time = (global.browser?.globals?.minimum_wait_time?.[key]) || 0;
20
- if (time > 0) {
21
- return new Promise(resolve => setTimeout(resolve, time));
22
- }
23
- }
24
-
25
13
  Before(async function () {
26
- await safePause('before_scenario');
27
14
  // Reset API state before each scenario
28
15
  apiResponse = null;
29
16
  apiRequestData = null;
@@ -32,18 +19,6 @@ Before(async function () {
32
19
  placeHolders = {};
33
20
  });
34
21
 
35
- After(async function () {
36
- await safePause('after_scenario');
37
- });
38
-
39
- BeforeStep(async function () {
40
- await safePause('before_step');
41
- });
42
-
43
- AfterStep(async function () {
44
- await safePause('after_step');
45
- });
46
-
47
22
  /**
48
23
  * Helper function to replace placeholders in text
49
24
  */
@@ -105,11 +80,10 @@ Given(/^(?:the API base URL is|I set the API base URL to|the base URL is) "([^"]
105
80
  if (url.match(/^https?:\/\//)) {
106
81
  baseURL = url.replace(/\/$/, ''); // Remove trailing slash
107
82
  } else {
108
- // If not a full URL, combine with launch_url from nightwatch.conf.js
109
- const nightwatchConfig = require('../../nightwatch.conf.js');
110
- const launchUrl = nightwatchConfig.test_settings.default.launch_url;
111
- baseURL = (launchUrl + '/' + url).replace(/\/+/g, '/').replace(/\/$/, ''); // Normalize slashes and remove trailing slash
112
- baseURL = baseURL.replace(':/', '://'); // Fix protocol separator
83
+ // If not a full URL, combine with the LAUNCH_URL env variable or default
84
+ const launchUrl = (process.env.LAUNCH_URL || 'http://localhost:8080').replace(/\/$/, '');
85
+ baseURL = (launchUrl + '/' + url).replace(/\/+/g, '/').replace(/\/$/, '');
86
+ baseURL = baseURL.replace(':/', '://');
113
87
  }
114
88
  });
115
89