@esimplicity/stack-tests 0.1.0 → 0.1.2
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.
|
@@ -93,23 +93,23 @@ function registerApiHttpSteps(test) {
|
|
|
93
93
|
world.lastContentType = result.contentType;
|
|
94
94
|
world.lastResponse = result.response;
|
|
95
95
|
}
|
|
96
|
-
When("I GET {string}", { tags: "@api" }, async ({ api, world }, path) => {
|
|
96
|
+
When("I GET {string}", { tags: "@api or @hybrid" }, async ({ api, world }, path) => {
|
|
97
97
|
await send({ api, world }, "GET", path);
|
|
98
98
|
});
|
|
99
|
-
When("I DELETE {string}", { tags: "@api" }, async ({ api, world }, path) => {
|
|
99
|
+
When("I DELETE {string}", { tags: "@api or @hybrid" }, async ({ api, world }, path) => {
|
|
100
100
|
await send({ api, world }, "DELETE", path);
|
|
101
101
|
});
|
|
102
|
-
When("I POST {string} with JSON body:", { tags: "@api" }, async ({ api, world }, path, docString) => {
|
|
102
|
+
When("I POST {string} with JSON body:", { tags: "@api or @hybrid" }, async ({ api, world }, path, docString) => {
|
|
103
103
|
const interpolated = interpolate(docString ?? "", world.vars);
|
|
104
104
|
const parsed = tryParseJson(interpolated) ?? interpolated;
|
|
105
105
|
await send({ api, world }, "POST", path, parsed);
|
|
106
106
|
});
|
|
107
|
-
When("I PATCH {string} with JSON body:", { tags: "@api" }, async ({ api, world }, path, docString) => {
|
|
107
|
+
When("I PATCH {string} with JSON body:", { tags: "@api or @hybrid" }, async ({ api, world }, path, docString) => {
|
|
108
108
|
const interpolated = interpolate(docString ?? "", world.vars);
|
|
109
109
|
const parsed = tryParseJson(interpolated) ?? interpolated;
|
|
110
110
|
await send({ api, world }, "PATCH", path, parsed);
|
|
111
111
|
});
|
|
112
|
-
When("I PUT {string} with JSON body:", { tags: "@api" }, async ({ api, world }, path, docString) => {
|
|
112
|
+
When("I PUT {string} with JSON body:", { tags: "@api or @hybrid" }, async ({ api, world }, path, docString) => {
|
|
113
113
|
const interpolated = interpolate(docString ?? "", world.vars);
|
|
114
114
|
const parsed = tryParseJson(interpolated) ?? interpolated;
|
|
115
115
|
await send({ api, world }, "PUT", path, parsed);
|
|
@@ -121,22 +121,22 @@ import { createBdd as createBdd2 } from "playwright-bdd";
|
|
|
121
121
|
import { expect as expect2 } from "@playwright/test";
|
|
122
122
|
function registerApiAssertionSteps(test) {
|
|
123
123
|
const { Then } = createBdd2(test);
|
|
124
|
-
Then("the response status should be {int}", { tags: "@api" }, async ({ world }, code) => {
|
|
124
|
+
Then("the response status should be {int}", { tags: "@api or @hybrid" }, async ({ world }, code) => {
|
|
125
125
|
expect2(world.lastStatus, `Unexpected status. Body: ${world.lastText}`).toBe(code);
|
|
126
126
|
});
|
|
127
|
-
Then("the response should be a JSON array", { tags: "@api" }, async ({ world }) => {
|
|
127
|
+
Then("the response should be a JSON array", { tags: "@api or @hybrid" }, async ({ world }) => {
|
|
128
128
|
expect2(Array.isArray(world.lastJson), `Expected JSON array. Body: ${world.lastText}`).toBe(true);
|
|
129
129
|
});
|
|
130
|
-
Then("the response should be a JSON object", { tags: "@api" }, async ({ world }) => {
|
|
130
|
+
Then("the response should be a JSON object", { tags: "@api or @hybrid" }, async ({ world }) => {
|
|
131
131
|
const v = world.lastJson;
|
|
132
132
|
expect2(v !== null && typeof v === "object" && !Array.isArray(v), `Expected JSON object. Body: ${world.lastText}`).toBe(true);
|
|
133
133
|
});
|
|
134
|
-
Then("the value at {string} should equal {string}", { tags: "@api" }, async ({ world }, path, expectedRaw) => {
|
|
134
|
+
Then("the value at {string} should equal {string}", { tags: "@api or @hybrid" }, async ({ world }, path, expectedRaw) => {
|
|
135
135
|
const actual = selectPath(world.lastJson, path);
|
|
136
136
|
const expected = parseExpected(expectedRaw, world);
|
|
137
137
|
expect2(actual).toEqual(expected);
|
|
138
138
|
});
|
|
139
|
-
Then("I store the value at {string} as {string}", { tags: "@api" }, async ({ world, cleanup }, path, varName) => {
|
|
139
|
+
Then("I store the value at {string} as {string}", { tags: "@api or @hybrid" }, async ({ world, cleanup }, path, varName) => {
|
|
140
140
|
const val = selectPath(world.lastJson, path);
|
|
141
141
|
world.vars[varName] = String(val);
|
|
142
142
|
cleanup.registerFromVar(world, varName, val, world.lastJson);
|
|
@@ -147,13 +147,13 @@ function registerApiAssertionSteps(test) {
|
|
|
147
147
|
import { createBdd as createBdd3 } from "playwright-bdd";
|
|
148
148
|
function registerApiAuthSteps(test) {
|
|
149
149
|
const { Given } = createBdd3(test);
|
|
150
|
-
Given("I am authenticated as an admin via API", { tags: "@api" }, async ({ auth, world }) => {
|
|
150
|
+
Given("I am authenticated as an admin via API", { tags: "@api or @hybrid" }, async ({ auth, world }) => {
|
|
151
151
|
await auth.apiLoginAsAdmin(world);
|
|
152
152
|
});
|
|
153
|
-
Given("I am authenticated as a user via API", { tags: "@api" }, async ({ auth, world }) => {
|
|
153
|
+
Given("I am authenticated as a user via API", { tags: "@api or @hybrid" }, async ({ auth, world }) => {
|
|
154
154
|
await auth.apiLoginAsUser(world);
|
|
155
155
|
});
|
|
156
|
-
Given("I set bearer token from variable {string}", { tags: "@api" }, async ({ auth, world }, varName) => {
|
|
156
|
+
Given("I set bearer token from variable {string}", { tags: "@api or @hybrid" }, async ({ auth, world }, varName) => {
|
|
157
157
|
const token = world.vars[varName];
|
|
158
158
|
if (!token) throw new Error(`No token found in variable '${varName}'`);
|
|
159
159
|
auth.apiSetBearer(world, token);
|
|
@@ -210,31 +210,31 @@ function registerSharedVarSteps(test) {
|
|
|
210
210
|
import { createBdd as createBdd7 } from "playwright-bdd";
|
|
211
211
|
function registerUiBasicSteps(test) {
|
|
212
212
|
const { Given, When, Then } = createBdd7(test);
|
|
213
|
-
Given("I navigate to {string}", { tags: "@ui" }, async ({ ui, world }, path) => {
|
|
213
|
+
Given("I navigate to {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, path) => {
|
|
214
214
|
await ui.goto(interpolate(path, world.vars));
|
|
215
215
|
});
|
|
216
|
-
When("I click the button {string}", { tags: "@ui" }, async ({ ui, world }, name) => {
|
|
216
|
+
When("I click the button {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, name) => {
|
|
217
217
|
await ui.clickButton(interpolate(name, world.vars));
|
|
218
218
|
});
|
|
219
|
-
When("I click the link {string}", { tags: "@ui" }, async ({ ui, world }, name) => {
|
|
219
|
+
When("I click the link {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, name) => {
|
|
220
220
|
await ui.clickLink(interpolate(name, world.vars));
|
|
221
221
|
});
|
|
222
|
-
When("I fill the placeholder {string} with {string}", { tags: "@ui" }, async ({ ui, world }, placeholder, value) => {
|
|
222
|
+
When("I fill the placeholder {string} with {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, placeholder, value) => {
|
|
223
223
|
await ui.fillPlaceholder(interpolate(placeholder, world.vars), interpolate(value, world.vars));
|
|
224
224
|
});
|
|
225
|
-
When("I fill the field {string} with {string}", { tags: "@ui" }, async ({ ui, world }, label, value) => {
|
|
225
|
+
When("I fill the field {string} with {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, label, value) => {
|
|
226
226
|
await ui.fillLabel(interpolate(label, world.vars), interpolate(value, world.vars));
|
|
227
227
|
});
|
|
228
|
-
When("I log in as admin in UI", { tags: "@ui" }, async ({ auth, world }) => {
|
|
228
|
+
When("I log in as admin in UI", { tags: "@ui or @hybrid" }, async ({ auth, world }) => {
|
|
229
229
|
await auth.uiLoginAsAdmin(world);
|
|
230
230
|
});
|
|
231
|
-
When("I log in as user in UI", { tags: "@ui" }, async ({ auth, world }) => {
|
|
231
|
+
When("I log in as user in UI", { tags: "@ui or @hybrid" }, async ({ auth, world }) => {
|
|
232
232
|
await auth.uiLoginAsUser(world);
|
|
233
233
|
});
|
|
234
|
-
Then("I should see text {string}", { tags: "@ui" }, async ({ ui, world }, text) => {
|
|
234
|
+
Then("I should see text {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, text) => {
|
|
235
235
|
await ui.expectText(interpolate(text, world.vars));
|
|
236
236
|
});
|
|
237
|
-
Then("the URL should contain {string}", { tags: "@ui" }, async ({ ui, world }, part) => {
|
|
237
|
+
Then("the URL should contain {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, part) => {
|
|
238
238
|
await ui.expectUrlContains(interpolate(part, world.vars));
|
|
239
239
|
});
|
|
240
240
|
}
|
|
@@ -339,36 +339,36 @@ function parseRegex(input) {
|
|
|
339
339
|
}
|
|
340
340
|
function registerWizardSteps(test) {
|
|
341
341
|
const { Given, When, Then } = createBdd8(test);
|
|
342
|
-
Given("I open {string} page", { tags: "@ui" }, async ({ ui, world }, urlOrVar) => {
|
|
342
|
+
Given("I open {string} page", { tags: "@ui or @hybrid" }, async ({ ui, world }, urlOrVar) => {
|
|
343
343
|
await ui.goto(resolveValue(urlOrVar, world));
|
|
344
344
|
});
|
|
345
|
-
Given("I open {string} in the browser", { tags: "@ui" }, async ({ ui, world }, urlOrVar) => {
|
|
345
|
+
Given("I open {string} in the browser", { tags: "@ui or @hybrid" }, async ({ ui, world }, urlOrVar) => {
|
|
346
346
|
await ui.goto(resolveValue(urlOrVar, world));
|
|
347
347
|
});
|
|
348
|
-
When("I go back in the browser", { tags: "@ui" }, async ({ ui }) => {
|
|
348
|
+
When("I go back in the browser", { tags: "@ui or @hybrid" }, async ({ ui }) => {
|
|
349
349
|
await ui.goBack();
|
|
350
350
|
});
|
|
351
|
-
When("I save the current URL as {string}", { tags: "@ui" }, async ({ ui, world }, varName) => {
|
|
351
|
+
When("I save the current URL as {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, varName) => {
|
|
352
352
|
world.vars[varName] = await ui.getCurrentUrl();
|
|
353
353
|
});
|
|
354
|
-
When("I save the current url as {string}", { tags: "@ui" }, async ({ ui, world }, varName) => {
|
|
354
|
+
When("I save the current url as {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, varName) => {
|
|
355
355
|
world.vars[varName] = await ui.getCurrentUrl();
|
|
356
356
|
});
|
|
357
|
-
Then("I zoom to {string} in the browser", { tags: "@ui" }, async ({ ui, world }, scale) => {
|
|
357
|
+
Then("I zoom to {string} in the browser", { tags: "@ui or @hybrid" }, async ({ ui, world }, scale) => {
|
|
358
358
|
await ui.zoomTo(parseNumber(scale, world));
|
|
359
359
|
});
|
|
360
|
-
When("I reload the page", { tags: "@ui" }, async ({ ui }) => {
|
|
360
|
+
When("I reload the page", { tags: "@ui or @hybrid" }, async ({ ui }) => {
|
|
361
361
|
await ui.reload();
|
|
362
362
|
});
|
|
363
|
-
Then("I wait {string} seconds", { tags: "@ui" }, async ({ ui, world }, seconds) => {
|
|
363
|
+
Then("I wait {string} seconds", { tags: "@ui or @hybrid" }, async ({ ui, world }, seconds) => {
|
|
364
364
|
await ui.waitSeconds(parseNumber(seconds, world));
|
|
365
365
|
});
|
|
366
|
-
Then("I wait for the page to load", { tags: "@ui" }, async ({ ui }) => {
|
|
366
|
+
Then("I wait for the page to load", { tags: "@ui or @hybrid" }, async ({ ui }) => {
|
|
367
367
|
await ui.waitForPageLoad();
|
|
368
368
|
});
|
|
369
369
|
When(
|
|
370
370
|
"I get a part of the URL based on {string} regular expression and save it as {string}",
|
|
371
|
-
{ tags: "@ui" },
|
|
371
|
+
{ tags: "@ui or @hybrid" },
|
|
372
372
|
async ({ ui, world }, regexString, varName) => {
|
|
373
373
|
const url = await ui.getCurrentUrl();
|
|
374
374
|
const regex = parseRegex(resolveValue(regexString, world));
|
|
@@ -377,7 +377,7 @@ function registerWizardSteps(test) {
|
|
|
377
377
|
world.vars[varName] = match[1] ?? match[0];
|
|
378
378
|
}
|
|
379
379
|
);
|
|
380
|
-
Then("I {string} {string}", { tags: "@ui" }, async ({ ui, world }, action, value) => {
|
|
380
|
+
Then("I {string} {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, action, value) => {
|
|
381
381
|
const verb = action.trim().toLowerCase();
|
|
382
382
|
const resolved = resolveValue(value, world);
|
|
383
383
|
if (verb === "type") {
|
|
@@ -392,7 +392,7 @@ function registerWizardSteps(test) {
|
|
|
392
392
|
});
|
|
393
393
|
When(
|
|
394
394
|
"I {string} the {string} element that contains {string}",
|
|
395
|
-
{ tags: "@ui" },
|
|
395
|
+
{ tags: "@ui or @hybrid" },
|
|
396
396
|
async ({ ui, world }, clickMode, elementType, text) => {
|
|
397
397
|
await ui.clickElementThatContains(
|
|
398
398
|
asClickMode(resolveValue(clickMode, world)),
|
|
@@ -403,7 +403,7 @@ function registerWizardSteps(test) {
|
|
|
403
403
|
);
|
|
404
404
|
When(
|
|
405
405
|
"I {string} the {string} element with {string} {string}",
|
|
406
|
-
{ tags: "@ui" },
|
|
406
|
+
{ tags: "@ui or @hybrid" },
|
|
407
407
|
async ({ ui, world }, clickMode, ordinal, text, method) => {
|
|
408
408
|
await ui.clickElementWith(
|
|
409
409
|
asClickMode(resolveValue(clickMode, world)),
|
|
@@ -413,12 +413,12 @@ function registerWizardSteps(test) {
|
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
415
|
);
|
|
416
|
-
When("I click on the top left corner of the page", { tags: "@ui" }, async ({ page }) => {
|
|
416
|
+
When("I click on the top left corner of the page", { tags: "@ui or @hybrid" }, async ({ page }) => {
|
|
417
417
|
await page.mouse.click(0, 0);
|
|
418
418
|
});
|
|
419
419
|
When(
|
|
420
420
|
"If its visible, I {string} the {string} element with {string} {string}",
|
|
421
|
-
{ tags: "@ui" },
|
|
421
|
+
{ tags: "@ui or @hybrid" },
|
|
422
422
|
async ({ page, ui, world }, clickMode, ordinal, text, method) => {
|
|
423
423
|
const idx = parseOrdinalIndex(ordinal, world);
|
|
424
424
|
const resolvedText = resolveValue(text, world);
|
|
@@ -429,12 +429,12 @@ function registerWizardSteps(test) {
|
|
|
429
429
|
await ui.clickElementWith(asClickMode(resolveValue(clickMode, world)), ordinal, resolvedText, resolvedMethod);
|
|
430
430
|
}
|
|
431
431
|
);
|
|
432
|
-
Then("I fill {string} into the {string} dropdown", { tags: "@ui" }, async ({ ui, world }, value, label) => {
|
|
432
|
+
Then("I fill {string} into the {string} dropdown", { tags: "@ui or @hybrid" }, async ({ ui, world }, value, label) => {
|
|
433
433
|
await ui.fillDropdown(resolveValue(value, world), resolveValue(label, world));
|
|
434
434
|
});
|
|
435
435
|
When(
|
|
436
436
|
"I {string} {string} in the {string} element with {string} {string}",
|
|
437
|
-
{ tags: "@ui" },
|
|
437
|
+
{ tags: "@ui or @hybrid" },
|
|
438
438
|
async ({ ui, world }, action, value, ordinal, text, method) => {
|
|
439
439
|
await ui.inputInElement(
|
|
440
440
|
asInputMode(resolveValue(action, world)),
|
|
@@ -447,33 +447,33 @@ function registerWizardSteps(test) {
|
|
|
447
447
|
);
|
|
448
448
|
Then(
|
|
449
449
|
"I verify if a new tab which URL {string} {string} opens",
|
|
450
|
-
{ tags: "@ui" },
|
|
450
|
+
{ tags: "@ui or @hybrid" },
|
|
451
451
|
async ({ ui, world }, mode, expected) => {
|
|
452
452
|
await ui.expectNewTabUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
453
453
|
}
|
|
454
454
|
);
|
|
455
455
|
Then(
|
|
456
456
|
"I verify if a new tab which url {string} {string} opens",
|
|
457
|
-
{ tags: "@ui" },
|
|
457
|
+
{ tags: "@ui or @hybrid" },
|
|
458
458
|
async ({ ui, world }, mode, expected) => {
|
|
459
459
|
await ui.expectNewTabUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
460
460
|
}
|
|
461
461
|
);
|
|
462
|
-
Then("I verify if the URL {string} {string}", { tags: "@ui" }, async ({ ui, world }, mode, expected) => {
|
|
462
|
+
Then("I verify if the URL {string} {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, mode, expected) => {
|
|
463
463
|
await ui.expectUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
464
464
|
});
|
|
465
|
-
Then("I verify if the url {string} {string}", { tags: "@ui" }, async ({ ui, world }, mode, expected) => {
|
|
465
|
+
Then("I verify if the url {string} {string}", { tags: "@ui or @hybrid" }, async ({ ui, world }, mode, expected) => {
|
|
466
466
|
await ui.expectUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
467
467
|
});
|
|
468
|
-
Then("I verify if the URL {string} {string} opens", { tags: "@ui" }, async ({ ui, world }, mode, expected) => {
|
|
468
|
+
Then("I verify if the URL {string} {string} opens", { tags: "@ui or @hybrid" }, async ({ ui, world }, mode, expected) => {
|
|
469
469
|
await ui.expectUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
470
470
|
});
|
|
471
|
-
Then("I verify if the url {string} {string} opens", { tags: "@ui" }, async ({ ui, world }, mode, expected) => {
|
|
471
|
+
Then("I verify if the url {string} {string} opens", { tags: "@ui or @hybrid" }, async ({ ui, world }, mode, expected) => {
|
|
472
472
|
await ui.expectUrl(asUrlAssertMode(resolveValue(mode, world)), resolveValue(expected, world));
|
|
473
473
|
});
|
|
474
474
|
Then(
|
|
475
475
|
"I verify that a {string} element with {string} text {string} visible",
|
|
476
|
-
{ tags: "@ui" },
|
|
476
|
+
{ tags: "@ui or @hybrid" },
|
|
477
477
|
async ({ ui, world }, elementType, text, assertion) => {
|
|
478
478
|
const normalized = resolveValue(assertion, world).trim().toLowerCase();
|
|
479
479
|
const shouldBeVisible = normalized === "is";
|
|
@@ -485,7 +485,7 @@ function registerWizardSteps(test) {
|
|
|
485
485
|
);
|
|
486
486
|
Then(
|
|
487
487
|
"I verify that {string} element with {string} {string} is {string}",
|
|
488
|
-
{ tags: "@ui" },
|
|
488
|
+
{ tags: "@ui or @hybrid" },
|
|
489
489
|
async ({ ui, world }, ordinal, text, method, state) => {
|
|
490
490
|
await ui.expectElementState(
|
|
491
491
|
resolveValue(ordinal, world),
|
|
@@ -497,7 +497,7 @@ function registerWizardSteps(test) {
|
|
|
497
497
|
);
|
|
498
498
|
Then(
|
|
499
499
|
"I verify that {string} element with {string} {string} becomes {string} during {string} seconds",
|
|
500
|
-
{ tags: "@ui" },
|
|
500
|
+
{ tags: "@ui or @hybrid" },
|
|
501
501
|
async ({ ui, world }, ordinal, text, method, state, seconds) => {
|
|
502
502
|
await ui.expectElementStateWithin(
|
|
503
503
|
resolveValue(ordinal, world),
|
package/dist/index.js
CHANGED
package/dist/steps/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esimplicity/stack-tests",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,10 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@playwright/test": "^1.49.0",
|
|
60
59
|
"@types/node": "^22.10.0",
|
|
61
|
-
"
|
|
62
|
-
"tsup": "^8.3.0",
|
|
63
|
-
"typescript": "^5.6.3"
|
|
60
|
+
"tsup": "^8.3.0"
|
|
64
61
|
}
|
|
65
62
|
}
|