playwright-cucumber-ts-steps 1.1.7 → 1.1.9

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/dist/backend/actions/click.d.ts +133 -0
  3. package/dist/backend/actions/click.d.ts.map +1 -0
  4. package/dist/backend/actions/click.js +248 -0
  5. package/dist/backend/actions/find.d.ts +244 -0
  6. package/dist/backend/actions/find.d.ts.map +1 -0
  7. package/dist/backend/actions/find.js +415 -0
  8. package/dist/backend/actions/form.d.ts +38 -0
  9. package/dist/backend/actions/form.d.ts.map +1 -0
  10. package/dist/backend/actions/form.js +237 -0
  11. package/dist/backend/actions/formTable.d.ts +25 -1
  12. package/dist/backend/actions/formTable.d.ts.map +1 -1
  13. package/dist/backend/actions/formTable.js +27 -5
  14. package/dist/backend/actions/frames.d.ts +54 -0
  15. package/dist/backend/actions/frames.d.ts.map +1 -0
  16. package/dist/backend/actions/frames.js +97 -0
  17. package/dist/backend/actions/index.d.ts +10 -0
  18. package/dist/backend/actions/index.d.ts.map +1 -1
  19. package/dist/backend/actions/index.js +10 -0
  20. package/dist/backend/actions/inputs.d.ts +140 -0
  21. package/dist/backend/actions/inputs.d.ts.map +1 -0
  22. package/dist/backend/actions/inputs.js +247 -0
  23. package/dist/backend/actions/interactions.d.ts +61 -1
  24. package/dist/backend/actions/interactions.d.ts.map +1 -1
  25. package/dist/backend/actions/interactions.js +65 -10
  26. package/dist/backend/actions/keyboard.d.ts +71 -0
  27. package/dist/backend/actions/keyboard.d.ts.map +1 -0
  28. package/dist/backend/actions/keyboard.js +98 -0
  29. package/dist/backend/actions/misc.d.ts +135 -0
  30. package/dist/backend/actions/misc.d.ts.map +1 -0
  31. package/dist/backend/actions/misc.js +208 -0
  32. package/dist/backend/actions/mobile.d.ts +75 -0
  33. package/dist/backend/actions/mobile.d.ts.map +1 -0
  34. package/dist/backend/actions/mobile.js +148 -0
  35. package/dist/backend/actions/mouse.d.ts +80 -0
  36. package/dist/backend/actions/mouse.d.ts.map +1 -0
  37. package/dist/backend/actions/mouse.js +150 -0
  38. package/dist/backend/actions/navigation.d.ts +48 -1
  39. package/dist/backend/actions/navigation.d.ts.map +1 -1
  40. package/dist/backend/actions/navigation.js +61 -10
  41. package/dist/backend/actions/waits.d.ts +56 -0
  42. package/dist/backend/actions/waits.d.ts.map +1 -0
  43. package/dist/backend/actions/waits.js +83 -0
  44. package/dist/backend/api/assertions.d.ts +32 -1
  45. package/dist/backend/api/assertions.d.ts.map +1 -1
  46. package/dist/backend/api/assertions.js +37 -9
  47. package/dist/backend/api/index.d.ts +1 -0
  48. package/dist/backend/api/index.d.ts.map +1 -1
  49. package/dist/backend/api/index.js +1 -0
  50. package/dist/backend/api/mock.d.ts +34 -1
  51. package/dist/backend/api/mock.d.ts.map +1 -1
  52. package/dist/backend/api/mock.js +37 -10
  53. package/dist/backend/api/network.d.ts +61 -0
  54. package/dist/backend/api/network.d.ts.map +1 -0
  55. package/dist/backend/api/network.js +177 -0
  56. package/dist/backend/api/requests.d.ts +43 -1
  57. package/dist/backend/api/requests.d.ts.map +1 -1
  58. package/dist/backend/api/requests.js +49 -17
  59. package/dist/backend/assertions/pageState.d.ts +40 -1
  60. package/dist/backend/assertions/pageState.d.ts.map +1 -1
  61. package/dist/backend/assertions/pageState.js +48 -16
  62. package/dist/backend/assertions/text.d.ts +46 -1
  63. package/dist/backend/assertions/text.d.ts.map +1 -1
  64. package/dist/backend/assertions/text.js +51 -8
  65. package/dist/backend/assertions/visibility.d.ts +102 -1
  66. package/dist/backend/assertions/visibility.d.ts.map +1 -1
  67. package/dist/backend/assertions/visibility.js +166 -12
  68. package/dist/backend/auth/index.js +2 -2
  69. package/dist/backend/db/steps.d.ts +35 -1
  70. package/dist/backend/db/steps.d.ts.map +1 -1
  71. package/dist/backend/db/steps.js +48 -15
  72. package/dist/backend/elements/alerts.d.ts +35 -1
  73. package/dist/backend/elements/alerts.d.ts.map +1 -1
  74. package/dist/backend/elements/alerts.js +39 -6
  75. package/dist/backend/elements/forms.d.ts +44 -1
  76. package/dist/backend/elements/forms.d.ts.map +1 -1
  77. package/dist/backend/elements/forms.js +50 -11
  78. package/dist/backend/elements/frames.d.ts +36 -1
  79. package/dist/backend/elements/frames.d.ts.map +1 -1
  80. package/dist/backend/elements/frames.js +43 -13
  81. package/dist/backend/utils/state.d.ts +18 -0
  82. package/dist/backend/utils/state.d.ts.map +1 -0
  83. package/dist/backend/utils/state.js +84 -0
  84. package/dist/core/registry.d.ts +14 -14
  85. package/dist/core/registry.d.ts.map +1 -1
  86. package/dist/core/registry.js +13 -4
  87. package/dist/core/runner.d.ts.map +1 -1
  88. package/dist/core/runner.js +91 -38
  89. package/package.json +52 -12
