playwright-cucumber-ts-steps 0.0.9 โ†’ 0.1.1

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 (39) hide show
  1. package/dist/actions/clickSteps.js +54 -69
  2. package/dist/actions/cookieSteps.js +7 -5
  3. package/dist/actions/debugSteps.js +5 -3
  4. package/dist/actions/elementFindSteps.js +75 -94
  5. package/dist/actions/inputSteps.js +65 -67
  6. package/dist/actions/interceptionSteps.js +9 -7
  7. package/dist/actions/miscSteps.js +52 -57
  8. package/dist/actions/mouseSteps.js +13 -14
  9. package/dist/actions/scrollSteps.js +7 -5
  10. package/dist/actions/storageSteps.js +11 -10
  11. package/dist/assertions/buttonAndTextVisibilitySteps.js +29 -31
  12. package/dist/assertions/cookieSteps.js +7 -5
  13. package/dist/assertions/elementSteps.js +27 -27
  14. package/dist/assertions/formInputSteps.js +28 -26
  15. package/dist/assertions/interceptionRequestsSteps.js +39 -29
  16. package/dist/assertions/locationSteps.js +17 -15
  17. package/dist/assertions/roleTestIdSteps.js +12 -10
  18. package/dist/assertions/semanticSteps.js +9 -7
  19. package/dist/assertions/storageSteps.js +25 -21
  20. package/dist/assertions/visualSteps.js +46 -44
  21. package/dist/custom_setups/globalLogin.js +10 -5
  22. package/dist/custom_setups/loginHooks.js +34 -32
  23. package/dist/helpers/compareSnapshots.js +15 -9
  24. package/dist/helpers/hooks.js +78 -42
  25. package/dist/helpers/utils/fakerUtils.js +32 -26
  26. package/dist/helpers/utils/index.js +19 -3
  27. package/dist/helpers/utils/optionsUtils.js +18 -8
  28. package/dist/helpers/utils/resolveUtils.js +19 -11
  29. package/dist/helpers/world.js +52 -17
  30. package/dist/iframes/frames.js +4 -2
  31. package/dist/index.js +43 -27
  32. package/dist/register.js +3 -1
  33. package/package.json +18 -2
  34. package/dist/assertions/InterceptionRequests.d.ts +0 -1
  35. package/dist/assertions/InterceptionRequests.js +0 -191
  36. package/dist/assertions/button_and_text_visibility.d.ts +0 -1
  37. package/dist/assertions/button_and_text_visibility.js +0 -172
  38. package/dist/custom_setups/global-login.d.ts +0 -2
  39. package/dist/custom_setups/global-login.js +0 -20
