webship-js 2.0.9 → 2.0.11
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.
- package/.github/ISSUE_TEMPLATE/issue.md +37 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- package/.github/workflows/github-actions.yml +56 -4
- package/CLAUDE.md +5 -2
- package/README.md +13 -1
- package/bin/generate-reports.js +51 -7
- package/bin/init-webship.js +85 -17
- package/cucumber.js +29 -1
- package/docs/00-quick-start.md +30 -7
- package/docs/02-bbr-smart-waits.md +6 -0
- package/docs/04-step-reference.md +2 -2
- package/docs/09-api-testing.md +9 -2
- package/docs/11-debugging.md +21 -0
- package/docs/12-ai-agent-guide.md +3 -1
- package/docs/13-faq.md +3 -0
- package/docs/15-tag-conventions.md +4 -1
- package/docs/16-ci-cd.md +29 -13
- package/docs/api-step-definitions.md +13 -2
- package/docs/global-settings.md +2 -2
- package/docs/install-webship-js/ddev-webship-js.md +3 -0
- package/docs/install-webship-js.md +14 -2
- package/examples/a11y-legacy-widget.html +34 -0
- package/examples/auth-state.html +42 -0
- package/examples/clock.html +33 -0
- package/examples/downloads/webship-archive.zip +0 -0
- package/examples/downloads/webship-notes.txt +4 -0
- package/examples/downloads/webship-report.csv +4 -0
- package/examples/downloads.html +16 -0
- package/examples/element-viewport.html +42 -0
- package/examples/field-types.html +98 -0
- package/examples/iframe-newsletter.html +29 -0
- package/examples/iframe-order.html +26 -0
- package/examples/iframe.html +21 -0
- package/examples/javascript-errors.html +35 -0
- package/examples/links.html +1 -0
- package/examples/metatags.html +18 -0
- package/examples/mouse-and-pointer.html +83 -0
- package/examples/native-dialogs.html +8 -0
- package/examples/network.html +83 -0
- package/examples/scroll-horizontal.html +50 -0
- package/examples/selectors-position.html +29 -0
- package/examples/storage.html +57 -0
- package/examples/viewport-size.html +24 -0
- package/examples/wait-conditions.html +69 -0
- package/examples/web-first.html +99 -0
- package/package.json +9 -2
- package/tests/assets/catalog.xml +19 -0
- package/tests/assets/feed-namespaced.xml +13 -0
- package/tests/assets/sitemap.xml +14 -0
- package/tests/assets/webship-site-expected.yaml +21 -0
- package/tests/assets/webship-site.schema.json +46 -0
- package/tests/assets/webship-site.yaml +21 -0
- package/tests/check-examples.js +235 -0
- package/tests/check-must-fail.js +84 -0
- package/tests/check-paths.js +82 -0
- package/tests/check-report.js +119 -0
- package/tests/check-scaffold.js +211 -0
- package/tests/features/a11y.feature +18 -0
- package/tests/features/auth-state.feature +32 -0
- package/tests/features/clock.feature +27 -0
- package/tests/features/cookie.feature +9 -0
- package/tests/features/dialog.feature +27 -0
- package/tests/features/element.feature +47 -0
- package/tests/features/field.feature +104 -0
- package/tests/features/file-download.feature +64 -0
- package/tests/features/iframe.feature +83 -0
- package/tests/features/javascript.feature +47 -0
- package/tests/features/link.feature +11 -0
- package/tests/features/metatag.feature +38 -0
- package/tests/features/mouse-and-pointer.feature +86 -0
- package/tests/features/network-mocking.feature +80 -0
- package/tests/features/responsive.feature +27 -0
- package/tests/features/rest-and-api-requests.feature +120 -0
- package/tests/features/scroll-horizontal.feature +55 -0
- package/tests/features/selectors-position.feature +41 -0
- package/tests/features/storage.feature +98 -0
- package/tests/features/test--then--i-see-locator.feature +13 -0
- package/tests/features/test--then--i-should--see-text-in-element.feature +9 -1
- package/tests/features/test--then--the-field-should-contain-value.feature +8 -0
- package/tests/features/video.feature +1 -0
- package/tests/features/wait.feature +89 -0
- package/tests/features/web-first.feature +100 -0
- package/tests/features/xml.feature +96 -0
- package/tests/features/yaml.feature +75 -0
- package/tests/must-fail/assertions.feature +96 -0
- package/tests/must-fail/waits.feature +51 -0
- package/tests/reports/README.md +2 -2
- package/tests/step-definitions/a11y.steps.js +12 -8
- package/tests/step-definitions/api.steps.js +18 -45
- package/tests/step-definitions/assertion.steps.js +235 -61
- package/tests/step-definitions/dialog.steps.js +2 -2
- package/tests/step-definitions/element.steps.js +3 -1
- package/tests/step-definitions/field.steps.js +152 -22
- package/tests/step-definitions/file-download.steps.js +74 -10
- package/tests/step-definitions/rest.steps.js +23 -12
- package/tests/step-definitions/screenshot.steps.js +1 -1
- package/tests/step-definitions/selectors.steps.js +9 -3
- package/tests/step-definitions/storage.steps.js +3 -3
- package/tests/step-definitions/wait.steps.js +129 -39
- package/tests/step-definitions/webship.js +211 -3
- package/tests/step-definitions/xml.steps.js +76 -14
- package/tests/step-definitions/yaml.steps.js +46 -27
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Checks the scaffold a new project gets (bin/init-webship.js, the script the
|
|
5
|
+
// post-install runs), the way a new user meets it:
|
|
6
|
+
//
|
|
7
|
+
// 1. `npm init -y` in an empty folder, then the scaffold: the files and the
|
|
8
|
+
// package.json scripts are there, and `npm test` is the suite, not npm's
|
|
9
|
+
// "no test specified" placeholder,
|
|
10
|
+
// 2. `npm test` in that project is green against a site (the examples/
|
|
11
|
+
// pages of this repository, served on a free port),
|
|
12
|
+
// 3. a feature named on the command line runs alone,
|
|
13
|
+
// 4. a second scaffold run changes nothing, and a `test` script the project
|
|
14
|
+
// chose itself is kept.
|
|
15
|
+
//
|
|
16
|
+
// The browser install is skipped (--skip-browsers): Chromium must be in the
|
|
17
|
+
// Playwright cache already, as it is after `npx playwright install chromium`.
|
|
18
|
+
//
|
|
19
|
+
// Usage: node tests/check-scaffold.js (npm run test:scaffold)
|
|
20
|
+
|
|
21
|
+
const crypto = require('crypto');
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const net = require('net');
|
|
24
|
+
const os = require('os');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const { spawn, spawnSync } = require('child_process');
|
|
27
|
+
|
|
28
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
29
|
+
const INIT = path.join(ROOT, 'bin', 'init-webship.js');
|
|
30
|
+
const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
31
|
+
const problems = [];
|
|
32
|
+
|
|
33
|
+
const EXPECTED_FILES = [
|
|
34
|
+
'cucumber.js',
|
|
35
|
+
'playwright.config.ts',
|
|
36
|
+
'tsconfig.json',
|
|
37
|
+
'package.json',
|
|
38
|
+
'tests/features/check-homepage.feature',
|
|
39
|
+
'tests/step-definitions/custom.js',
|
|
40
|
+
'tests/reports/README.md',
|
|
41
|
+
];
|
|
42
|
+
const EXPECTED_SCRIPTS = ['test', 'test:chromium', 'test:firefox', 'test:webkit', 'test:headed', 'test:fast', 'generate-reports'];
|
|
43
|
+
|
|
44
|
+
function scaffold(dir) {
|
|
45
|
+
return spawnSync(process.execPath, [INIT, '--cwd', dir, '--skip-browsers'], { encoding: 'utf8' });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function hashes(dir) {
|
|
49
|
+
const out = {};
|
|
50
|
+
for (const file of EXPECTED_FILES) {
|
|
51
|
+
const full = path.join(dir, file);
|
|
52
|
+
out[file] = fs.existsSync(full) ? crypto.createHash('sha1').update(fs.readFileSync(full)).digest('hex') : null;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The project uses this checkout as its webship-js and shares its
|
|
58
|
+
// dependencies, so nothing is downloaded.
|
|
59
|
+
function linkDependencies(dir) {
|
|
60
|
+
const target = path.join(dir, 'node_modules');
|
|
61
|
+
fs.mkdirSync(target, { recursive: true });
|
|
62
|
+
for (const entry of fs.readdirSync(path.join(ROOT, 'node_modules'))) {
|
|
63
|
+
fs.symlinkSync(path.join(ROOT, 'node_modules', entry), path.join(target, entry));
|
|
64
|
+
}
|
|
65
|
+
fs.symlinkSync(ROOT, path.join(target, 'webship-js'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function freePort() {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
const server = net.createServer();
|
|
71
|
+
server.on('error', reject);
|
|
72
|
+
server.listen(0, '127.0.0.1', () => {
|
|
73
|
+
const { port } = server.address();
|
|
74
|
+
server.close(() => resolve(port));
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function waitForPort(port, ms) {
|
|
80
|
+
const deadline = Date.now() + ms;
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
const attempt = () => {
|
|
83
|
+
const socket = net.connect(port, '127.0.0.1');
|
|
84
|
+
socket.on('connect', () => { socket.destroy(); resolve(true); });
|
|
85
|
+
socket.on('error', () => {
|
|
86
|
+
socket.destroy();
|
|
87
|
+
if (Date.now() > deadline) resolve(false);
|
|
88
|
+
else setTimeout(attempt, 200);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
attempt();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function main() {
|
|
96
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'webship-js-scaffold-'));
|
|
97
|
+
let server = null;
|
|
98
|
+
try {
|
|
99
|
+
// 1. A new project: npm init -y, then the scaffold.
|
|
100
|
+
const project = path.join(tmp, 'new-project');
|
|
101
|
+
fs.mkdirSync(project);
|
|
102
|
+
const init = spawnSync(NPM, ['init', '-y'], { cwd: project, encoding: 'utf8', shell: process.platform === 'win32' });
|
|
103
|
+
if (init.status !== 0) throw new Error(`npm init -y failed: ${init.stderr}`);
|
|
104
|
+
const placeholder = JSON.parse(fs.readFileSync(path.join(project, 'package.json'), 'utf8')).scripts.test;
|
|
105
|
+
|
|
106
|
+
const first = scaffold(project);
|
|
107
|
+
if (first.status !== 0) problems.push(`the scaffold exited with ${first.status}: ${first.stderr}`);
|
|
108
|
+
for (const file of EXPECTED_FILES) {
|
|
109
|
+
if (!fs.existsSync(path.join(project, file))) problems.push(`the scaffold did not write ${file}`);
|
|
110
|
+
}
|
|
111
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(project, 'package.json'), 'utf8'));
|
|
112
|
+
for (const name of EXPECTED_SCRIPTS) {
|
|
113
|
+
if (!pkg.scripts || !pkg.scripts[name]) problems.push(`package.json has no "${name}" script`);
|
|
114
|
+
}
|
|
115
|
+
if (pkg.scripts && pkg.scripts.test === placeholder) {
|
|
116
|
+
problems.push(`"npm test" is still the placeholder of npm init: ${placeholder}`);
|
|
117
|
+
}
|
|
118
|
+
if (!pkg.dependencies || !pkg.dependencies['webship-js']) problems.push('package.json does not depend on webship-js');
|
|
119
|
+
|
|
120
|
+
// 2. npm test in the new project, against the examples/ pages.
|
|
121
|
+
linkDependencies(project);
|
|
122
|
+
const port = await freePort();
|
|
123
|
+
server = spawn(process.execPath, [path.join(ROOT, 'node_modules', 'http-server', 'bin', 'http-server'), path.join(ROOT, 'examples'), '-p', String(port), '-a', '127.0.0.1', '-s'], { stdio: 'ignore' });
|
|
124
|
+
if (!await waitForPort(port, 15000)) throw new Error(`the examples server did not start on port ${port}`);
|
|
125
|
+
const run = spawnSync(NPM, ['test'], {
|
|
126
|
+
cwd: project,
|
|
127
|
+
encoding: 'utf8',
|
|
128
|
+
shell: process.platform === 'win32',
|
|
129
|
+
env: Object.assign({}, process.env, { LAUNCH_URL: `http://127.0.0.1:${port}`, FORCE_COLOR: '0', SLOW_MO: '0', WEBSHIP_REPORT_DISABLE: '1' }),
|
|
130
|
+
});
|
|
131
|
+
const report = path.join(project, 'tests', 'reports', 'cucumber_report.json');
|
|
132
|
+
let scenarios = 0;
|
|
133
|
+
let failed = 0;
|
|
134
|
+
if (fs.existsSync(report)) {
|
|
135
|
+
for (const feature of JSON.parse(fs.readFileSync(report, 'utf8'))) {
|
|
136
|
+
for (const scenario of feature.elements || []) {
|
|
137
|
+
scenarios++;
|
|
138
|
+
if ((scenario.steps || []).some((step) => step.result.status !== 'passed')) failed++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (run.status !== 0 || !scenarios || failed) {
|
|
143
|
+
problems.push(`"npm test" in the new project: exit ${run.status}, ${scenarios} scenario(s), ${failed} not passed\n${(run.stdout || '').split('\n').slice(-25).join('\n')}\n${run.stderr || ''}`);
|
|
144
|
+
} else {
|
|
145
|
+
console.log(` npm test in the new project: ${scenarios} scenario passed.`);
|
|
146
|
+
}
|
|
147
|
+
if (/colorsEnabled/.test((run.stdout || '') + (run.stderr || ''))) {
|
|
148
|
+
problems.push('the scaffolded cucumber.js makes cucumber-js print a deprecation warning (colorsEnabled)');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// A feature named on the command line runs alone, beside a second one.
|
|
152
|
+
const extra = path.join(project, 'tests', 'features', 'second.feature');
|
|
153
|
+
fs.writeFileSync(extra, 'Feature: Second\n\n Scenario: Second\n Given I am on the homepage\n');
|
|
154
|
+
const namedReport = path.join(tmp, 'named.json');
|
|
155
|
+
const named = spawnSync(process.execPath, [path.join(ROOT, 'node_modules', '@cucumber', 'cucumber', 'bin', 'cucumber.js'), '--dry-run', 'tests/features/second.feature', '--format', `json:${namedReport}`], {
|
|
156
|
+
cwd: project,
|
|
157
|
+
encoding: 'utf8',
|
|
158
|
+
env: Object.assign({}, process.env, { FORCE_COLOR: '0', WEBSHIP_REPORT_DISABLE: '1' }),
|
|
159
|
+
});
|
|
160
|
+
const namedScenarios = fs.existsSync(namedReport)
|
|
161
|
+
? JSON.parse(fs.readFileSync(namedReport, 'utf8')).reduce((n, feature) => n + (feature.elements || []).length, 0)
|
|
162
|
+
: -1;
|
|
163
|
+
if (namedScenarios !== 1) {
|
|
164
|
+
problems.push(`naming one feature on the command line in the new project selected ${namedScenarios} scenario(s), not 1\n${named.stderr || ''}`);
|
|
165
|
+
}
|
|
166
|
+
fs.rmSync(extra, { force: true });
|
|
167
|
+
|
|
168
|
+
// 3. A second run changes nothing.
|
|
169
|
+
fs.rmSync(path.join(project, 'node_modules'), { recursive: true, force: true });
|
|
170
|
+
const before = hashes(project);
|
|
171
|
+
const second = scaffold(project);
|
|
172
|
+
if (second.status !== 0) problems.push(`the second scaffold run exited with ${second.status}`);
|
|
173
|
+
const after = hashes(project);
|
|
174
|
+
for (const file of EXPECTED_FILES) {
|
|
175
|
+
if (before[file] !== after[file]) problems.push(`a second scaffold run changed ${file}`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// A test script the project chose is kept.
|
|
179
|
+
const own = path.join(tmp, 'own-test-script');
|
|
180
|
+
fs.mkdirSync(own);
|
|
181
|
+
fs.writeFileSync(path.join(own, 'package.json'), JSON.stringify({ name: 'own-test-script', version: '1.0.0', scripts: { test: 'node my-own-tests.js' } }, null, 2));
|
|
182
|
+
scaffold(own);
|
|
183
|
+
const ownPkg = JSON.parse(fs.readFileSync(path.join(own, 'package.json'), 'utf8'));
|
|
184
|
+
if (ownPkg.scripts.test !== 'node my-own-tests.js') problems.push(`the scaffold replaced a test script of the project: ${ownPkg.scripts.test}`);
|
|
185
|
+
if (!ownPkg.scripts['test:chromium']) problems.push('the scaffold did not add test:chromium beside an existing test script');
|
|
186
|
+
|
|
187
|
+
// No package.json at all: the scaffold writes one.
|
|
188
|
+
const bare = path.join(tmp, 'no-package-json');
|
|
189
|
+
fs.mkdirSync(bare);
|
|
190
|
+
scaffold(bare);
|
|
191
|
+
const barePkgPath = path.join(bare, 'package.json');
|
|
192
|
+
if (!fs.existsSync(barePkgPath) || !JSON.parse(fs.readFileSync(barePkgPath, 'utf8')).scripts.test) {
|
|
193
|
+
problems.push('without a package.json the scaffold did not write one with a test script');
|
|
194
|
+
}
|
|
195
|
+
} finally {
|
|
196
|
+
if (server) server.kill();
|
|
197
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (problems.length) {
|
|
201
|
+
console.error(`\n${problems.length} problem(s) with the scaffold:`);
|
|
202
|
+
for (const p of problems) console.error(' ' + p);
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
console.log('The scaffold gives a new project its files and scripts, and its first "npm test" is green.');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
main().catch((error) => {
|
|
209
|
+
console.error(error.stack || String(error));
|
|
210
|
+
process.exit(1);
|
|
211
|
+
});
|
|
@@ -59,3 +59,21 @@ Feature: Accessibility (a11y) smoke checks
|
|
|
59
59
|
And the page should pass the full accessibility check at level "AA"
|
|
60
60
|
And the element "main" should not violate the accessibility rule "image-alt"
|
|
61
61
|
And I print the full accessibility check
|
|
62
|
+
|
|
63
|
+
Scenario: A skip link that leads to the main content
|
|
64
|
+
Given I am on "/a11y-legacy-widget.html"
|
|
65
|
+
Then the page should have a skip link
|
|
66
|
+
And the page should have a main landmark
|
|
67
|
+
|
|
68
|
+
Scenario: The whole page passes the WCAG audit
|
|
69
|
+
Given I am on "/a11y.html"
|
|
70
|
+
Then the page should pass an accessibility audit
|
|
71
|
+
And the page should pass an accessibility audit at level "A"
|
|
72
|
+
And the page should pass an accessibility audit at level "AA"
|
|
73
|
+
And the page should pass an accessibility audit at level "AAA"
|
|
74
|
+
|
|
75
|
+
Scenario: Audit one part of a page, or everything but one part
|
|
76
|
+
Given I am on "/a11y-legacy-widget.html"
|
|
77
|
+
Then the element "main" should pass an accessibility audit
|
|
78
|
+
And the element "#main-content form" should pass an accessibility audit
|
|
79
|
+
And the page should pass an accessibility audit excluding ".legacy-widget"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Feature: Save and restore the auth state
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to save the cookies and the local storage of a signed-in visitor to a file and restore them later,
|
|
4
|
+
so that a scenario starts signed in without going through the sign-in form.
|
|
5
|
+
|
|
6
|
+
Scenario: Save the state of a signed-in visitor, then restore it
|
|
7
|
+
Given I am on "/auth-state.html"
|
|
8
|
+
Then "#auth-status" should have text "You are not signed in"
|
|
9
|
+
When I press "Sign in"
|
|
10
|
+
Then "#auth-status" should have text "Signed in as Webship Tester"
|
|
11
|
+
When I save the auth state to "tests/auth/webship-tester.json"
|
|
12
|
+
And I clear the auth state
|
|
13
|
+
And I reload the page
|
|
14
|
+
Then "#auth-status" should have text "You are not signed in"
|
|
15
|
+
And a cookie with the name "webship_session" should not exist
|
|
16
|
+
When I restore the auth state from "tests/auth/webship-tester.json"
|
|
17
|
+
And I am on "/auth-state.html"
|
|
18
|
+
Then "#auth-status" should have text "Signed in as Webship Tester"
|
|
19
|
+
And a cookie with the name "webship_session" and the value "signed-in" should exist
|
|
20
|
+
|
|
21
|
+
Scenario: The saved state carries cookies and local storage to another page
|
|
22
|
+
Given I am on "/storage.html"
|
|
23
|
+
And the cookie "webship_session" is set to "signed-in"
|
|
24
|
+
And the local storage "webship_user" is set to "Webship Editor"
|
|
25
|
+
When we save the auth state to "tests/auth/webship-editor.json"
|
|
26
|
+
And we clear the auth state
|
|
27
|
+
And we restore the auth state from "tests/auth/webship-editor.json"
|
|
28
|
+
And I am on "/auth-state.html"
|
|
29
|
+
Then "#auth-status" should have text "Signed in as Webship Editor"
|
|
30
|
+
When I am on "/storage.html"
|
|
31
|
+
Then "#cookies" should have text "webship_session = signed-in"
|
|
32
|
+
And "#local-storage" should have text "webship_user = Webship Editor"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Feature: The browser clock
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to set the time the page reads and move it forward,
|
|
4
|
+
so that an autosave, a timeout or a date can be tested without waiting for it.
|
|
5
|
+
|
|
6
|
+
Scenario: Advance the clock by milliseconds, seconds and minutes
|
|
7
|
+
Given the system time is "2026-05-08T10:00:00Z"
|
|
8
|
+
And I am on "/clock.html"
|
|
9
|
+
Then "#today" should have text "2026-05-08"
|
|
10
|
+
And "#autosave" should have text "Draft not saved yet"
|
|
11
|
+
When I advance the clock by 1000 ms
|
|
12
|
+
Then "#autosave" should have text "Draft not saved yet"
|
|
13
|
+
When I advance the clock by 29 seconds
|
|
14
|
+
Then "#autosave" should have text "Draft saved"
|
|
15
|
+
And "#session" should have text "Session active"
|
|
16
|
+
When we advance the clock by 1 second
|
|
17
|
+
And I advance the clock by 4 minutes
|
|
18
|
+
Then "#session" should have text "Session active"
|
|
19
|
+
When I advance the clock by 1 minute
|
|
20
|
+
Then "#session" should have text "Session expired"
|
|
21
|
+
|
|
22
|
+
Scenario: Set the system time
|
|
23
|
+
Given the system time is "2026-12-31T23:59:00Z"
|
|
24
|
+
And I am on "/clock.html"
|
|
25
|
+
Then "#today" should have text "2026-12-31"
|
|
26
|
+
When I set the system time to "2027-01-01T00:00:30Z"
|
|
27
|
+
Then "#today" should have text "2027-01-01"
|
|
@@ -11,3 +11,12 @@ Feature: Cookie step definitions
|
|
|
11
11
|
And a cookie with the name "language" and the value "fr" should not exist
|
|
12
12
|
And a cookie with the name "preferences" and a value containing "lightmode" should not exist
|
|
13
13
|
And a cookie with a name containing "old" should not exist
|
|
14
|
+
|
|
15
|
+
Scenario: Part of a cookie name together with its value
|
|
16
|
+
Given I am on "/cookies.html"
|
|
17
|
+
Then a cookie with a name containing "pref" and the value "darkmode-enabled" should exist
|
|
18
|
+
And a cookie with a name containing "session" and the value "abc123" should exist
|
|
19
|
+
And a cookie with a name containing "session" and the value "expired" should not exist
|
|
20
|
+
And a cookie with a name containing "lang" and the value "fr" should not exist
|
|
21
|
+
And a cookie with a name containing "pref" and a value containing "lightmode" should not exist
|
|
22
|
+
And a cookie with a name containing "old" and a value containing "darkmode" should not exist
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Feature: Native browser dialogs
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to answer a prompt and read what a dialog said,
|
|
4
|
+
so that a flow behind an alert, a confirm or a prompt can be tested.
|
|
5
|
+
|
|
6
|
+
Scenario: Accept the next prompt with a text
|
|
7
|
+
Given I am on "/native-dialogs.html"
|
|
8
|
+
And I will accept the next dialog with "Quarterly report"
|
|
9
|
+
When I press "Rename item"
|
|
10
|
+
Then I should see "Name: Quarterly report"
|
|
11
|
+
And the last dialog type should be "prompt"
|
|
12
|
+
And the last dialog message should contain "new name"
|
|
13
|
+
|
|
14
|
+
Scenario: Read a part of the message of a confirm
|
|
15
|
+
Given I am on "/native-dialogs.html"
|
|
16
|
+
And we will accept the next dialog with "ignored by a confirm"
|
|
17
|
+
When I press "Delete item"
|
|
18
|
+
Then I should see "Item deleted #1"
|
|
19
|
+
And the last dialog message should contain "Delete this"
|
|
20
|
+
And the last dialog type should be "confirm"
|
|
21
|
+
|
|
22
|
+
Scenario: Dismiss a prompt
|
|
23
|
+
Given I am on "/native-dialogs.html"
|
|
24
|
+
And I will dismiss the next dialog
|
|
25
|
+
When I press "Rename item"
|
|
26
|
+
Then I should see "Rename cancelled"
|
|
27
|
+
And the last dialog message should contain "Enter the new name"
|
|
@@ -14,3 +14,50 @@ Feature: Element step definitions
|
|
|
14
14
|
Given I am on "/element.html"
|
|
15
15
|
When I click on the element "#btn"
|
|
16
16
|
Then I should see "clicked"
|
|
17
|
+
|
|
18
|
+
Scenario: No element has an attribute value containing a text
|
|
19
|
+
Given I am on "/element.html"
|
|
20
|
+
Then the element "p" with the attribute "data-role" and the value containing "tro" should exist
|
|
21
|
+
And the element "p" with the attribute "data-role" and the value containing "missing" should not exist
|
|
22
|
+
|
|
23
|
+
Scenario: Trigger a JS event on an element
|
|
24
|
+
Given I am on "/element-viewport.html"
|
|
25
|
+
Then "#event-log" should have text "No event yet"
|
|
26
|
+
When I trigger the JS event "change" on the element "#country"
|
|
27
|
+
Then "#event-log" should have text "The change event reached the country field"
|
|
28
|
+
When I trigger the JS event "webship-ping" on the element "#left-box"
|
|
29
|
+
Then "#event-log" should have text "The webship-ping event reached the left box"
|
|
30
|
+
|
|
31
|
+
Scenario: Hover over an element
|
|
32
|
+
Given I am on "/element-viewport.html"
|
|
33
|
+
When I hover over the element "#hover-button"
|
|
34
|
+
Then "#event-log" should have text "The pointer is over the hover button"
|
|
35
|
+
|
|
36
|
+
Scenario: Scroll to an element below the fold
|
|
37
|
+
Given I am on "/element-viewport.html"
|
|
38
|
+
Then the element "#top-banner" should be displayed within a viewport
|
|
39
|
+
And the element "#below-fold" should not be displayed within a viewport
|
|
40
|
+
When I scroll to the element "#below-fold"
|
|
41
|
+
Then the element "#below-fold" should be displayed within a viewport
|
|
42
|
+
And the element "#top-banner" should not be displayed within a viewport
|
|
43
|
+
|
|
44
|
+
Scenario: Element within the viewport with a top offset
|
|
45
|
+
Given I am on "/element-viewport.html"
|
|
46
|
+
Then the element "#centered-box" should be displayed within a viewport with a top offset of 60 pixels
|
|
47
|
+
And the element "#top-banner" should not be displayed within a viewport with a top offset of 60 pixels
|
|
48
|
+
And the element "#below-fold" should not be displayed within a viewport with a top offset of 60 pixels
|
|
49
|
+
|
|
50
|
+
Scenario: Element at the top of the viewport
|
|
51
|
+
Given I am on "/element-viewport.html"
|
|
52
|
+
Then the element "#top-banner" should be at the top of the viewport
|
|
53
|
+
|
|
54
|
+
Scenario: Element centered in the viewport
|
|
55
|
+
Given I am on "/element-viewport.html"
|
|
56
|
+
Then the element "#centered-box" should be centered in the viewport
|
|
57
|
+
|
|
58
|
+
Scenario: Element centered in the viewport after a resize
|
|
59
|
+
Given I am on "/element-viewport.html"
|
|
60
|
+
When I set the viewport size to 800x600
|
|
61
|
+
Then the element "#centered-box" should be centered in the viewport
|
|
62
|
+
When I scroll to the element "#below-fold"
|
|
63
|
+
Then the element "#below-fold" should be centered in the viewport
|
|
@@ -23,3 +23,107 @@ Feature: Field step definitions
|
|
|
23
23
|
Scenario: Disable browser validation
|
|
24
24
|
Given I am on "/field.html"
|
|
25
25
|
And browser validation for the form "#f" is disabled
|
|
26
|
+
|
|
27
|
+
Scenario: Enabled and disabled state of a field
|
|
28
|
+
Given I am on "/field-types.html"
|
|
29
|
+
Then the field "Account ID" should have "disabled" state
|
|
30
|
+
And the field "account_id" should have "disabled" state
|
|
31
|
+
And the field "Display name" should have "enabled" state
|
|
32
|
+
And the field "#display-name" should have "enabled" state
|
|
33
|
+
|
|
34
|
+
Scenario: Fill a multi-value field
|
|
35
|
+
Given I am on "/field-types.html"
|
|
36
|
+
When I fill in the multi-value field "tags" with the following values:
|
|
37
|
+
| bdd |
|
|
38
|
+
| testing |
|
|
39
|
+
| webship |
|
|
40
|
+
And we fill in the multi-value field "phones" with the following values:
|
|
41
|
+
| 0790000000 |
|
|
42
|
+
| 0791111111 |
|
|
43
|
+
Then "#tags-1" should have value "bdd"
|
|
44
|
+
And "#tags-2" should have value "testing"
|
|
45
|
+
And "#tags-3" should have value "webship"
|
|
46
|
+
And "#phones-1" should have value "0790000000"
|
|
47
|
+
And "#phones-2" should have value "0791111111"
|
|
48
|
+
|
|
49
|
+
Scenario: Fill a rich-text field
|
|
50
|
+
Given I am on "/field-types.html"
|
|
51
|
+
When I fill in the WYSIWYG field "body" with the "Hello from the editor"
|
|
52
|
+
Then "#body-editor" should contain text "Hello from the editor"
|
|
53
|
+
And "#body-editor p" should have text "Hello from the editor"
|
|
54
|
+
And "#body" should have value "Hello from the editor"
|
|
55
|
+
|
|
56
|
+
Scenario: Fill one rich-text field of several
|
|
57
|
+
Given I am on "/field-types.html"
|
|
58
|
+
When I fill in the WYSIWYG field "summary" with the "Short summary"
|
|
59
|
+
Then "#summary-editor p" should have text "Short summary"
|
|
60
|
+
And "#summary" should have value "Short summary"
|
|
61
|
+
And "#body-editor" should have text ""
|
|
62
|
+
When I fill in the WYSIWYG field "Body" with the "Long body"
|
|
63
|
+
Then "#body-editor p" should have text "Long body"
|
|
64
|
+
And "#summary-editor p" should have text "Short summary"
|
|
65
|
+
When we fill in the WYSIWYG field "Summary" with the "Found by its label"
|
|
66
|
+
Then "#summary-editor p" should have text "Found by its label"
|
|
67
|
+
And "#body-editor p" should have text "Long body"
|
|
68
|
+
|
|
69
|
+
Scenario: Selected options of a select with several values
|
|
70
|
+
Given I am on "/field-types.html"
|
|
71
|
+
Then the option "Red" should be selected within the select element "#colors"
|
|
72
|
+
And the option "Blue" should be selected within the select element "#colors"
|
|
73
|
+
And the option "Green" should not be selected within the select element "#colors"
|
|
74
|
+
When I unselect "Red" from "#colors"
|
|
75
|
+
Then the option "Red" should not be selected within the select element "#colors"
|
|
76
|
+
And the option "Blue" should be selected within the select element "#colors"
|
|
77
|
+
And "#colors-summary" should have text "Selected: Blue"
|
|
78
|
+
When I clear the select "#colors"
|
|
79
|
+
Then the option "Blue" should not be selected within the select element "#colors"
|
|
80
|
+
And "#colors-summary" should have text "Selected: none"
|
|
81
|
+
|
|
82
|
+
Scenario: Uncheck a checkbox by its selector
|
|
83
|
+
Given I am on "/field-types.html"
|
|
84
|
+
Then the "#newsletter" checkbox is checked
|
|
85
|
+
And "#terms" checkbox is not checked
|
|
86
|
+
When I uncheck the checkbox "#newsletter"
|
|
87
|
+
Then the "#newsletter" checkbox is not checked
|
|
88
|
+
|
|
89
|
+
Scenario: Fill the date and the time of a datetime field
|
|
90
|
+
Given I am on "/field-types.html"
|
|
91
|
+
When I fill in the datetime field "Reminder" with date "2026-09-15" and time "14:00"
|
|
92
|
+
Then "#reminder-date" should have value "2026-09-15"
|
|
93
|
+
And "#reminder-time" should have value "14:00"
|
|
94
|
+
And "#pickup-date" should have value ""
|
|
95
|
+
|
|
96
|
+
Scenario: Fill one part of a datetime field
|
|
97
|
+
Given I am on "/field-types.html"
|
|
98
|
+
When I fill in the date part of the datetime field "Pickup" with "2026-07-04"
|
|
99
|
+
Then "#pickup-date" should have value "2026-07-04"
|
|
100
|
+
And "#pickup-time" should have value ""
|
|
101
|
+
When I fill in the time part of the datetime field "Pickup" with "08:30"
|
|
102
|
+
Then "#pickup-time" should have value "08:30"
|
|
103
|
+
And "#reminder-date" should have value ""
|
|
104
|
+
|
|
105
|
+
Scenario: Fill the start and the end of a date range
|
|
106
|
+
Given I am on "/field-types.html"
|
|
107
|
+
When I fill in the start datetime field "event" with date "2026-05-08" and time "10:00"
|
|
108
|
+
And I fill in the end datetime field "event" with date "2026-05-09" and time "18:00"
|
|
109
|
+
Then "#event-start-date" should have value "2026-05-08"
|
|
110
|
+
And "#event-start-time" should have value "10:00"
|
|
111
|
+
And "#event-end-date" should have value "2026-05-09"
|
|
112
|
+
And "#event-end-time" should have value "18:00"
|
|
113
|
+
|
|
114
|
+
Scenario: Datetime inputs right after their label, and a range named by its legend
|
|
115
|
+
Given I am on "/field-types.html"
|
|
116
|
+
When I fill in the datetime field "Departure" with date "2026-12-31" and time "23:59"
|
|
117
|
+
Then "#departure-date" should have value "2026-12-31"
|
|
118
|
+
And "#departure-time" should have value "23:59"
|
|
119
|
+
When I fill in the date part of the datetime field "Departure" with "2027-01-01"
|
|
120
|
+
And I fill in the time part of the datetime field "Departure" with "06:15"
|
|
121
|
+
Then "#departure-date" should have value "2027-01-01"
|
|
122
|
+
And "#departure-time" should have value "06:15"
|
|
123
|
+
When I fill in the start datetime field "Event" with date "2026-05-08" and time "10:00"
|
|
124
|
+
And we fill in the end datetime field "Event" with date "2026-05-09" and time "18:00"
|
|
125
|
+
Then "#event-start-date" should have value "2026-05-08"
|
|
126
|
+
And "#event-start-time" should have value "10:00"
|
|
127
|
+
And "#event-end-date" should have value "2026-05-09"
|
|
128
|
+
And "#event-end-time" should have value "18:00"
|
|
129
|
+
And "#reminder-date" should have value ""
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Feature: File download steps
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to download a file from a link or a URL and read what came down,
|
|
4
|
+
so that I can check its name and its content.
|
|
5
|
+
|
|
6
|
+
Scenario: Download a file from a link and read it
|
|
7
|
+
Given I am on "/downloads.html"
|
|
8
|
+
When I download the file from the link "Download report"
|
|
9
|
+
Then the downloaded file name should be "webship-report.csv"
|
|
10
|
+
And the downloaded file name should contain "report"
|
|
11
|
+
And the downloaded file name should contain ".csv"
|
|
12
|
+
And the downloaded file should contain:
|
|
13
|
+
"""
|
|
14
|
+
name,role,status
|
|
15
|
+
"""
|
|
16
|
+
And the downloaded file should contain:
|
|
17
|
+
"""
|
|
18
|
+
Webship Admin,administrator,active
|
|
19
|
+
Webship Guest,visitor,blocked
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
Scenario: The link decides the name of the downloaded file
|
|
23
|
+
Given I am on "/downloads.html"
|
|
24
|
+
When we download the file from the link "Download release notes"
|
|
25
|
+
Then the downloaded file name should be "release-notes-2026.txt"
|
|
26
|
+
And the downloaded file name should contain "2026"
|
|
27
|
+
And the downloaded file should contain:
|
|
28
|
+
"""
|
|
29
|
+
Webship-js release notes
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
Scenario: A file downloaded from a URL is read the same way
|
|
33
|
+
When I download the file from the URL "/downloads/webship-report.csv"
|
|
34
|
+
Then the downloaded file name should contain "webship-report"
|
|
35
|
+
And the downloaded file should contain:
|
|
36
|
+
"""
|
|
37
|
+
Webship Tester,editor,active
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
Scenario: The files in a downloaded zip archive, by name
|
|
41
|
+
Given I am on "/downloads.html"
|
|
42
|
+
When I download the file from the link "Download archive"
|
|
43
|
+
Then the downloaded file name should be "webship-archive.zip"
|
|
44
|
+
And the downloaded file should be a zip archive containing the following files named:
|
|
45
|
+
| readme.txt |
|
|
46
|
+
| reports/summary.csv |
|
|
47
|
+
| reports/users-2026.csv |
|
|
48
|
+
And the downloaded file should be a zip archive containing the following files named:
|
|
49
|
+
| summary.csv | users-2026.csv |
|
|
50
|
+
|
|
51
|
+
Scenario: The files in a downloaded zip archive, by part of their name
|
|
52
|
+
When I download the file from the URL "/downloads/webship-archive.zip"
|
|
53
|
+
Then the downloaded file should be a zip archive containing the following files partially named:
|
|
54
|
+
| readme |
|
|
55
|
+
| reports/ |
|
|
56
|
+
| 2026 |
|
|
57
|
+
And the downloaded file should be a zip archive containing the following files partially named:
|
|
58
|
+
| summary | users |
|
|
59
|
+
And the downloaded file should be a zip archive not containing the following files partially named:
|
|
60
|
+
| secret |
|
|
61
|
+
| .env |
|
|
62
|
+
| __MACOSX |
|
|
63
|
+
And the downloaded file should be a zip archive not containing the following files partially named:
|
|
64
|
+
| .pdf | invoice |
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Feature: Iframe step definitions
|
|
2
|
+
As a tester,
|
|
3
|
+
I want to switch to an iframe, act inside it and read its text,
|
|
4
|
+
so that embedded forms and widgets can be tested like the rest of the page.
|
|
5
|
+
|
|
6
|
+
Scenario: Switch to an iframe by CSS selector
|
|
7
|
+
Given I am on "/iframe.html"
|
|
8
|
+
When I switch to iframe "#order-frame"
|
|
9
|
+
Then I should see "Order form inside the iframe" inside the iframe
|
|
10
|
+
And I should not see "Newsletter form inside the iframe" inside the iframe
|
|
11
|
+
|
|
12
|
+
Scenario: Switch to the iframe by CSS selector, with the article
|
|
13
|
+
Given I am on "/iframe.html"
|
|
14
|
+
When I switch to the iframe ".newsletter-widget"
|
|
15
|
+
Then I should see "Newsletter form inside the iframe" inside the iframe
|
|
16
|
+
And I should not see "Order form inside the iframe" inside the iframe
|
|
17
|
+
|
|
18
|
+
Scenario: Switch to an iframe with a locator
|
|
19
|
+
Given I am on "/iframe.html"
|
|
20
|
+
When I switch to iframe with locator "iframe[src*=newsletter]"
|
|
21
|
+
Then I should see "Newsletter form inside the iframe" inside the iframe
|
|
22
|
+
And I should not see "Order form inside the iframe" inside the iframe
|
|
23
|
+
|
|
24
|
+
Scenario: Switch to the iframe with a title
|
|
25
|
+
Given I am on "/iframe.html"
|
|
26
|
+
When I switch to the iframe with title "Order form"
|
|
27
|
+
Then I should see "Order form inside the iframe" inside the iframe
|
|
28
|
+
And I should not see "Newsletter form inside the iframe" inside the iframe
|
|
29
|
+
|
|
30
|
+
Scenario: Switch to the iframe with a name
|
|
31
|
+
Given I am on "/iframe.html"
|
|
32
|
+
When I switch to the iframe with name "newsletter"
|
|
33
|
+
Then I should see "Newsletter form inside the iframe" inside the iframe
|
|
34
|
+
And I should not see "Order form inside the iframe" inside the iframe
|
|
35
|
+
|
|
36
|
+
Scenario: Switch from one iframe to another
|
|
37
|
+
Given I am on "/iframe.html"
|
|
38
|
+
When I switch to the iframe with name "order"
|
|
39
|
+
Then I should see "Order form inside the iframe" inside the iframe
|
|
40
|
+
When I switch to the iframe with title "Newsletter form"
|
|
41
|
+
Then I should see "Newsletter form inside the iframe" inside the iframe
|
|
42
|
+
And I should not see "Order form inside the iframe" inside the iframe
|
|
43
|
+
|
|
44
|
+
Scenario: The text of the root document is not inside the iframe
|
|
45
|
+
Given I am on "/iframe.html"
|
|
46
|
+
When I switch to iframe "#order-frame"
|
|
47
|
+
Then I should not see "This text is in the root document" inside the iframe
|
|
48
|
+
When I switch to the root document
|
|
49
|
+
Then I should see "This text is in the root document"
|
|
50
|
+
|
|
51
|
+
Scenario: Click a text inside the iframe
|
|
52
|
+
Given I am on "/iframe.html"
|
|
53
|
+
When I switch to iframe "#order-frame"
|
|
54
|
+
Then I should not see "Order confirmed" inside the iframe
|
|
55
|
+
When I click "Confirm" inside the iframe
|
|
56
|
+
Then I should see "Order confirmed" inside the iframe
|
|
57
|
+
|
|
58
|
+
Scenario: Click an element by its id inside the iframe
|
|
59
|
+
Given I am on "/iframe.html"
|
|
60
|
+
When I switch to iframe "#order-frame"
|
|
61
|
+
And I click "cancel-btn" by attr inside the iframe
|
|
62
|
+
Then I should see "Order cancelled" inside the iframe
|
|
63
|
+
And I should not see "Order confirmed" inside the iframe
|
|
64
|
+
|
|
65
|
+
Scenario: Click an element by its test id inside the iframe
|
|
66
|
+
Given I am on "/iframe.html"
|
|
67
|
+
When I switch to iframe "#order-frame"
|
|
68
|
+
And I click "Confirm" inside the iframe
|
|
69
|
+
And I click "cancel-order" by attr inside the iframe
|
|
70
|
+
Then I should see "Order cancelled" inside the iframe
|
|
71
|
+
|
|
72
|
+
Scenario: Fill in a field by its name inside the iframe
|
|
73
|
+
Given I am on "/iframe.html"
|
|
74
|
+
When I switch to the iframe with name "newsletter"
|
|
75
|
+
Then I should not see "Hello Webship" inside the iframe
|
|
76
|
+
When I fill in "subscriber_name" with "Webship" inside the iframe
|
|
77
|
+
Then I should see "Hello Webship" inside the iframe
|
|
78
|
+
|
|
79
|
+
Scenario: Fill in a field by its id inside the iframe
|
|
80
|
+
Given I am on "/iframe.html"
|
|
81
|
+
When I switch to the iframe with name "newsletter"
|
|
82
|
+
And I fill in "city" with "Amman" inside the iframe
|
|
83
|
+
Then I should see "City set to Amman" inside the iframe
|