@@ -33,27 +33,52 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- const registry_1 = require("../../core/registry");
37
- const state_1 = require("./state");
36
+ exports.MakePostRequestWithFile = exports.MakePostRequestWithTable = exports.MakeDeleteRequest = exports.MakeGetRequest = void 0;
38
37
  const fs = __importStar(require("fs"));
39
38
  const path = __importStar(require("path"));
40
- // GET Request
41
- (0, registry_1.Step)("I make a GET request to {string}", async (page, url) => {
39
+ const registry_1 = require("../../core/registry");
40
+ const state_1 = require("./state");
41
+ /**
42
+ * @module ApiActions
43
+ */
44
+ /**
45
+ * Performs a standard HTTP GET request and stores the response in the global API state.
46
+ * * @example
47
+ * ```gherkin
48
+ * When I make a GET request to "[https://api.example.com/users](https://api.example.com/users)"
49
+ * ```
50
+ * * @param url - The full URL or endpoint path.
51
+ */
52
+ exports.MakeGetRequest = (0, registry_1.Step)("I make a GET request to {string}", async (page, url) => {
42
53
  const response = await page.request.get(url);
43
54
  state_1.apiState.setResponse(response);
44
55
  console.log(`GET ${url} - Status: ${response.status()}`);
45
56
  });
46
- // DELETE Request
47
- (0, registry_1.Step)("I make a DELETE request to {string}", async (page, url) => {
57
+ /**
58
+ * Performs a standard HTTP DELETE request and stores the response in the global API state.
59
+ * * @example
60
+ * ```gherkin
61
+ * When I make a DELETE request to "/api/users/1"
62
+ * ```
63
+ * * @param url - The endpoint path to delete.
64
+ */
65
+ exports.MakeDeleteRequest = (0, registry_1.Step)("I make a DELETE request to {string}", async (page, url) => {
48
66
  const response = await page.request.delete(url);
49
67
  state_1.apiState.setResponse(response);
68
+ console.log(`DELETE ${url} - Status: ${response.status()}`);
50
69
  });
51
- // 1. POST with Data Table
52
- // Usage:
53
- // When I make a POST request to "/api/users" with data:
54
- // | name | John |
55
- // | job | Dev |
56
- (0, registry_1.Step)("I make a POST request to {string} with data", async (page, url, tableData) => {
70
+ /**
71
+ * Performs an HTTP POST request using a Gherkin Data Table as the JSON payload.
72
+ * * @example
73
+ * ```gherkin
74
+ * When I make a POST request to "/api/users" with data
75
+ * | name | John |
76
+ * | job | Dev |
77
+ * ```
78
+ * * @param url - The target endpoint.
79
+ * @param tableData - The Gherkin Data Table (automatically converted to a JSON object).
80
+ */
81
+ exports.MakePostRequestWithTable = (0, registry_1.Step)("I make a POST request to {string} with data", async (page, url, tableData) => {
57
82
  if (!tableData)
58
83
  throw new Error("This step requires a Data Table.");
59
84
  // Convert Table [ ["key", "val"], ["k2", "v2"] ] -> Object { key: "val", k2: "v2" }
@@ -66,16 +91,22 @@ const path = __importStar(require("path"));
66
91
  headers: { "Content-Type": "application/json" },
67
92
  });
68
93
  state_1.apiState.setResponse(response);
94
+ console.log(`POST ${url} (Table) - Status: ${response.status()}`);
69
95
  });
70
- // 2. POST with File Payload
71
- // Usage: When I make a POST request to "/api/users" with payload from "data/user.json"
72
- (0, registry_1.Step)("I make a POST request to {string} with payload from {string}", async (page, url, filePath) => {
73
- // Resolve file path (relative to root)
96
+ /**
97
+ * Performs an HTTP POST request using the contents of a local JSON file as the payload.
98
+ * * @example
99
+ * ```gherkin
100
+ * When I make a POST request to "/api/users" with payload from "data/user.json"
101
+ * ```
102
+ * * @param url - The target endpoint.
103
+ * @param filePath - Path to the JSON file relative to the project root.
104
+ */
105
+ exports.MakePostRequestWithFile = (0, registry_1.Step)("I make a POST request to {string} with payload from {string}", async (page, url, filePath) => {
74
106
  const fullPath = path.resolve(process.cwd(), filePath);
75
107
  if (!fs.existsSync(fullPath)) {
76
108
  throw new Error(`❌ Payload file not found at: ${fullPath}`);
77
109
  }
78
- // Read and parse JSON
79
110
  const fileContent = fs.readFileSync(fullPath, "utf8");
80
111
  const payload = JSON.parse(fileContent);
81
112
  const response = await page.request.post(url, {
@@ -83,4 +114,5 @@ const path = __importStar(require("path"));
83
114
  headers: { "Content-Type": "application/json" },
84
115
  });
85
116
  state_1.apiState.setResponse(response);
117
+ console.log(`POST ${url} (File: ${filePath}) - Status: ${response.status()}`);
86
118
  });
@@ -1,2 +1,41 @@
1
- export {};
1
+ /**
2
+ * @module BrowserAssertions
3
+ */
4
+ /**
5
+ * Asserts that the current browser URL contains a specific substring.
6
+ * Useful for verifying redirection to a general area (e.g., a dashboard).
7
+ * * @example
8
+ * ```gherkin
9
+ * Then I expect the url to contain "dashboard"
10
+ * ```
11
+ * * @param part - The substring to search for in the URL.
12
+ */
13
+ export declare const ExpectUrlToContain: void;
14
+ /**
15
+ * Asserts that the current browser URL exactly matches the provided string.
16
+ * * @example
17
+ * ```gherkin
18
+ * Then I expect the url to be "[https://example.com/login](https://example.com/login)"
19
+ * ```
20
+ * * @param url - The expected full URL.
21
+ */
22
+ export declare const ExpectUrlToBe: void;
23
+ /**
24
+ * Asserts that the page's `<title>` tag contains a specific substring.
25
+ * * @example
26
+ * ```gherkin
27
+ * Then I expect the title to contain "Welcome"
28
+ * ```
29
+ * * @param part - The substring expected within the page title.
30
+ */
31
+ export declare const ExpectTitleToContain: void;
32
+ /**
33
+ * Asserts that the page's `<title>` tag exactly matches the provided string.
34
+ * * @example
35
+ * ```gherkin
36
+ * Then I expect the title to be "My Application - Home"
37
+ * ```
38
+ * * @param title - The expected full page title.
39
+ */
40
+ export declare const ExpectTitleToBe: void;
2
41
  //# sourceMappingURL=pageState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/pageState.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/pageState.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAM9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,MAGxB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,MAMhC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,MAG1B,CAAC"}
@@ -1,25 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpectTitleToBe = exports.ExpectTitleToContain = exports.ExpectUrlToBe = exports.ExpectUrlToContain = void 0;
3
4
  const test_1 = require("@playwright/test");
4
5
  const registry_1 = require("../../core/registry");
5
- // URL Check
6
- (0, registry_1.Step)("I expect the url to be {string}", async (page, url) => {
7
- await (0, test_1.expect)(page).toHaveURL(url);
8
- });
9
- // Partial URL Check
10
- (0, registry_1.Step)("I expect the url to contain {string}", async (page, part) => {
11
- // We use a RegExp to allow partial matching safely
6
+ /**
7
+ * @module BrowserAssertions
8
+ */
9
+ /**
10
+ * Asserts that the current browser URL contains a specific substring.
11
+ * Useful for verifying redirection to a general area (e.g., a dashboard).
12
+ * * @example
13
+ * ```gherkin
14
+ * Then I expect the url to contain "dashboard"
15
+ * ```
16
+ * * @param part - The substring to search for in the URL.
17
+ */
18
+ exports.ExpectUrlToContain = (0, registry_1.Step)("I expect the url to contain {string}", async (page, part) => {
12
19
  await (0, test_1.expect)(page).toHaveURL(new RegExp(part));
20
+ console.log(`✅ URL contains "${part}"`);
13
21
  });
14
- // Title Check
15
- (0, registry_1.Step)("I expect the title to be {string}", async (page, title) => {
16
- await (0, test_1.expect)(page).toHaveTitle(title);
22
+ /**
23
+ * Asserts that the current browser URL exactly matches the provided string.
24
+ * * @example
25
+ * ```gherkin
26
+ * Then I expect the url to be "[https://example.com/login](https://example.com/login)"
27
+ * ```
28
+ * * @param url - The expected full URL.
29
+ */
30
+ exports.ExpectUrlToBe = (0, registry_1.Step)("I expect the url to be {string}", async (page, url) => {
31
+ await (0, test_1.expect)(page).toHaveURL(url);
32
+ console.log(`✅ URL is "${url}"`);
17
33
  });
18
- // Partial Title Check
19
- (0, registry_1.Step)("I expect the title to contain {string}", async (page, titlePart) => {
20
- await (0, test_1.expect)(page).toHaveTitle(new RegExp(titlePart));
34
+ /**
35
+ * Asserts that the page's `<title>` tag contains a specific substring.
36
+ * * @example
37
+ * ```gherkin
38
+ * Then I expect the title to contain "Welcome"
39
+ * ```
40
+ * * @param part - The substring expected within the page title.
41
+ */
42
+ exports.ExpectTitleToContain = (0, registry_1.Step)("I expect the title to contain {string}", async (page, part) => {
43
+ await (0, test_1.expect)(page).toHaveTitle(new RegExp(part));
44
+ console.log(`✅ Title contains "${part}"`);
21
45
  });
22
- // Screenshot Match (Visual Regression)
23
- (0, registry_1.Step)("I expect the page screenshot to match {string}", async (page, filename) => {
24
- await (0, test_1.expect)(page).toHaveScreenshot(filename);
46
+ /**
47
+ * Asserts that the page's `<title>` tag exactly matches the provided string.
48
+ * * @example
49
+ * ```gherkin
50
+ * Then I expect the title to be "My Application - Home"
51
+ * ```
52
+ * * @param title - The expected full page title.
53
+ */
54
+ exports.ExpectTitleToBe = (0, registry_1.Step)("I expect the title to be {string}", async (page, title) => {
55
+ await (0, test_1.expect)(page).toHaveTitle(title);
56
+ console.log(`✅ Title is "${title}"`);
25
57
  });
@@ -1,2 +1,47 @@
1
- export {};
1
+ /**
2
+ * @module ElementAssertions
3
+ */
4
+ /**
5
+ * Asserts that an element exactly matches the specified text.
6
+ * * @example
7
+ * ```gherkin
8
+ * Then I expect "h1" to have text "Welcome Home"
9
+ * ```
10
+ * * @param selector - The CSS or Playwright selector for the element.
11
+ * @param text - The exact text string expected.
12
+ */
13
+ export declare const ExpectElementToHaveText: void;
14
+ /**
15
+ * Asserts that an element contains the specified substring.
16
+ * Useful for long paragraphs or dynamic content.
17
+ * * @example
18
+ * ```gherkin
19
+ * Then I expect ".error-msg" to contain text "invalid credentials"
20
+ * ```
21
+ * * @param selector - The CSS or Playwright selector for the element.
22
+ * @param text - The partial text string expected to be present.
23
+ */
24
+ export declare const ExpectElementToContainText: void;
25
+ /**
26
+ * Asserts that a form field (input, textarea, select) has a specific value.
27
+ * * @example
28
+ * ```gherkin
29
+ * Then I expect "#username" to have value "john_doe"
30
+ * ```
31
+ * * @param selector - The selector for the input element.
32
+ * @param value - The expected value of the field.
33
+ */
34
+ export declare const ExpectElementToHaveValue: void;
35
+ /**
36
+ * Asserts that a specific attribute of an element matches the expected value.
37
+ * Common use cases include checking `href` for links or `src` for images.
38
+ * * @example
39
+ * ```gherkin
40
+ * Then I expect "a#terms-link" to have attribute "href" with value "/terms-and-conditions"
41
+ * ```
42
+ * * @param selector - The selector for the element.
43
+ * @param attr - The name of the attribute (e.g., "class", "href", "data-testid").
44
+ * @param value - The expected value of that attribute.
45
+ */
46
+ export declare const ExpectElementAttributeValue: void;
2
47
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/text.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/text.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,MAMnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,MAMtC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,MAMpC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,MAMvC,CAAC"}
@@ -1,20 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpectElementAttributeValue = exports.ExpectElementToHaveValue = exports.ExpectElementToContainText = exports.ExpectElementToHaveText = void 0;
3
4
  const test_1 = require("@playwright/test");
4
5
  const registry_1 = require("../../core/registry");
5
- // Exact text match
6
- (0, registry_1.Step)("I expect {string} to have text {string}", async (page, selector, text) => {
6
+ /**
7
+ * @module ElementAssertions
8
+ */
9
+ /**
10
+ * Asserts that an element exactly matches the specified text.
11
+ * * @example
12
+ * ```gherkin
13
+ * Then I expect "h1" to have text "Welcome Home"
14
+ * ```
15
+ * * @param selector - The CSS or Playwright selector for the element.
16
+ * @param text - The exact text string expected.
17
+ */
18
+ exports.ExpectElementToHaveText = (0, registry_1.Step)("I expect {string} to have text {string}", async (page, selector, text) => {
7
19
  await (0, test_1.expect)(page.locator(selector)).toHaveText(text);
20
+ console.log(`✅ Element "${selector}" has exact text "${text}"`);
8
21
  });
9
- // Partial text match (contains)
10
- (0, registry_1.Step)("I expect {string} to contain text {string}", async (page, selector, text) => {
22
+ /**
23
+ * Asserts that an element contains the specified substring.
24
+ * Useful for long paragraphs or dynamic content.
25
+ * * @example
26
+ * ```gherkin
27
+ * Then I expect ".error-msg" to contain text "invalid credentials"
28
+ * ```
29
+ * * @param selector - The CSS or Playwright selector for the element.
30
+ * @param text - The partial text string expected to be present.
31
+ */
32
+ exports.ExpectElementToContainText = (0, registry_1.Step)("I expect {string} to contain text {string}", async (page, selector, text) => {
11
33
  await (0, test_1.expect)(page.locator(selector)).toContainText(text);
34
+ console.log(`✅ Element "${selector}" contains text "${text}"`);
12
35
  });
13
- // Check input value (for form fields)
14
- (0, registry_1.Step)("I expect {string} to have value {string}", async (page, selector, value) => {
36
+ /**
37
+ * Asserts that a form field (input, textarea, select) has a specific value.
38
+ * * @example
39
+ * ```gherkin
40
+ * Then I expect "#username" to have value "john_doe"
41
+ * ```
42
+ * * @param selector - The selector for the input element.
43
+ * @param value - The expected value of the field.
44
+ */
45
+ exports.ExpectElementToHaveValue = (0, registry_1.Step)("I expect {string} to have value {string}", async (page, selector, value) => {
15
46
  await (0, test_1.expect)(page.locator(selector)).toHaveValue(value);
47
+ console.log(`✅ Input "${selector}" has value "${value}"`);
16
48
  });
17
- // Check an attribute (e.g., class, href, src)
18
- (0, registry_1.Step)("I expect {string} to have attribute {string} with value {string}", async (page, selector, attr, value) => {
49
+ /**
50
+ * Asserts that a specific attribute of an element matches the expected value.
51
+ * Common use cases include checking `href` for links or `src` for images.
52
+ * * @example
53
+ * ```gherkin
54
+ * Then I expect "a#terms-link" to have attribute "href" with value "/terms-and-conditions"
55
+ * ```
56
+ * * @param selector - The selector for the element.
57
+ * @param attr - The name of the attribute (e.g., "class", "href", "data-testid").
58
+ * @param value - The expected value of that attribute.
59
+ */
60
+ exports.ExpectElementAttributeValue = (0, registry_1.Step)("I expect {string} to have attribute {string} with value {string}", async (page, selector, attr, value) => {
19
61
  await (0, test_1.expect)(page.locator(selector)).toHaveAttribute(attr, value);
62
+ console.log(`✅ Element "${selector}" attribute "${attr}" is "${value}"`);
20
63
  });
@@ -1,2 +1,103 @@
1
- export {};
1
+ /**
2
+ * @module ActiveElementAssertions
3
+ */
4
+ /**
5
+ * Asserts that the currently stored (active) element is visible in the viewport.
6
+ * * @example
7
+ * ```gherkin
8
+ * Then I expect element to be visible
9
+ * ```
10
+ */
11
+ export declare const ExpectActiveVisible: void;
12
+ /**
13
+ * Asserts that an element with a given selector or description is visible in the viewport.
14
+ * * @example
15
+ * ```gherkin
16
+ * Then I expect "Submit Button" to be visible
17
+ * Then I expect ".login-form" to be visible
18
+ * ```
19
+ */
20
+ export declare const ExpectStringVisible: void;
21
+ /**
22
+ * Asserts that the currently stored (active) element is hidden or detached from the DOM.
23
+ * * @example
24
+ * ```gherkin
25
+ * Then I expect element to be hidden
26
+ * ```
27
+ */
28
+ export declare const ExpectActiveHidden: void;
29
+ /**
30
+ * Asserts that the currently stored (active) element is enabled (not disabled).
31
+ * * @example
32
+ * ```gherkin
33
+ * Then I expect element to be enabled
34
+ * ```
35
+ */
36
+ export declare const ExpectActiveEnabled: void;
37
+ /**
38
+ * Asserts that the currently stored (active) element is disabled.
39
+ * * @example
40
+ * ```gherkin
41
+ * Then I expect element to be disabled
42
+ * ```
43
+ */
44
+ export declare const ExpectActiveDisabled: void;
45
+ /**
46
+ * Asserts that the currently stored (active) element has the exact text specified.
47
+ * * @example
48
+ * ```gherkin
49
+ * Then I expect element to have text "Submit Order"
50
+ * ```
51
+ */
52
+ export declare const ExpectActiveText: void;
53
+ /**
54
+ * Asserts that the currently stored (active) element contains the specified partial text.
55
+ * * @example
56
+ * ```gherkin
57
+ * Then I expect element to contain text "Order #"
58
+ * ```
59
+ */
60
+ export declare const ExpectActiveContainText: void;
61
+ /**
62
+ * Asserts that the currently stored (active) element (input/select) has a specific value.
63
+ * Supports aliases (e.g., `@orderId`) to compare against stored variables.
64
+ * * @example
65
+ * ```gherkin
66
+ * Then I expect element to have value "12345"
67
+ * Then I expect element to have value "@savedUserEmail"
68
+ * ```
69
+ */
70
+ export declare const ExpectActiveValue: void;
71
+ /**
72
+ * Asserts that the currently stored (active) element possesses a specific attribute.
73
+ * * @example
74
+ * ```gherkin
75
+ * Then I expect element to have attribute "required"
76
+ * ```
77
+ */
78
+ export declare const ExpectActiveAttribute: void;
79
+ /**
80
+ * Asserts that the currently stored (active) element has an attribute with a specific value.
81
+ * * @example
82
+ * ```gherkin
83
+ * Then I expect element to have attribute "type" with value "password"
84
+ * ```
85
+ */
86
+ export declare const ExpectActiveAttributeValue: void;
87
+ /**
88
+ * Performs a visual comparison of the entire page against a baseline screenshot.
89
+ * * @example
90
+ * ```gherkin
91
+ * Then I expect the page screenshot to match "landing-page.png"
92
+ * ```
93
+ */
94
+ export declare const ExpectPageScreenshotMatch: void;
95
+ /**
96
+ * Performs a visual comparison of the active element against a baseline screenshot.
97
+ * * @example
98
+ * ```gherkin
99
+ * Then I expect the element screenshot to match "login-button.png"
100
+ * ```
101
+ */
102
+ export declare const ExpectElementScreenshotMatch: void;
2
103
  //# sourceMappingURL=visibility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/visibility.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/visibility.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,MAI7B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,MAI/B,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAO5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,MAOnC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,MAa7B,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,MAOjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,MAOtC,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAMrC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,MAOxC,CAAC"}
@@ -1,20 +1,174 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpectElementScreenshotMatch = exports.ExpectPageScreenshotMatch = exports.ExpectActiveAttributeValue = exports.ExpectActiveAttribute = exports.ExpectActiveValue = exports.ExpectActiveContainText = exports.ExpectActiveText = exports.ExpectActiveDisabled = exports.ExpectActiveEnabled = exports.ExpectActiveHidden = exports.ExpectStringVisible = exports.ExpectActiveVisible = void 0;
3
4
  const test_1 = require("@playwright/test");
4
5
  const registry_1 = require("../../core/registry");
5
- // Check if element exists and is visible
6
- (0, registry_1.Step)("I expect {string} to be visible", async (page, selector) => {
7
- await (0, test_1.expect)(page.locator(selector)).toBeVisible();
6
+ const state_1 = require("../utils/state");
7
+ /**
8
+ * @module ActiveElementAssertions
9
+ */
10
+ // ===============================
11
+ // 1. VISIBILITY & STATE CHECKS
12
+ // ===============================
13
+ /**
14
+ * Asserts that the currently stored (active) element is visible in the viewport.
15
+ * * @example
16
+ * ```gherkin
17
+ * Then I expect element to be visible
18
+ * ```
19
+ */
20
+ exports.ExpectActiveVisible = (0, registry_1.Step)("I expect element to be visible", async (page) => {
21
+ const element = (0, state_1.getActiveElement)(page);
22
+ await (0, test_1.expect)(element).toBeVisible();
23
+ console.log("✅ Element is visible");
8
24
  });
9
- // Check if element is hidden (or doesn't exist)
10
- (0, registry_1.Step)("I expect {string} to be hidden", async (page, selector) => {
11
- await (0, test_1.expect)(page.locator(selector)).toBeHidden();
25
+ /**
26
+ * Asserts that an element with a given selector or description is visible in the viewport.
27
+ * * @example
28
+ * ```gherkin
29
+ * Then I expect "Submit Button" to be visible
30
+ * Then I expect ".login-form" to be visible
31
+ * ```
32
+ */
33
+ exports.ExpectStringVisible = (0, registry_1.Step)("I expect {string} to be visible", async (page, selector) => {
34
+ const element = page.locator(selector);
35
+ await (0, test_1.expect)(element).toBeVisible();
36
+ console.log(`✅ "${selector}" is visible`);
12
37
  });
13
- // Check if element is enabled (clickable)
14
- (0, registry_1.Step)("I expect {string} to be enabled", async (page, selector) => {
15
- await (0, test_1.expect)(page.locator(selector)).toBeEnabled();
38
+ /**
39
+ * Asserts that the currently stored (active) element is hidden or detached from the DOM.
40
+ * * @example
41
+ * ```gherkin
42
+ * Then I expect element to be hidden
43
+ * ```
44
+ */
45
+ exports.ExpectActiveHidden = (0, registry_1.Step)("I expect element to be hidden", async (page) => {
46
+ const element = (0, state_1.getActiveElement)(page);
47
+ await (0, test_1.expect)(element).toBeHidden();
48
+ console.log("✅ Element is hidden");
16
49
  });
17
- // Check if element is disabled
18
- (0, registry_1.Step)("I expect {string} to be disabled", async (page, selector) => {
19
- await (0, test_1.expect)(page.locator(selector)).toBeDisabled();
50
+ /**
51
+ * Asserts that the currently stored (active) element is enabled (not disabled).
52
+ * * @example
53
+ * ```gherkin
54
+ * Then I expect element to be enabled
55
+ * ```
56
+ */
57
+ exports.ExpectActiveEnabled = (0, registry_1.Step)("I expect element to be enabled", async (page) => {
58
+ const element = (0, state_1.getActiveElement)(page);
59
+ await (0, test_1.expect)(element).toBeEnabled();
60
+ console.log("✅ Element is enabled");
61
+ });
62
+ /**
63
+ * Asserts that the currently stored (active) element is disabled.
64
+ * * @example
65
+ * ```gherkin
66
+ * Then I expect element to be disabled
67
+ * ```
68
+ */
69
+ exports.ExpectActiveDisabled = (0, registry_1.Step)("I expect element to be disabled", async (page) => {
70
+ const element = (0, state_1.getActiveElement)(page);
71
+ await (0, test_1.expect)(element).toBeDisabled();
72
+ console.log("✅ Element is disabled");
73
+ });
74
+ // ===============================
75
+ // 2. TEXT & VALUE CHECKS
76
+ // ===============================
77
+ /**
78
+ * Asserts that the currently stored (active) element has the exact text specified.
79
+ * * @example
80
+ * ```gherkin
81
+ * Then I expect element to have text "Submit Order"
82
+ * ```
83
+ */
84
+ exports.ExpectActiveText = (0, registry_1.Step)("I expect element to have text {string}", async (page, text) => {
85
+ const element = (0, state_1.getActiveElement)(page);
86
+ await (0, test_1.expect)(element).toHaveText(text);
87
+ console.log(`✅ Element has text "${text}"`);
88
+ });
89
+ /**
90
+ * Asserts that the currently stored (active) element contains the specified partial text.
91
+ * * @example
92
+ * ```gherkin
93
+ * Then I expect element to contain text "Order #"
94
+ * ```
95
+ */
96
+ exports.ExpectActiveContainText = (0, registry_1.Step)("I expect element to contain text {string}", async (page, text) => {
97
+ const element = (0, state_1.getActiveElement)(page);
98
+ await (0, test_1.expect)(element).toContainText(text);
99
+ console.log(`✅ Element contains text "${text}"`);
100
+ });
101
+ /**
102
+ * Asserts that the currently stored (active) element (input/select) has a specific value.
103
+ * Supports aliases (e.g., `@orderId`) to compare against stored variables.
104
+ * * @example
105
+ * ```gherkin
106
+ * Then I expect element to have value "12345"
107
+ * Then I expect element to have value "@savedUserEmail"
108
+ * ```
109
+ */
110
+ exports.ExpectActiveValue = (0, registry_1.Step)("I expect element to have value {string}", async (page, value) => {
111
+ if (value.startsWith("@")) {
112
+ const alias = value.slice(1);
113
+ const stored = (0, state_1.getVariable)(page, alias);
114
+ if (!stored)
115
+ throw new Error(`Alias @${alias} not found`);
116
+ value = stored;
117
+ }
118
+ const element = (0, state_1.getActiveElement)(page);
119
+ await (0, test_1.expect)(element).toHaveValue(value);
120
+ console.log(`✅ Element has value "${value}"`);
121
+ });
122
+ // ===============================
123
+ // 3. ATTRIBUTE CHECKS
124
+ // ===============================
125
+ /**
126
+ * Asserts that the currently stored (active) element possesses a specific attribute.
127
+ * * @example
128
+ * ```gherkin
129
+ * Then I expect element to have attribute "required"
130
+ * ```
131
+ */
132
+ exports.ExpectActiveAttribute = (0, registry_1.Step)("I expect element to have attribute {string}", async (page, attr) => {
133
+ const element = (0, state_1.getActiveElement)(page);
134
+ await (0, test_1.expect)(element).toHaveAttribute(attr);
135
+ console.log(`✅ Element has attribute "${attr}"`);
136
+ });
137
+ /**
138
+ * Asserts that the currently stored (active) element has an attribute with a specific value.
139
+ * * @example
140
+ * ```gherkin
141
+ * Then I expect element to have attribute "type" with value "password"
142
+ * ```
143
+ */
144
+ exports.ExpectActiveAttributeValue = (0, registry_1.Step)("I expect element to have attribute {string} with value {string}", async (page, attr, value) => {
145
+ const element = (0, state_1.getActiveElement)(page);
146
+ await (0, test_1.expect)(element).toHaveAttribute(attr, value);
147
+ console.log(`✅ Element has attribute "${attr}" = "${value}"`);
148
+ });
149
+ // ===============================
150
+ // 4. VISUAL REGRESSION
151
+ // ===============================
152
+ /**
153
+ * Performs a visual comparison of the entire page against a baseline screenshot.
154
+ * * @example
155
+ * ```gherkin
156
+ * Then I expect the page screenshot to match "landing-page.png"
157
+ * ```
158
+ */
159
+ exports.ExpectPageScreenshotMatch = (0, registry_1.Step)("I expect the page screenshot to match {string}", async (page, filename) => {
160
+ await (0, test_1.expect)(page).toHaveScreenshot(filename);
161
+ console.log(`📸 Page matches screenshot: ${filename}`);
162
+ });
163
+ /**
164
+ * Performs a visual comparison of the active element against a baseline screenshot.
165
+ * * @example
166
+ * ```gherkin
167
+ * Then I expect the element screenshot to match "login-button.png"
168
+ * ```
169
+ */
170
+ exports.ExpectElementScreenshotMatch = (0, registry_1.Step)("I expect the element screenshot to match {string}", async (page, filename) => {
171
+ const element = (0, state_1.getActiveElement)(page);
172
+ await (0, test_1.expect)(element).toHaveScreenshot(filename);
173
+ console.log(`📸 Element matches screenshot: ${filename}`);
20
174
  });
@@ -33,9 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- const registry_1 = require("../../core/registry");
37
- const path = __importStar(require("path"));
38
36
  const fs = __importStar(require("fs"));
37
+ const path = __importStar(require("path"));
38
+ const registry_1 = require("../../core/registry");
39
39
  // 1. SAVE STATE (Use this after a successful login)
40
40
  // Example: And I save the browser state to "admin.json"
41
41
  (0, registry_1.Step)("I save the browser state to {string}", async (page, filename) => {