@@ -1,18 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  // e2e/step_definitions/common/actions/storageSteps.ts
2
- import { When } from "@cucumber/cucumber";
3
- When("I clear all local storage", async function () {
4
+ const cucumber_1 = require("@cucumber/cucumber");
5
+ (0, cucumber_1.When)("I clear all local storage", async function () {
4
6
  await this.page.evaluate(() => localStorage.clear());
5
7
  this.log("Cleared all local storage");
6
8
  });
7
- When("I clear local storage", async function () {
9
+ (0, cucumber_1.When)("I clear local storage", async function () {
8
10
  await this.page.evaluate(() => localStorage.clear());
9
11
  this.log("Cleared local storage (alias)");
10
12
  });
11
- When("I clear session storage", async function () {
13
+ (0, cucumber_1.When)("I clear session storage", async function () {
12
14
  await this.page.evaluate(() => sessionStorage.clear());
13
15
  this.log("Cleared session storage");
14
16
  });
15
- When("I clear all browser storage", async function () {
17
+ (0, cucumber_1.When)("I clear all browser storage", async function () {
16
18
  const { context, page } = this;
17
19
  // Clear cookies
18
20
  await context.clearCookies();
@@ -27,17 +29,16 @@ When("I clear all browser storage", async function () {
27
29
  });
28
30
  this.log("โœ… Cleared all cookies and storage");
29
31
  });
30
- When("I set local storage item {string} to {string}", async function (key, value) {
32
+ (0, cucumber_1.When)("I set local storage item {string} to {string}", async function (key, value) {
31
33
  await this.page.evaluate(([k, v]) => localStorage.setItem(k, v), [key, value]);
32
34
  });
33
35
  // When("I clear session storage", async function (this: CustomWorld) {
34
36
  // await this.page.evaluate(() => sessionStorage.clear());
35
37
  // });
36
- When("I clear local storage", async function () {
38
+ (0, cucumber_1.When)("I clear local storage", async function () {
37
39
  await this.page.evaluate(() => localStorage.clear());
38
40
  });
39
- When("I store input text as {string}", async function (alias) {
40
- var _a;
41
+ (0, cucumber_1.When)("I store input text as {string}", async function (alias) {
41
42
  const activeElementHandle = await this.page.evaluateHandle(() => document.activeElement);
42
43
  const tagName = await activeElementHandle.evaluate((el) => el ? el.tagName.toLowerCase() : "");
43
44
  if (tagName !== "input" && tagName !== "textarea") {
@@ -45,5 +46,5 @@ When("I store input text as {string}", async function (alias) {
45
46
  }
46
47
  const value = await activeElementHandle.evaluate((el) => el.value);
47
48
  this.data[alias] = value;
48
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `๐Ÿ“ฅ Stored value from input as "${alias}": ${value}`);
49
+ this.log?.(`๐Ÿ“ฅ Stored value from input as "${alias}": ${value}`);
49
50
  });
@@ -1,17 +1,19 @@
1
- import { Then } from "@cucumber/cucumber";
2
- import { expect } from "@playwright/test";
3
- import { evaluateFaker } from "../helpers/utils/fakerUtils";
4
- Then("I count {int} elements", async function (expectedCount) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const test_1 = require("@playwright/test");
5
+ const fakerUtils_1 = require("../helpers/utils/fakerUtils");
6
+ (0, cucumber_1.Then)("I count {int} elements", async function (expectedCount) {
5
7
  if (!this.elements)
6
8
  throw new Error("No elements found to count");
7
9
  const count = await this.elements.count();
8
10
  await this.page.waitForLoadState("networkidle");
9
- expect(count).toBe(expectedCount);
11
+ (0, test_1.expect)(count).toBe(expectedCount);
10
12
  });
11
13
  /**
12
14
  * THEN: I see button "Submit"
13
15
  */
14
- Then(/^I see button "(.*)"$/, async function (rawText) {
16
+ (0, cucumber_1.Then)(/^I see button "(.*)"$/, async function (rawText) {
15
17
  let buttonText = rawText.startsWith("@")
16
18
  ? this.data[rawText.slice(1)]
17
19
  : rawText;
@@ -23,12 +25,12 @@ Then(/^I see button "(.*)"$/, async function (rawText) {
23
25
  exact: false,
24
26
  });
25
27
  await this.page.waitForLoadState("networkidle");
26
- await expect(button).toBeVisible();
28
+ await (0, test_1.expect)(button).toBeVisible();
27
29
  });
28
30
  /**
29
31
  * THEN: I do not see button "Cancel"
30
32
  */
31
- Then(/^I do not see button "(.*)"$/, async function (rawText) {
33
+ (0, cucumber_1.Then)(/^I do not see button "(.*)"$/, async function (rawText) {
32
34
  let buttonText = rawText.startsWith("@")
33
35
  ? this.data[rawText.slice(1)]
34
36
  : rawText;
@@ -51,17 +53,16 @@ Then(/^I do not see button "(.*)"$/, async function (rawText) {
51
53
  /**
52
54
  * THEN: I see text "Welcome"
53
55
  */
54
- Then("I see text {string}", async function (expected) {
55
- var _a;
56
+ (0, cucumber_1.Then)("I see text {string}", async function (expected) {
56
57
  const scope = this.getScope(); // โœ… Supports iframe OR main page
57
58
  const locator = scope.locator(`text=${expected}`);
58
59
  await locator.waitFor({ state: "visible", timeout: 5000 });
59
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `โœ… Verified text visible: ${expected}`);
60
+ this.log?.(`โœ… Verified text visible: ${expected}`);
60
61
  });
61
62
  /**
62
63
  * THEN: I do not see text "Error"
63
64
  */
64
- Then("I do not see text {string}", async function (text) {
65
+ (0, cucumber_1.Then)("I do not see text {string}", async function (text) {
65
66
  await this.page.waitForLoadState("networkidle");
66
67
  const locator = this.page.locator(`:has-text("${text}")`);
67
68
  const count = await locator.count();
@@ -75,7 +76,7 @@ Then("I do not see text {string}", async function (text) {
75
76
  /**
76
77
  * THEN: I see visible text "Dashboard"
77
78
  */
78
- Then("I see visible text {string}", async function (text) {
79
+ (0, cucumber_1.Then)("I see visible text {string}", async function (text) {
79
80
  await this.page.waitForLoadState("networkidle");
80
81
  const locator = this.page.locator(`:text-is("${text}")`);
81
82
  if (!(await locator.first().isVisible())) {
@@ -85,13 +86,13 @@ Then("I see visible text {string}", async function (text) {
85
86
  /**
86
87
  * THEN: I do not see visible text "Logout"
87
88
  */
88
- Then("I do not see visible text {string}", async function (text) {
89
+ (0, cucumber_1.Then)("I do not see visible text {string}", async function (text) {
89
90
  const locator = this.page.locator(`:text-is("${text}")`);
90
91
  if ((await locator.count()) > 0 && (await locator.first().isVisible())) {
91
92
  throw new Error(`Visible text "${text}" should not be visible`);
92
93
  }
93
94
  });
94
- Then("I see value {string}", async function (expected) {
95
+ (0, cucumber_1.Then)("I see value {string}", async function (expected) {
95
96
  if (!this.element)
96
97
  throw new Error("No element selected");
97
98
  const value = await this.element.inputValue();
@@ -99,7 +100,7 @@ Then("I see value {string}", async function (expected) {
99
100
  throw new Error(`Expected value "${expected}", but got "${value}"`);
100
101
  }
101
102
  });
102
- Then("I do not see value {string}", async function (unwanted) {
103
+ (0, cucumber_1.Then)("I do not see value {string}", async function (unwanted) {
103
104
  if (!this.element)
104
105
  throw new Error("No element selected");
105
106
  const value = await this.element.inputValue();
@@ -110,15 +111,14 @@ Then("I do not see value {string}", async function (unwanted) {
110
111
  //
111
112
  // ๐Ÿ“ƒ VISIBLE TEXT ASSERTIONS
112
113
  //
113
- Then(/^I do not see text "(.*)"$/, async function (unexpectedText) {
114
+ (0, cucumber_1.Then)(/^I do not see text "(.*)"$/, async function (unexpectedText) {
114
115
  const el = this.page.getByText(unexpectedText, { exact: true });
115
- await expect(el).toHaveCount(0);
116
+ await (0, test_1.expect)(el).toHaveCount(0);
116
117
  });
117
118
  //
118
119
  // ๐Ÿ†• Visible Text - Alias for clarity (optional if you want separate steps for naming)
119
120
  //
120
- Then("I see {string} in the element", async function (expected) {
121
- var _a;
121
+ (0, cucumber_1.Then)("I see {string} in the element", async function (expected) {
122
122
  const element = this.element;
123
123
  if (!element)
124
124
  throw new Error("No element selected");
@@ -130,15 +130,14 @@ Then("I see {string} in the element", async function (expected) {
130
130
  throw new Error(`No data stored for alias "@${alias}"`);
131
131
  }
132
132
  // โœ… Resolve faker syntax
133
- expected = evaluateFaker(expected);
133
+ expected = (0, fakerUtils_1.evaluateFaker)(expected);
134
134
  const textContent = await element.textContent();
135
135
  if (!textContent)
136
136
  throw new Error("Element has no text content");
137
- expect(textContent).toContain(expected);
138
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `Verified "${expected}" in element text`);
137
+ (0, test_1.expect)(textContent).toContain(expected);
138
+ this.log?.(`Verified "${expected}" in element text`);
139
139
  });
140
- Then("I see @{word} in the element", async function (alias) {
141
- var _a;
140
+ (0, cucumber_1.Then)("I see @{word} in the element", async function (alias) {
142
141
  const storedValue = this.data[alias];
143
142
  if (!storedValue) {
144
143
  throw new Error(`No value found in data storage under alias "@${alias}".`);
@@ -146,12 +145,11 @@ Then("I see @{word} in the element", async function (alias) {
146
145
  if (!this.element) {
147
146
  throw new Error("No element found. You must get an element before asserting its contents.");
148
147
  }
149
- const actualText = ((_a = (await this.element.textContent())) === null || _a === void 0 ? void 0 : _a.trim()) || "";
150
- expect(actualText).toContain(storedValue);
148
+ const actualText = (await this.element.textContent())?.trim() || "";
149
+ (0, test_1.expect)(actualText).toContain(storedValue);
151
150
  this.log(`Verified element contains value from "@${alias}" = "${storedValue}". Actual: "${actualText}"`);
152
151
  });
153
- Then("I see button {string} is disabled", async function (rawText) {
154
- var _a;
152
+ (0, cucumber_1.Then)("I see button {string} is disabled", async function (rawText) {
155
153
  // Resolve alias
156
154
  let buttonText = rawText.startsWith("@")
157
155
  ? this.data[rawText.slice(1)]
@@ -163,10 +161,10 @@ Then("I see button {string} is disabled", async function (rawText) {
163
161
  name: buttonText,
164
162
  exact: false,
165
163
  });
166
- await expect(button).toBeVisible({ timeout: 5000 });
164
+ await (0, test_1.expect)(button).toBeVisible({ timeout: 5000 });
167
165
  const isDisabled = await button.isDisabled();
168
166
  if (!isDisabled) {
169
167
  throw new Error(`๐Ÿšซ Button "${buttonText}" is not disabled as expected.`);
170
168
  }
171
- (_a = this.log) === null || _a === void 0 ? void 0 : _a.call(this, `โœ… Verified button "${buttonText}" is disabled.`);
169
+ this.log?.(`โœ… Verified button "${buttonText}" is disabled.`);
172
170
  });
@@ -1,8 +1,10 @@
1
- import { Then } from "@cucumber/cucumber";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
2
4
  /**
3
5
  * THEN: I see cookie "myCookie"
4
6
  */
5
- Then("I see cookie {string}", async function (cookieName) {
7
+ (0, cucumber_1.Then)("I see cookie {string}", async function (cookieName) {
6
8
  const cookies = await this.context.cookies();
7
9
  const cookie = cookies.find((c) => c.name === cookieName);
8
10
  if (!cookie)
@@ -11,7 +13,7 @@ Then("I see cookie {string}", async function (cookieName) {
11
13
  /**
12
14
  * THEN: I do not see cookie "myCookie"
13
15
  */
14
- Then("I do not see cookie {string}", async function (name) {
16
+ (0, cucumber_1.Then)("I do not see cookie {string}", async function (name) {
15
17
  const cookies = await this.context.cookies();
16
18
  const cookie = cookies.find((c) => c.name === name);
17
19
  if (cookie)
@@ -20,7 +22,7 @@ Then("I do not see cookie {string}", async function (name) {
20
22
  /**
21
23
  * THEN: I see cookie "sessionId" has value "abc123"
22
24
  */
23
- Then("I see cookie {string} has value {string}", async function (name, expectedValue) {
25
+ (0, cucumber_1.Then)("I see cookie {string} has value {string}", async function (name, expectedValue) {
24
26
  const cookies = await this.context.cookies();
25
27
  const cookie = cookies.find((c) => c.name === name);
26
28
  if (!cookie)
@@ -32,7 +34,7 @@ Then("I see cookie {string} has value {string}", async function (name, expectedV
32
34
  /**
33
35
  * THEN: I see cookie "token" contains value "auth"
34
36
  */
35
- Then("I see cookie {string} contains value {string}", async function (name, valuePart) {
37
+ (0, cucumber_1.Then)("I see cookie {string} contains value {string}", async function (name, valuePart) {
36
38
  const cookies = await this.context.cookies();
37
39
  const cookie = cookies.find((c) => c.name === name);
38
40
  if (!cookie)
@@ -1,84 +1,84 @@
1
- import { Then } from "@cucumber/cucumber";
2
- import { expect } from "@playwright/test";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const test_1 = require("@playwright/test");
3
5
  //
4
6
  // โœ… ELEMENT EXISTS
5
7
  //
6
- Then(/^I see element "([^"]+)" exists$/, async function (selector) {
8
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" exists$/, async function (selector) {
7
9
  const el = await this.page.locator(selector);
8
- await expect(el).toHaveCount(1);
10
+ await (0, test_1.expect)(el).toHaveCount(1);
9
11
  });
10
- Then("I see element exists", async function () {
11
- var _a, _b, _c;
12
+ (0, cucumber_1.Then)("I see element exists", async function () {
12
13
  if (!this.element)
13
14
  throw new Error("No element stored in context");
14
- const count = (_c = (await ((_b = (_a = this.element).count) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : 1;
15
+ const count = (await this.element.count?.()) ?? 1;
15
16
  if (count === 0)
16
17
  throw new Error("Element does not exist");
17
18
  });
18
- Then("I see element does not exist", async function () {
19
- var _a, _b, _c;
19
+ (0, cucumber_1.Then)("I see element does not exist", async function () {
20
20
  if (!this.element)
21
21
  throw new Error("No element stored in context");
22
- const count = (_c = (await ((_b = (_a = this.element).count) === null || _b === void 0 ? void 0 : _b.call(_a)))) !== null && _c !== void 0 ? _c : 1;
22
+ const count = (await this.element.count?.()) ?? 1;
23
23
  if (count > 0)
24
24
  throw new Error("Element exists but should not");
25
25
  });
26
- Then("I see element is visible", async function () {
26
+ (0, cucumber_1.Then)("I see element is visible", async function () {
27
27
  if (!this.element)
28
28
  throw new Error("No element in context");
29
29
  const isVisible = await this.element.isVisible();
30
30
  if (!isVisible)
31
31
  throw new Error("Element is not visible");
32
32
  });
33
- Then("I see element is not visible", async function () {
33
+ (0, cucumber_1.Then)("I see element is not visible", async function () {
34
34
  if (!this.element)
35
35
  throw new Error("No element in context");
36
36
  const isVisible = await this.element.isVisible();
37
37
  if (isVisible)
38
38
  throw new Error("Element is visible but should not be");
39
39
  });
40
- Then(/^I see element "([^"]+)" does not exist$/, async function (selector) {
40
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" does not exist$/, async function (selector) {
41
41
  const el = await this.page.locator(selector);
42
- await expect(el).toHaveCount(0);
42
+ await (0, test_1.expect)(el).toHaveCount(0);
43
43
  });
44
44
  //
45
45
  // ๐Ÿ‘๏ธ ELEMENT VISIBILITY
46
46
  //
47
- Then(/^I see element "([^"]+)" is visible$/, async function (selector) {
47
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" is visible$/, async function (selector) {
48
48
  const el = this.page.locator(selector);
49
- await expect(el).toBeVisible();
49
+ await (0, test_1.expect)(el).toBeVisible();
50
50
  });
51
- Then(/^I see element "([^"]+)" is not visible$/, async function (selector) {
51
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" is not visible$/, async function (selector) {
52
52
  const el = this.page.locator(selector);
53
- await expect(el).not.toBeVisible();
53
+ await (0, test_1.expect)(el).not.toBeVisible();
54
54
  });
55
55
  //
56
56
  // ๐Ÿ”Ž ATTRIBUTE ASSERTIONS
57
57
  //
58
- Then(/^I see element "([^"]+)" attribute "([^"]+)" equals "(.*)"$/, async function (selector, attribute, expected) {
58
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" equals "(.*)"$/, async function (selector, attribute, expected) {
59
59
  const el = this.page.locator(selector);
60
- await expect(el).toHaveAttribute(attribute, expected);
60
+ await (0, test_1.expect)(el).toHaveAttribute(attribute, expected);
61
61
  });
62
- Then("I see element has attribute {string}", async function (attr) {
62
+ (0, cucumber_1.Then)("I see element has attribute {string}", async function (attr) {
63
63
  if (!this.element)
64
64
  throw new Error("No element in context");
65
65
  const value = await this.element.getAttribute(attr);
66
66
  if (value === null)
67
67
  throw new Error(`Attribute "${attr}" not found`);
68
68
  });
69
- Then("I see element attribute {string} contains {string}", async function (attr, part) {
69
+ (0, cucumber_1.Then)("I see element attribute {string} contains {string}", async function (attr, part) {
70
70
  if (!this.element)
71
71
  throw new Error("No element in context");
72
72
  const value = await this.element.getAttribute(attr);
73
- if (!(value === null || value === void 0 ? void 0 : value.includes(part))) {
73
+ if (!value?.includes(part)) {
74
74
  throw new Error(`Attribute "${attr}" does not contain "${part}". Got: "${value}"`);
75
75
  }
76
76
  });
77
- Then(/^I see element "([^"]+)" attribute "([^"]+)" contains "(.*)"$/, async function (selector, attribute, substring) {
77
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" attribute "([^"]+)" contains "(.*)"$/, async function (selector, attribute, substring) {
78
78
  const attr = await this.page.locator(selector).getAttribute(attribute);
79
- expect(attr === null || attr === void 0 ? void 0 : attr.includes(substring)).toBeTruthy();
79
+ (0, test_1.expect)(attr?.includes(substring)).toBeTruthy();
80
80
  });
81
- Then(/^I see element "([^"]+)" has attribute "([^"]+)"$/, async function (selector, attribute) {
81
+ (0, cucumber_1.Then)(/^I see element "([^"]+)" has attribute "([^"]+)"$/, async function (selector, attribute) {
82
82
  const attr = await this.page.locator(selector).getAttribute(attribute);
83
- expect(attr).not.toBeNull();
83
+ (0, test_1.expect)(attr).not.toBeNull();
84
84
  });
@@ -1,43 +1,45 @@
1
- import { Then } from "@cucumber/cucumber";
2
- import { expect } from "@playwright/test";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cucumber_1 = require("@cucumber/cucumber");
4
+ const test_1 = require("@playwright/test");
3
5
  //
4
6
  // ๐Ÿงพ INPUT VALUES
5
7
  //
6
- Then(/^I see input "([^"]+)" has value "(.*)"$/, async function (selector, value) {
8
+ (0, cucumber_1.Then)(/^I see input "([^"]+)" has value "(.*)"$/, async function (selector, value) {
7
9
  const el = this.page.locator(selector);
8
- await expect(el).toHaveValue(value);
10
+ await (0, test_1.expect)(el).toHaveValue(value);
9
11
  });
10
- Then("I see input value {string}", async function (expected) {
12
+ (0, cucumber_1.Then)("I see input value {string}", async function (expected) {
11
13
  if (!this.element)
12
14
  throw new Error("No element stored in context");
13
15
  const value = await this.element.inputValue();
14
- expect(value).toBe(expected);
16
+ (0, test_1.expect)(value).toBe(expected);
15
17
  });
16
- Then("I see input value contains {string}", async function (part) {
18
+ (0, cucumber_1.Then)("I see input value contains {string}", async function (part) {
17
19
  if (!this.element)
18
20
  throw new Error("No element stored in context");
19
21
  const value = await this.element.inputValue();
20
- expect(value).toContain(part);
22
+ (0, test_1.expect)(value).toContain(part);
21
23
  });
22
- Then(/^I see input "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
24
+ (0, cucumber_1.Then)(/^I see input "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
23
25
  const val = await this.page.locator(selector).inputValue();
24
- expect(val).toContain(partial);
26
+ (0, test_1.expect)(val).toContain(partial);
25
27
  });
26
28
  //
27
29
  // ๐Ÿ“ TEXTAREA VALUES
28
30
  //
29
- Then(/^I see textarea "([^"]+)" has value "(.*)"$/, async function (selector, value) {
31
+ (0, cucumber_1.Then)(/^I see textarea "([^"]+)" has value "(.*)"$/, async function (selector, value) {
30
32
  const el = this.page.locator(selector);
31
- await expect(el).toHaveValue(value);
33
+ await (0, test_1.expect)(el).toHaveValue(value);
32
34
  });
33
- Then("I see textarea value {string}", async function (expected) {
35
+ (0, cucumber_1.Then)("I see textarea value {string}", async function (expected) {
34
36
  if (!this.element)
35
37
  throw new Error("No textarea selected");
36
38
  const value = await this.element.inputValue();
37
39
  if (value !== expected)
38
40
  throw new Error(`Expected "${expected}", got "${value}"`);
39
41
  });
40
- Then("I see textarea value contains {string}", async function (part) {
42
+ (0, cucumber_1.Then)("I see textarea value contains {string}", async function (part) {
41
43
  if (!this.element)
42
44
  throw new Error("No textarea selected");
43
45
  const value = await this.element.inputValue();
@@ -45,41 +47,41 @@ Then("I see textarea value contains {string}", async function (part) {
45
47
  throw new Error(`Textarea does not contain "${part}". Got: "${value}"`);
46
48
  }
47
49
  });
48
- Then(/^I see textarea "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
50
+ (0, cucumber_1.Then)(/^I see textarea "([^"]+)" value contains "(.*)"$/, async function (selector, partial) {
49
51
  const val = await this.page.locator(selector).inputValue();
50
- expect(val).toContain(partial);
52
+ (0, test_1.expect)(val).toContain(partial);
51
53
  });
52
54
  //
53
55
  // โœ… GENERIC VALUE MATCHING
54
56
  //
55
- Then(/^I see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
57
+ (0, cucumber_1.Then)(/^I see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
56
58
  const el = this.page.locator(selector);
57
- await expect(el).toHaveValue(value);
59
+ await (0, test_1.expect)(el).toHaveValue(value);
58
60
  });
59
- Then(/^I do not see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
61
+ (0, cucumber_1.Then)(/^I do not see value "(.*)" in "([^"]+)"$/, async function (value, selector) {
60
62
  const actual = await this.page.locator(selector).inputValue();
61
- expect(actual).not.toBe(value);
63
+ (0, test_1.expect)(actual).not.toBe(value);
62
64
  });
63
65
  //
64
66
  // โฌ‡๏ธ OPTION IN SELECT
65
67
  //
66
- Then(/^I see option "(.*)"$/, async function (optionText) {
68
+ (0, cucumber_1.Then)(/^I see option "(.*)"$/, async function (optionText) {
67
69
  const el = this.page.locator(`option`, { hasText: optionText });
68
- await expect(el).toHaveCount(1);
70
+ await (0, test_1.expect)(el).toHaveCount(1);
69
71
  });
70
- Then("I see option {string}", async function (optionText) {
72
+ (0, cucumber_1.Then)("I see option {string}", async function (optionText) {
71
73
  const option = this.page.locator("option", { hasText: optionText });
72
74
  if (!(await option.isVisible())) {
73
75
  throw new Error(`Option "${optionText}" not visible`);
74
76
  }
75
77
  });
76
- Then("I do not see option {string}", async function (optionText) {
78
+ (0, cucumber_1.Then)("I do not see option {string}", async function (optionText) {
77
79
  const option = this.page.locator("option", { hasText: optionText });
78
80
  if ((await option.count()) > 0 && (await option.first().isVisible())) {
79
81
  throw new Error(`Option "${optionText}" is visible but should not be`);
80
82
  }
81
83
  });
82
- Then(/^I do not see option "(.*)"$/, async function (optionText) {
84
+ (0, cucumber_1.Then)(/^I do not see option "(.*)"$/, async function (optionText) {
83
85
  const el = this.page.locator(`option`, { hasText: optionText });
84
- await expect(el).toHaveCount(0);
86
+ await (0, test_1.expect)(el).toHaveCount(0);
85
87
  });