playwright-cucumber-ts-steps 1.0.4 → 1.0.6
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/dist/backend/actions/formTable.d.ts +2 -0
- package/dist/backend/actions/formTable.d.ts.map +1 -0
- package/dist/backend/actions/formTable.js +16 -7
- package/dist/backend/actions/index.d.ts +4 -0
- package/dist/backend/actions/index.d.ts.map +1 -0
- package/dist/backend/actions/interactions.d.ts +2 -0
- package/dist/backend/actions/interactions.d.ts.map +1 -0
- package/dist/backend/actions/interactions.js +24 -15
- package/dist/backend/actions/navigation.d.ts +2 -0
- package/dist/backend/actions/navigation.d.ts.map +1 -0
- package/dist/backend/actions/navigation.js +21 -12
- package/dist/backend/api/assertions.d.ts +2 -0
- package/dist/backend/api/assertions.d.ts.map +1 -0
- package/dist/backend/api/assertions.js +17 -8
- package/dist/backend/api/index.d.ts +4 -0
- package/dist/backend/api/index.d.ts.map +1 -0
- package/dist/backend/api/mock.d.ts +2 -0
- package/dist/backend/api/mock.d.ts.map +1 -0
- package/dist/backend/api/mock.js +24 -15
- package/dist/backend/api/requests.d.ts +2 -0
- package/dist/backend/api/requests.d.ts.map +1 -0
- package/dist/backend/api/requests.js +21 -12
- package/dist/backend/api/state.d.ts +6 -0
- package/dist/backend/api/state.d.ts.map +1 -0
- package/dist/backend/assertions/expectVisible.d.ts +3 -0
- package/dist/backend/assertions/expectVisible.d.ts.map +1 -0
- package/dist/backend/assertions/expectVisible.js +15 -4
- package/dist/backend/assertions/index.d.ts +4 -0
- package/dist/backend/assertions/index.d.ts.map +1 -0
- package/dist/backend/assertions/pageState.d.ts +2 -0
- package/dist/backend/assertions/pageState.d.ts.map +1 -0
- package/dist/backend/assertions/pageState.js +24 -15
- package/dist/backend/assertions/text.d.ts +2 -0
- package/dist/backend/assertions/text.d.ts.map +1 -0
- package/dist/backend/assertions/text.js +21 -12
- package/dist/backend/assertions/visibility.d.ts +2 -0
- package/dist/backend/assertions/visibility.d.ts.map +1 -0
- package/dist/backend/assertions/visibility.js +21 -12
- package/dist/backend/auth/index.d.ts +2 -0
- package/dist/backend/auth/index.d.ts.map +1 -0
- package/dist/backend/auth/index.js +15 -6
- package/dist/backend/db/index.d.ts +3 -0
- package/dist/backend/db/index.d.ts.map +1 -0
- package/dist/backend/db/state.d.ts +6 -0
- package/dist/backend/db/state.d.ts.map +1 -0
- package/dist/backend/db/state.js +12 -3
- package/dist/backend/db/steps.d.ts +2 -0
- package/dist/backend/db/steps.d.ts.map +1 -0
- package/dist/backend/db/steps.js +16 -7
- package/dist/backend/elements/alerts.d.ts +2 -0
- package/dist/backend/elements/alerts.d.ts.map +1 -0
- package/dist/backend/elements/alerts.js +24 -15
- package/dist/backend/elements/forms.d.ts +2 -0
- package/dist/backend/elements/forms.d.ts.map +1 -0
- package/dist/backend/elements/forms.js +21 -12
- package/dist/backend/elements/frames.d.ts +2 -0
- package/dist/backend/elements/frames.d.ts.map +1 -0
- package/dist/backend/elements/frames.js +20 -11
- package/dist/backend/elements/index.d.ts +4 -0
- package/dist/backend/elements/index.d.ts.map +1 -0
- package/dist/core/registry.d.ts +23 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/runner.d.ts +17 -0
- package/dist/core/runner.d.ts.map +1 -0
- package/dist/core/runner.js +16 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/reporting/index.d.ts +12 -0
- package/dist/reporting/index.d.ts.map +1 -0
- package/package.json +26 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formTable.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/formTable.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const registry_1 = require("../../core/registry");
|
|
4
13
|
const test_1 = require("@playwright/test");
|
|
5
14
|
// CHANGE: Removed the ':' at the end of the string below
|
|
6
|
-
(0, registry_1.Step)("I fill the following {string} form data",
|
|
15
|
+
(0, registry_1.Step)("I fill the following {string} form data", (page, formName, tableData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
16
|
console.log(`📝 Processing Form: ${formName}`);
|
|
8
17
|
// The runner passes the table data as the last argument
|
|
9
18
|
// tableData = [ ['#username', 'tomsmith'], ['#password', '...'] ]
|
|
@@ -15,20 +24,20 @@ const test_1 = require("@playwright/test");
|
|
|
15
24
|
const selector = row[0];
|
|
16
25
|
const value = row[1];
|
|
17
26
|
if (value === "click") {
|
|
18
|
-
|
|
27
|
+
yield page.click(selector);
|
|
19
28
|
}
|
|
20
29
|
else if (value === "check") {
|
|
21
|
-
|
|
30
|
+
yield page.check(selector);
|
|
22
31
|
}
|
|
23
32
|
else if (value === "assert:visible") {
|
|
24
|
-
|
|
33
|
+
yield (0, test_1.expect)(page.locator(selector)).toBeVisible();
|
|
25
34
|
}
|
|
26
35
|
else if (value.startsWith("assert:text:")) {
|
|
27
36
|
const text = value.replace("assert:text:", "");
|
|
28
|
-
|
|
37
|
+
yield (0, test_1.expect)(page.locator(selector)).toHaveText(text);
|
|
29
38
|
}
|
|
30
39
|
else {
|
|
31
|
-
|
|
40
|
+
yield page.fill(selector, value);
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
|
-
});
|
|
43
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,gBAAgB,CAAC;AACxB,OAAO,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/interactions.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const registry_1 = require("../../core/registry");
|
|
4
13
|
// Click
|
|
5
|
-
(0, registry_1.Step)("I click {string}",
|
|
6
|
-
|
|
7
|
-
});
|
|
14
|
+
(0, registry_1.Step)("I click {string}", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
yield page.click(selector);
|
|
16
|
+
}));
|
|
8
17
|
// Force Click (sometimes needed for stubborn elements)
|
|
9
|
-
(0, registry_1.Step)("I force click {string}",
|
|
10
|
-
|
|
11
|
-
});
|
|
18
|
+
(0, registry_1.Step)("I force click {string}", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
yield page.click(selector, { force: true });
|
|
20
|
+
}));
|
|
12
21
|
// Type/Fill
|
|
13
|
-
(0, registry_1.Step)("I fill {string} with {string}",
|
|
14
|
-
|
|
15
|
-
});
|
|
22
|
+
(0, registry_1.Step)("I fill {string} with {string}", (page, selector, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
yield page.fill(selector, value);
|
|
24
|
+
}));
|
|
16
25
|
// Press Key (e.g., "Enter")
|
|
17
|
-
(0, registry_1.Step)("I press {string}",
|
|
18
|
-
|
|
19
|
-
});
|
|
26
|
+
(0, registry_1.Step)("I press {string}", (page, key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
yield page.keyboard.press(key);
|
|
28
|
+
}));
|
|
20
29
|
// Wait (Hard wait - use sparingly!)
|
|
21
|
-
(0, registry_1.Step)("I wait for {int} milliseconds",
|
|
22
|
-
|
|
23
|
-
});
|
|
30
|
+
(0, registry_1.Step)("I wait for {int} milliseconds", (page, ms) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
yield page.waitForTimeout(ms);
|
|
32
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/backend/actions/navigation.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const registry_1 = require("../../core/registry");
|
|
4
13
|
// Basic visit
|
|
5
|
-
(0, registry_1.Step)("I visit {string}",
|
|
6
|
-
|
|
7
|
-
});
|
|
14
|
+
(0, registry_1.Step)("I visit {string}", (page, url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
yield page.goto(url);
|
|
16
|
+
}));
|
|
8
17
|
// Visit and wait for network (useful for slow apps)
|
|
9
|
-
(0, registry_1.Step)("I visit {string} and wait for network idle",
|
|
10
|
-
|
|
11
|
-
});
|
|
18
|
+
(0, registry_1.Step)("I visit {string} and wait for network idle", (page, url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
yield page.goto(url, { waitUntil: "networkidle" });
|
|
20
|
+
}));
|
|
12
21
|
// Reload page
|
|
13
|
-
(0, registry_1.Step)("I reload the page",
|
|
14
|
-
|
|
15
|
-
});
|
|
22
|
+
(0, registry_1.Step)("I reload the page", (page) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
yield page.reload();
|
|
24
|
+
}));
|
|
16
25
|
// Go back
|
|
17
|
-
(0, registry_1.Step)("I go back",
|
|
18
|
-
|
|
19
|
-
});
|
|
26
|
+
(0, registry_1.Step)("I go back", (page) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
yield page.goBack();
|
|
28
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/backend/api/assertions.ts"],"names":[],"mappings":""}
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const test_1 = require("@playwright/test");
|
|
4
13
|
const registry_1 = require("../../core/registry");
|
|
5
14
|
const state_1 = require("./state");
|
|
6
15
|
// Check Status Code
|
|
7
|
-
(0, registry_1.Step)("I expect the response status to be {int}",
|
|
16
|
+
(0, registry_1.Step)("I expect the response status to be {int}", (page, statusCode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
17
|
const response = state_1.apiState.getResponse();
|
|
9
18
|
(0, test_1.expect)(response.status()).toBe(statusCode);
|
|
10
|
-
});
|
|
19
|
+
}));
|
|
11
20
|
// Check entire Body Text
|
|
12
|
-
(0, registry_1.Step)("I expect the response body to contain {string}",
|
|
21
|
+
(0, registry_1.Step)("I expect the response body to contain {string}", (page, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
22
|
const response = state_1.apiState.getResponse();
|
|
14
|
-
const body =
|
|
23
|
+
const body = yield response.text();
|
|
15
24
|
(0, test_1.expect)(body).toContain(text);
|
|
16
|
-
});
|
|
25
|
+
}));
|
|
17
26
|
// Check JSON Property
|
|
18
|
-
(0, registry_1.Step)("I expect the response property {string} to be {string}",
|
|
27
|
+
(0, registry_1.Step)("I expect the response property {string} to be {string}", (page, jsonPath, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
28
|
const response = state_1.apiState.getResponse();
|
|
20
|
-
const json =
|
|
29
|
+
const json = yield response.json();
|
|
21
30
|
// FIX: Added ': string' to the 'i' parameter
|
|
22
31
|
const actualValue = jsonPath
|
|
23
32
|
.split(".")
|
|
24
33
|
.reduce((o, i) => o[i], json);
|
|
25
34
|
(0, test_1.expect)(String(actualValue)).toBe(value);
|
|
26
|
-
});
|
|
35
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/backend/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,cAAc,CAAC;AACtB,OAAO,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/backend/api/mock.ts"],"names":[],"mappings":""}
|
package/dist/backend/api/mock.js
CHANGED
|
@@ -32,44 +32,53 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
35
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
45
|
const registry_1 = require("../../core/registry");
|
|
37
46
|
const fs = __importStar(require("fs"));
|
|
38
47
|
const path = __importStar(require("path"));
|
|
39
48
|
// 1. Mock with Inline JSON
|
|
40
49
|
// Usage: Given I mock the API endpoint "/api/users" with body '{"id": 1, "name": "Fake"}'
|
|
41
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with body {string}",
|
|
42
|
-
|
|
50
|
+
(0, registry_1.Step)("I mock the API endpoint {string} with body {string}", (page, urlPattern, jsonBody) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
yield page.route(urlPattern, (route) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
52
|
const json = JSON.parse(jsonBody);
|
|
44
|
-
|
|
53
|
+
yield route.fulfill({
|
|
45
54
|
status: 200,
|
|
46
55
|
contentType: "application/json",
|
|
47
56
|
body: JSON.stringify(json),
|
|
48
57
|
});
|
|
49
|
-
});
|
|
58
|
+
}));
|
|
50
59
|
console.log(`🎭 Mocked ${urlPattern} with inline JSON`);
|
|
51
|
-
});
|
|
60
|
+
}));
|
|
52
61
|
// 2. Mock with File
|
|
53
62
|
// Usage: Given I mock the API endpoint "/api/users" with response from "mocks/users.json"
|
|
54
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with response from {string}",
|
|
63
|
+
(0, registry_1.Step)("I mock the API endpoint {string} with response from {string}", (page, urlPattern, filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
64
|
const fullPath = path.resolve(process.cwd(), filePath);
|
|
56
65
|
if (!fs.existsSync(fullPath)) {
|
|
57
66
|
throw new Error(`❌ Mock file not found at: ${fullPath}`);
|
|
58
67
|
}
|
|
59
68
|
const bodyContent = fs.readFileSync(fullPath, "utf8");
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
yield page.route(urlPattern, (route) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
yield route.fulfill({
|
|
62
71
|
status: 200,
|
|
63
72
|
contentType: "application/json",
|
|
64
73
|
body: bodyContent,
|
|
65
74
|
});
|
|
66
|
-
});
|
|
75
|
+
}));
|
|
67
76
|
console.log(`🎭 Mocked ${urlPattern} with file: ${filePath}`);
|
|
68
|
-
});
|
|
77
|
+
}));
|
|
69
78
|
// 3. Mock Status Code Only (Simulate Errors)
|
|
70
79
|
// Usage: Given I mock the API endpoint "/api/broken" with status 500
|
|
71
|
-
(0, registry_1.Step)("I mock the API endpoint {string} with status {int}",
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
});
|
|
80
|
+
(0, registry_1.Step)("I mock the API endpoint {string} with status {int}", (page, urlPattern, statusCode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
yield page.route(urlPattern, (route) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
yield route.fulfill({ status: statusCode });
|
|
83
|
+
}));
|
|
84
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/backend/api/requests.ts"],"names":[],"mappings":""}
|
|
@@ -32,28 +32,37 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
35
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
45
|
const registry_1 = require("../../core/registry");
|
|
37
46
|
const state_1 = require("./state");
|
|
38
47
|
const fs = __importStar(require("fs"));
|
|
39
48
|
const path = __importStar(require("path"));
|
|
40
49
|
// GET Request
|
|
41
|
-
(0, registry_1.Step)("I make a GET request to {string}",
|
|
42
|
-
const response =
|
|
50
|
+
(0, registry_1.Step)("I make a GET request to {string}", (page, url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
const response = yield page.request.get(url);
|
|
43
52
|
state_1.apiState.setResponse(response);
|
|
44
53
|
console.log(`GET ${url} - Status: ${response.status()}`);
|
|
45
|
-
});
|
|
54
|
+
}));
|
|
46
55
|
// DELETE Request
|
|
47
|
-
(0, registry_1.Step)("I make a DELETE request to {string}",
|
|
48
|
-
const response =
|
|
56
|
+
(0, registry_1.Step)("I make a DELETE request to {string}", (page, url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const response = yield page.request.delete(url);
|
|
49
58
|
state_1.apiState.setResponse(response);
|
|
50
|
-
});
|
|
59
|
+
}));
|
|
51
60
|
// 1. POST with Data Table
|
|
52
61
|
// Usage:
|
|
53
62
|
// When I make a POST request to "/api/users" with data:
|
|
54
63
|
// | name | John |
|
|
55
64
|
// | job | Dev |
|
|
56
|
-
(0, registry_1.Step)("I make a POST request to {string} with data",
|
|
65
|
+
(0, registry_1.Step)("I make a POST request to {string} with data", (page, url, tableData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
66
|
if (!tableData)
|
|
58
67
|
throw new Error("This step requires a Data Table.");
|
|
59
68
|
// Convert Table [ ["key", "val"], ["k2", "v2"] ] -> Object { key: "val", k2: "v2" }
|
|
@@ -61,15 +70,15 @@ const path = __importStar(require("path"));
|
|
|
61
70
|
acc[row[0]] = row[1];
|
|
62
71
|
return acc;
|
|
63
72
|
}, {});
|
|
64
|
-
const response =
|
|
73
|
+
const response = yield page.request.post(url, {
|
|
65
74
|
data: payload,
|
|
66
75
|
headers: { "Content-Type": "application/json" },
|
|
67
76
|
});
|
|
68
77
|
state_1.apiState.setResponse(response);
|
|
69
|
-
});
|
|
78
|
+
}));
|
|
70
79
|
// 2. POST with File Payload
|
|
71
80
|
// 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}",
|
|
81
|
+
(0, registry_1.Step)("I make a POST request to {string} with payload from {string}", (page, url, filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
82
|
// Resolve file path (relative to root)
|
|
74
83
|
const fullPath = path.resolve(process.cwd(), filePath);
|
|
75
84
|
if (!fs.existsSync(fullPath)) {
|
|
@@ -78,9 +87,9 @@ const path = __importStar(require("path"));
|
|
|
78
87
|
// Read and parse JSON
|
|
79
88
|
const fileContent = fs.readFileSync(fullPath, "utf8");
|
|
80
89
|
const payload = JSON.parse(fileContent);
|
|
81
|
-
const response =
|
|
90
|
+
const response = yield page.request.post(url, {
|
|
82
91
|
data: payload,
|
|
83
92
|
headers: { "Content-Type": "application/json" },
|
|
84
93
|
});
|
|
85
94
|
state_1.apiState.setResponse(response);
|
|
86
|
-
});
|
|
95
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/backend/api/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C,eAAO,MAAM,QAAQ;4BACK,WAAW;;CAUpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expectVisible.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/expectVisible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,SAAO,iBAG/E"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.expectVisible = expectVisible;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
function expectVisible(page_1, selector_1) {
|
|
14
|
+
return __awaiter(this, arguments, void 0, function* (page, selector, timeout = 2000) {
|
|
15
|
+
const el = yield page.waitForSelector(selector, { state: 'visible', timeout });
|
|
16
|
+
if (!el)
|
|
17
|
+
throw new Error(`Element ${selector} not visible`);
|
|
18
|
+
});
|
|
8
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,QAAQ,CAAC;AAChB,OAAO,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/pageState.ts"],"names":[],"mappings":""}
|
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const test_1 = require("@playwright/test");
|
|
4
13
|
const registry_1 = require("../../core/registry");
|
|
5
14
|
// URL Check
|
|
6
|
-
(0, registry_1.Step)("I expect the url to be {string}",
|
|
7
|
-
|
|
8
|
-
});
|
|
15
|
+
(0, registry_1.Step)("I expect the url to be {string}", (page, url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
yield (0, test_1.expect)(page).toHaveURL(url);
|
|
17
|
+
}));
|
|
9
18
|
// Partial URL Check
|
|
10
|
-
(0, registry_1.Step)("I expect the url to contain {string}",
|
|
19
|
+
(0, registry_1.Step)("I expect the url to contain {string}", (page, part) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
20
|
// We use a RegExp to allow partial matching safely
|
|
12
|
-
|
|
13
|
-
});
|
|
21
|
+
yield (0, test_1.expect)(page).toHaveURL(new RegExp(part));
|
|
22
|
+
}));
|
|
14
23
|
// Title Check
|
|
15
|
-
(0, registry_1.Step)("I expect the title to be {string}",
|
|
16
|
-
|
|
17
|
-
});
|
|
24
|
+
(0, registry_1.Step)("I expect the title to be {string}", (page, title) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
yield (0, test_1.expect)(page).toHaveTitle(title);
|
|
26
|
+
}));
|
|
18
27
|
// Partial Title Check
|
|
19
|
-
(0, registry_1.Step)("I expect the title to contain {string}",
|
|
20
|
-
|
|
21
|
-
});
|
|
28
|
+
(0, registry_1.Step)("I expect the title to contain {string}", (page, titlePart) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
yield (0, test_1.expect)(page).toHaveTitle(new RegExp(titlePart));
|
|
30
|
+
}));
|
|
22
31
|
// Screenshot Match (Visual Regression)
|
|
23
|
-
(0, registry_1.Step)("I expect the page screenshot to match {string}",
|
|
24
|
-
|
|
25
|
-
});
|
|
32
|
+
(0, registry_1.Step)("I expect the page screenshot to match {string}", (page, filename) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
yield (0, test_1.expect)(page).toHaveScreenshot(filename);
|
|
34
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/text.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const test_1 = require("@playwright/test");
|
|
4
13
|
const registry_1 = require("../../core/registry");
|
|
5
14
|
// Exact text match
|
|
6
|
-
(0, registry_1.Step)("I expect {string} to have text {string}",
|
|
7
|
-
|
|
8
|
-
});
|
|
15
|
+
(0, registry_1.Step)("I expect {string} to have text {string}", (page, selector, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
yield (0, test_1.expect)(page.locator(selector)).toHaveText(text);
|
|
17
|
+
}));
|
|
9
18
|
// Partial text match (contains)
|
|
10
|
-
(0, registry_1.Step)("I expect {string} to contain text {string}",
|
|
11
|
-
|
|
12
|
-
});
|
|
19
|
+
(0, registry_1.Step)("I expect {string} to contain text {string}", (page, selector, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
yield (0, test_1.expect)(page.locator(selector)).toContainText(text);
|
|
21
|
+
}));
|
|
13
22
|
// Check input value (for form fields)
|
|
14
|
-
(0, registry_1.Step)("I expect {string} to have value {string}",
|
|
15
|
-
|
|
16
|
-
});
|
|
23
|
+
(0, registry_1.Step)("I expect {string} to have value {string}", (page, selector, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
yield (0, test_1.expect)(page.locator(selector)).toHaveValue(value);
|
|
25
|
+
}));
|
|
17
26
|
// Check an attribute (e.g., class, href, src)
|
|
18
|
-
(0, registry_1.Step)("I expect {string} to have attribute {string} with value {string}",
|
|
19
|
-
|
|
20
|
-
});
|
|
27
|
+
(0, registry_1.Step)("I expect {string} to have attribute {string} with value {string}", (page, selector, attr, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
yield (0, test_1.expect)(page.locator(selector)).toHaveAttribute(attr, value);
|
|
29
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/visibility.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const test_1 = require("@playwright/test");
|
|
4
13
|
const registry_1 = require("../../core/registry");
|
|
5
14
|
// Check if element exists and is visible
|
|
6
|
-
(0, registry_1.Step)("I expect {string} to be visible",
|
|
7
|
-
|
|
8
|
-
});
|
|
15
|
+
(0, registry_1.Step)("I expect {string} to be visible", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
yield (0, test_1.expect)(page.locator(selector)).toBeVisible();
|
|
17
|
+
}));
|
|
9
18
|
// Check if element is hidden (or doesn't exist)
|
|
10
|
-
(0, registry_1.Step)("I expect {string} to be hidden",
|
|
11
|
-
|
|
12
|
-
});
|
|
19
|
+
(0, registry_1.Step)("I expect {string} to be hidden", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
yield (0, test_1.expect)(page.locator(selector)).toBeHidden();
|
|
21
|
+
}));
|
|
13
22
|
// Check if element is enabled (clickable)
|
|
14
|
-
(0, registry_1.Step)("I expect {string} to be enabled",
|
|
15
|
-
|
|
16
|
-
});
|
|
23
|
+
(0, registry_1.Step)("I expect {string} to be enabled", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
yield (0, test_1.expect)(page.locator(selector)).toBeEnabled();
|
|
25
|
+
}));
|
|
17
26
|
// Check if element is disabled
|
|
18
|
-
(0, registry_1.Step)("I expect {string} to be disabled",
|
|
19
|
-
|
|
20
|
-
});
|
|
27
|
+
(0, registry_1.Step)("I expect {string} to be disabled", (page, selector) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
yield (0, test_1.expect)(page.locator(selector)).toBeDisabled();
|
|
29
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/backend/auth/index.ts"],"names":[],"mappings":""}
|