pomwright 1.5.0 → 2.0.0
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/CHANGELOG.md +36 -0
- package/README.md +5 -5
- package/dist/index.d.mts +91 -989
- package/dist/index.d.ts +91 -989
- package/dist/index.js +627 -1887
- package/dist/index.mjs +633 -1888
- package/package.json +9 -11
- package/AGENTS.md +0 -37
- package/docs/v1/BaseApi-explanation.md +0 -63
- package/docs/v1/BasePage-explanation.md +0 -96
- package/docs/v1/LocatorSchema-explanation.md +0 -271
- package/docs/v1/LocatorSchemaPath-explanation.md +0 -165
- package/docs/v1/PlaywrightReportLogger-explanation.md +0 -56
- package/docs/v1/get-locator-methods-explanation.md +0 -250
- package/docs/v1/intro-to-using-pomwright.md +0 -899
- package/docs/v1/sessionStorage-methods-explanation.md +0 -38
- package/docs/v1/tips-folder-structure.md +0 -38
- package/docs/v1-to-v2-migration/bridge-migration-guide.md +0 -159
- package/docs/v1-to-v2-migration/direct-migration-guide.md +0 -238
- package/docs/v1-to-v2-migration/v1-to-v2-comparison.md +0 -547
- package/docs/v2/PageObject.md +0 -293
- package/docs/v2/composing-locator-modules.md +0 -93
- package/docs/v2/locator-registry.md +0 -693
- package/docs/v2/logging.md +0 -168
- package/docs/v2/overview.md +0 -515
- package/docs/v2/session-storage.md +0 -160
- package/index.ts +0 -75
- package/intTestV2/.env +0 -0
- package/intTestV2/fixtures/testApp.fixtures.ts +0 -43
- package/intTestV2/package.json +0 -22
- package/intTestV2/page-object-models/testApp/pages/iframe/iframe.locatorSchema.ts +0 -24
- package/intTestV2/page-object-models/testApp/pages/iframe/iframe.page.ts +0 -17
- package/intTestV2/page-object-models/testApp/pages/testPage.locatorSchema.ts +0 -32
- package/intTestV2/page-object-models/testApp/pages/testPage.page.ts +0 -119
- package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.locatorSchema.ts +0 -29
- package/intTestV2/page-object-models/testApp/pages/testPath/[color]/color.page.ts +0 -48
- package/intTestV2/page-object-models/testApp/pages/testPath/testPath.locatorSchema.ts +0 -9
- package/intTestV2/page-object-models/testApp/pages/testPath/testPath.page.ts +0 -23
- package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.locatorSchema.ts +0 -114
- package/intTestV2/page-object-models/testApp/pages/testfilters/testfilters.page.ts +0 -23
- package/intTestV2/page-object-models/testApp/testApp.base.ts +0 -20
- package/intTestV2/playwright.config.ts +0 -54
- package/intTestV2/server.js +0 -216
- package/intTestV2/test-data/staticPage/index.html +0 -280
- package/intTestV2/test-data/staticPage/w3images/avatar2.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar3.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar5.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/avatar6.png +0 -0
- package/intTestV2/test-data/staticPage/w3images/forest.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/lights.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/mountains.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/nature.jpg +0 -0
- package/intTestV2/test-data/staticPage/w3images/snow.jpg +0 -0
- package/intTestV2/tests/locatorRegistry/add/add.describe.spec.ts +0 -54
- package/intTestV2/tests/locatorRegistry/add/add.filter.spec.ts +0 -143
- package/intTestV2/tests/locatorRegistry/add/add.frameLocator.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByAltText.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getById.spec.ts +0 -45
- package/intTestV2/tests/locatorRegistry/add/add.getByLabel.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByPlaceholder.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByRole.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByTestId.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByText.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.getByTitle.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.locator.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/add/add.reuseExisting.spec.ts +0 -66
- package/intTestV2/tests/locatorRegistry/add/add.reuseReusable.spec.ts +0 -311
- package/intTestV2/tests/locatorRegistry/add/add.spec.ts +0 -159
- package/intTestV2/tests/locatorRegistry/filter.cycle.spec.ts +0 -39
- package/intTestV2/tests/locatorRegistry/getLocator/getLocator.spec.ts +0 -253
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.clearSteps.spec.ts +0 -105
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.describe.spec.ts +0 -23
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.filter.spec.ts +0 -368
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getLocator.spec.ts +0 -56
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.getNestedLocator.spec.ts +0 -175
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.nth.spec.ts +0 -60
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.remove.spec.ts +0 -32
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.replace.spec.ts +0 -24
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.spec.ts +0 -110
- package/intTestV2/tests/locatorRegistry/getLocatorSchema/getLocatorSchema.update.spec.ts +0 -322
- package/intTestV2/tests/locatorRegistry/getNestedLocator/getNestedLocator.spec.ts +0 -412
- package/intTestV2/tests/locatorRegistry/registry/registry.binding.spec.ts +0 -50
- package/intTestV2/tests/locatorRegistry/validation/validation.locatorSchemaPath.spec.ts +0 -115
- package/intTestV2/tests/locatorRegistry/validation/validation.sub-path.spec.ts +0 -45
- package/intTestV2/tests/step/step.spec.ts +0 -49
- package/intTestV2/tests/testApp/color.spec.ts +0 -15
- package/intTestV2/tests/testApp/iframe.spec.ts +0 -57
- package/intTestV2/tests/testApp/testFilters.spec.ts +0 -24
- package/intTestV2/tests/testApp/testPage.spec.ts +0 -161
- package/intTestV2/tests/testApp/testPath.spec.ts +0 -18
- package/pack-build.sh +0 -11
- package/pack-test-v2.sh +0 -36
- package/playwright.base.ts +0 -42
- package/skills/README.md +0 -56
- package/skills/pomwright-v1-5-bridge-migration/SKILL.md +0 -40
- package/skills/pomwright-v1-5-bridge-migration/references/call-site-migration.md +0 -178
- package/skills/pomwright-v1-5-bridge-migration/references/schema-translation.md +0 -183
- package/skills/pomwright-v2-migration/SKILL.md +0 -63
- package/skills/pomwright-v2-migration/references/call-site-migration.md +0 -265
- package/skills/pomwright-v2-migration/references/class-migration.md +0 -266
- package/skills/pomwright-v2-migration/references/fixture-and-helpers.md +0 -423
- package/skills/pomwright-v2-migration/references/locator-registration.md +0 -344
- package/srcV2/fixture/base.fixtures.ts +0 -23
- package/srcV2/helpers/navigation.ts +0 -153
- package/srcV2/helpers/playwrightReportLogger.ts +0 -196
- package/srcV2/helpers/sessionStorage.ts +0 -251
- package/srcV2/helpers/stepDecorator.ts +0 -106
- package/srcV2/locators/index.ts +0 -15
- package/srcV2/locators/locatorQueryBuilder.ts +0 -427
- package/srcV2/locators/locatorRegistrationBuilder.ts +0 -558
- package/srcV2/locators/locatorRegistry.ts +0 -541
- package/srcV2/locators/locatorUpdateBuilder.ts +0 -602
- package/srcV2/locators/reusableLocatorBuilder.ts +0 -200
- package/srcV2/locators/types.ts +0 -256
- package/srcV2/locators/utils.ts +0 -309
- package/srcV2/locators/v1SchemaTranslator.ts +0 -178
- package/srcV2/pageObject.ts +0 -105
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# SessionStorage (v2)
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
`SessionStorage` is a helper for setting, reading, and clearing `window.sessionStorage` in Playwright tests. It provides:
|
|
6
|
-
|
|
7
|
-
- Step-wrapped operations using `test.step`.
|
|
8
|
-
- Optional waiting for a navigation context (`waitForContext`).
|
|
9
|
-
- A queueing API for setting data on the next navigation.
|
|
10
|
-
|
|
11
|
-
It is available via `PageObject.sessionStorage` or direct instantiation.
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Constructor
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { SessionStorage } from "pomwright";
|
|
19
|
-
|
|
20
|
-
const storage = new SessionStorage(page, { label: "LoginPage" });
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Options
|
|
24
|
-
|
|
25
|
-
- `label?: string` – optional prefix for step titles.
|
|
26
|
-
|
|
27
|
-
Step titles are generated as:
|
|
28
|
-
|
|
29
|
-
```html
|
|
30
|
-
<label>.SessionStorage.<method>:
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## Methods
|
|
36
|
-
|
|
37
|
-
### `set(states, options?)`
|
|
38
|
-
|
|
39
|
-
Writes key/value pairs to session storage. Optionally reloads the page after writing and/or waits for a usable context.
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
await storage.set({ token: "abc", theme: "dark" }, { reload: true });
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
#### **Options**
|
|
46
|
-
|
|
47
|
-
- `reload?: boolean` – reload the page after setting values.
|
|
48
|
-
- `waitForContext?: boolean` – wait for a main-frame execution context if not available.
|
|
49
|
-
|
|
50
|
-
If `waitForContext` is not provided and no context exists, `set` throws.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
### `setOnNextNavigation(states)`
|
|
55
|
-
|
|
56
|
-
Queues data for the next main-frame navigation. Multiple calls merge state until navigation occurs.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
await storage.setOnNextNavigation({ theme: "dark" });
|
|
60
|
-
await storage.setOnNextNavigation({ token: "abc" });
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Behavior:
|
|
64
|
-
|
|
65
|
-
- Uses a single `framenavigated` listener for the main frame.
|
|
66
|
-
- Flushes queued states after the next navigation.
|
|
67
|
-
- Clears the queue after writing.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
### `get(keys?, options?)`
|
|
72
|
-
|
|
73
|
-
Reads session storage values.
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
const all = await storage.get();
|
|
77
|
-
const subset = await storage.get(["token", "theme"]);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### **Options**
|
|
81
|
-
|
|
82
|
-
- `waitForContext?: boolean` – wait for a main-frame execution context if not available.
|
|
83
|
-
|
|
84
|
-
If `waitForContext` is not provided and no context exists, `get` throws.
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
### `clear(keysOrOptions?, options?)`
|
|
89
|
-
|
|
90
|
-
Clears session storage. You can clear all entries or a subset of keys.
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
await storage.clear();
|
|
94
|
-
await storage.clear(["token", "theme"]);
|
|
95
|
-
await storage.clear("token");
|
|
96
|
-
await storage.clear({ waitForContext: true });
|
|
97
|
-
await storage.clear(["token"], { waitForContext: true });
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
#### **Options**
|
|
101
|
-
|
|
102
|
-
- `waitForContext?: boolean` – wait for a main-frame execution context if not available.
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## Using `SessionStorage` through `PageObject`
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
import { test, expect } from "./fixtures";
|
|
110
|
-
|
|
111
|
-
test("session storage via PageObject", async ({ loginPage }) => {
|
|
112
|
-
await loginPage.navigation.gotoThisPage();
|
|
113
|
-
await loginPage.sessionStorage.set({ token: "abc" }, { reload: true });
|
|
114
|
-
await loginPage.sessionStorage.setOnNextNavigation({ theme: "dark" });
|
|
115
|
-
|
|
116
|
-
const data = await loginPage.sessionStorage.get(["token", "theme"], { waitForContext: true });
|
|
117
|
-
await loginPage.sessionStorage.clear(["token"], { waitForContext: true });
|
|
118
|
-
|
|
119
|
-
expect(data.token).toBe("abc");
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Using `SessionStorage` as a fixture
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
import { test as base } from "pomwright";
|
|
129
|
-
import { SessionStorage } from "pomwright";
|
|
130
|
-
|
|
131
|
-
type Fixtures = { sessionStorage: SessionStorage };
|
|
132
|
-
|
|
133
|
-
export const test = base.extend<Fixtures>({
|
|
134
|
-
sessionStorage: async ({ page }, use) => {
|
|
135
|
-
await use(new SessionStorage(page, { label: "SessionStorage" }));
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## Context handling details
|
|
143
|
-
|
|
144
|
-
Internally, `SessionStorage` checks for a main-frame execution context by evaluating `window.sessionStorage`. If the context is missing (e.g., before initial navigation or during reloads), you can pass `waitForContext: true` to wait for `framenavigated` and re-check availability.
|
|
145
|
-
|
|
146
|
-
If you omit `waitForContext` and no context exists, the helper throws with:
|
|
147
|
-
|
|
148
|
-
```text
|
|
149
|
-
SessionStorage context is not available.
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## v1 to v2 differences
|
|
155
|
-
|
|
156
|
-
- v1 `set(states, reload: boolean)` becomes `set(states, { reload, waitForContext })`.
|
|
157
|
-
- v1 `get(keys?)` and `clear()` did not accept context options.
|
|
158
|
-
- v2 `clear` accepts optional keys and `waitForContext`.
|
|
159
|
-
|
|
160
|
-
For migration guidance, see `docs/v1-to-v2-migration`.
|
package/index.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* V1 Exports
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { type AriaRoleType, GetByMethod, type LocatorSchema } from "./src/helpers/locatorSchema.interface";
|
|
6
|
-
export { GetByMethod, type LocatorSchema, type AriaRoleType };
|
|
7
|
-
|
|
8
|
-
import { BaseApi } from "./src/api/baseApi";
|
|
9
|
-
export { BaseApi };
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
BasePage,
|
|
13
|
-
type BasePageOptions,
|
|
14
|
-
type ExtractBaseUrlType,
|
|
15
|
-
type ExtractFullUrlType,
|
|
16
|
-
type ExtractUrlPathType,
|
|
17
|
-
} from "./src/basePage";
|
|
18
|
-
export { BasePage, type BasePageOptions, type ExtractBaseUrlType, type ExtractFullUrlType, type ExtractUrlPathType };
|
|
19
|
-
|
|
20
|
-
import { GetLocatorBase, type LocatorSchemaWithoutPath } from "./src/helpers/getLocatorBase";
|
|
21
|
-
export { GetLocatorBase, type LocatorSchemaWithoutPath };
|
|
22
|
-
|
|
23
|
-
import { BasePageV1toV2 } from "./src/basePageV1toV2";
|
|
24
|
-
export { BasePageV1toV2 };
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* V2 Exports
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import {
|
|
31
|
-
type AddAccessor,
|
|
32
|
-
createRegistryWithAccessors,
|
|
33
|
-
type GetLocatorAccessor,
|
|
34
|
-
type GetLocatorSchemaAccessor,
|
|
35
|
-
type GetNestedLocatorAccessor,
|
|
36
|
-
type LocatorRegistry,
|
|
37
|
-
} from "./srcV2/locators";
|
|
38
|
-
export {
|
|
39
|
-
createRegistryWithAccessors,
|
|
40
|
-
type LocatorRegistry,
|
|
41
|
-
type AddAccessor,
|
|
42
|
-
type GetLocatorAccessor,
|
|
43
|
-
type GetLocatorSchemaAccessor,
|
|
44
|
-
type GetNestedLocatorAccessor,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
import {
|
|
48
|
-
type BaseUrlTypeFromOptions,
|
|
49
|
-
type FullUrlTypeFromOptions,
|
|
50
|
-
PageObject,
|
|
51
|
-
type UrlPathTypeFromOptions,
|
|
52
|
-
type UrlTypeOptions,
|
|
53
|
-
} from "./srcV2/pageObject";
|
|
54
|
-
export {
|
|
55
|
-
PageObject,
|
|
56
|
-
type BaseUrlTypeFromOptions,
|
|
57
|
-
type FullUrlTypeFromOptions,
|
|
58
|
-
type UrlPathTypeFromOptions,
|
|
59
|
-
type UrlTypeOptions,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
import { test } from "./srcV2/fixture/base.fixtures";
|
|
63
|
-
export { test };
|
|
64
|
-
|
|
65
|
-
import { step } from "./srcV2/helpers/stepDecorator";
|
|
66
|
-
export { step };
|
|
67
|
-
|
|
68
|
-
import type { NavigationOptions } from "./srcV2/helpers/navigation";
|
|
69
|
-
export type { NavigationOptions };
|
|
70
|
-
|
|
71
|
-
import { SessionStorage } from "./srcV2/helpers/sessionStorage";
|
|
72
|
-
export { SessionStorage };
|
|
73
|
-
|
|
74
|
-
import { type LogEntry, type LogLevel, PlaywrightReportLogger } from "./srcV2/helpers/playwrightReportLogger";
|
|
75
|
-
export { type LogEntry, type LogLevel, PlaywrightReportLogger };
|
package/intTestV2/.env
DELETED
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import IframePage from "@page-object-models-v2/testApp/pages/iframe/iframe.page";
|
|
2
|
-
import TestFilters from "@page-object-models-v2/testApp/pages/testfilters/testfilters.page";
|
|
3
|
-
import TestPage from "@page-object-models-v2/testApp/pages/testPage.page";
|
|
4
|
-
import Color from "@page-object-models-v2/testApp/pages/testPath/[color]/color.page";
|
|
5
|
-
import TestPath from "@page-object-models-v2/testApp/pages/testPath/testPath.page";
|
|
6
|
-
import { expect } from "@playwright/test";
|
|
7
|
-
import { test as base } from "pomwright";
|
|
8
|
-
|
|
9
|
-
type Fixtures = {
|
|
10
|
-
iframePage: IframePage;
|
|
11
|
-
testPage: TestPage;
|
|
12
|
-
testPath: TestPath;
|
|
13
|
-
color: Color;
|
|
14
|
-
testFilters: TestFilters;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const test = base.extend<Fixtures>({
|
|
18
|
-
iframePage: async ({ page }, use) => {
|
|
19
|
-
const iframePage = new IframePage(page);
|
|
20
|
-
await use(iframePage);
|
|
21
|
-
},
|
|
22
|
-
testPage: async ({ page }, use) => {
|
|
23
|
-
const testPage = new TestPage(page);
|
|
24
|
-
await use(testPage);
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
testPath: async ({ page }, use) => {
|
|
28
|
-
const testPath = new TestPath(page);
|
|
29
|
-
await use(testPath);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
color: async ({ page }, use) => {
|
|
33
|
-
const color = new Color(page);
|
|
34
|
-
await use(color);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
testFilters: async ({ page }, use) => {
|
|
38
|
-
const testFilters = new TestFilters(page);
|
|
39
|
-
await use(testFilters);
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export { expect, test };
|
package/intTestV2/package.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "test-v2",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"start": "node ./server.js",
|
|
8
|
-
"postinstall": "npx -y only-allow pnpm && npx playwright install-deps"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [],
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@playwright/test": "1.58.0",
|
|
13
|
-
"@types/express": "^5.0.3",
|
|
14
|
-
"@types/node": "^24.5.2",
|
|
15
|
-
"express": "^5.1.0",
|
|
16
|
-
"pomwright": "file:../pomwright-1.4.0.tgz"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"dotenv": "^17.2.2"
|
|
20
|
-
},
|
|
21
|
-
"packageManager": "pnpm@9.12.0"
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { LocatorRegistry } from "pomwright";
|
|
2
|
-
|
|
3
|
-
export type Paths =
|
|
4
|
-
| "sectionA"
|
|
5
|
-
| "sectionA.frame"
|
|
6
|
-
| "sectionA.frame.toggle"
|
|
7
|
-
| "sectionB"
|
|
8
|
-
| "sectionB.frame"
|
|
9
|
-
| "sectionB.frame.toggle"
|
|
10
|
-
| "sectionB.frame.innerFrame"
|
|
11
|
-
| "sectionB.frame.innerFrame.toggle";
|
|
12
|
-
|
|
13
|
-
export function defineLocators(locators: LocatorRegistry<Paths>) {
|
|
14
|
-
locators.add("sectionA").locator("#sectionA");
|
|
15
|
-
locators.add("sectionA.frame").frameLocator("#iframeA");
|
|
16
|
-
locators.add("sectionA.frame.toggle").getByTestId("toggle-a");
|
|
17
|
-
|
|
18
|
-
locators.add("sectionB").locator("#sectionB");
|
|
19
|
-
locators.add("sectionB.frame").frameLocator("#iframeB");
|
|
20
|
-
locators.add("sectionB.frame.toggle").getByTestId("toggle-b");
|
|
21
|
-
|
|
22
|
-
locators.add("sectionB.frame.innerFrame").frameLocator("#iframeC");
|
|
23
|
-
locators.add("sectionB.frame.innerFrame.toggle").getByTestId("toggle-c");
|
|
24
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Page } from "@playwright/test";
|
|
2
|
-
import TestApp from "../../testApp.base";
|
|
3
|
-
import { defineLocators, type Paths } from "./iframe.locatorSchema";
|
|
4
|
-
|
|
5
|
-
export default class IframePage extends TestApp<Paths> {
|
|
6
|
-
constructor(page: Page) {
|
|
7
|
-
super(page, "/iframe");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
protected defineLocators(): void {
|
|
11
|
-
defineLocators(this.locatorRegistry);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
protected pageActionsToPerformAfterNavigation(): (() => Promise<void>)[] | null {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { LocatorRegistry } from "pomwright";
|
|
2
|
-
|
|
3
|
-
export type Paths =
|
|
4
|
-
| "topMenu"
|
|
5
|
-
| "topMenu.logo"
|
|
6
|
-
| "topMenu.news"
|
|
7
|
-
| "topMenu.accountSettings"
|
|
8
|
-
| "topMenu.messages"
|
|
9
|
-
| "topMenu.notifications"
|
|
10
|
-
| "topMenu.notifications.button"
|
|
11
|
-
| "topMenu.notifications.button.countBadge"
|
|
12
|
-
| "topMenu.notifications.dropdown"
|
|
13
|
-
| "topMenu.notifications.dropdown.item"
|
|
14
|
-
| "topMenu.myAccount";
|
|
15
|
-
|
|
16
|
-
export function defineLocators(registry: LocatorRegistry<Paths>) {
|
|
17
|
-
registry.add("topMenu").locator(".w3-top");
|
|
18
|
-
|
|
19
|
-
registry.add("topMenu.logo").getByRole("link", { name: /Logo/ });
|
|
20
|
-
|
|
21
|
-
registry.add("topMenu.news").getByTitle("News");
|
|
22
|
-
registry.add("topMenu.accountSettings").getByTitle("Account Settings");
|
|
23
|
-
registry.add("topMenu.messages").getByTitle("Messages");
|
|
24
|
-
|
|
25
|
-
registry.add("topMenu.notifications").locator(".w3-dropdown-hover");
|
|
26
|
-
registry.add("topMenu.notifications.button").getByRole("button");
|
|
27
|
-
registry.add("topMenu.notifications.button.countBadge").locator(".w3-badge");
|
|
28
|
-
registry.add("topMenu.notifications.dropdown").locator(".w3-dropdown-content");
|
|
29
|
-
registry.add("topMenu.notifications.dropdown.item").locator(".w3-bar-item");
|
|
30
|
-
|
|
31
|
-
registry.add("topMenu.myAccount").getByTitle("My Account");
|
|
32
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { expect, type Page } from "@playwright/test";
|
|
2
|
-
import { step } from "pomwright";
|
|
3
|
-
import TestApp from "../testApp.base";
|
|
4
|
-
import { defineLocators, type Paths } from "./testPage.locatorSchema";
|
|
5
|
-
|
|
6
|
-
export default class TestPageV2 extends TestApp<Paths> {
|
|
7
|
-
readonly navigationActionCount = { value: 0 };
|
|
8
|
-
|
|
9
|
-
constructor(page: Page) {
|
|
10
|
-
super(page, "/");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
protected defineLocators(): void {
|
|
14
|
-
defineLocators(this.locatorRegistry);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
protected pageActionsToPerformAfterNavigation(): (() => Promise<void>)[] | null {
|
|
18
|
-
return [
|
|
19
|
-
async () => {
|
|
20
|
-
this.navigationActionCount.value += 1;
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@step
|
|
26
|
-
async stepNoArgs(): Promise<string> {
|
|
27
|
-
expect(true).toBe(true);
|
|
28
|
-
return "Hello, World!";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@step("Step with title")
|
|
32
|
-
async stepWithTitle(): Promise<string> {
|
|
33
|
-
return "Hello, World!";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@step({ box: true })
|
|
37
|
-
async stepWithOptionBox(): Promise<string> {
|
|
38
|
-
return "Hello, World!";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@step({ timeout: 1000 })
|
|
42
|
-
async stepWithOptionTimeout(): Promise<string> {
|
|
43
|
-
return "Hello, World!";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@step({
|
|
47
|
-
location: {
|
|
48
|
-
file: "intTestV2/page-object-models/testApp/with-options/pages/testPage.page.ts",
|
|
49
|
-
line: 1,
|
|
50
|
-
column: 1,
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
async stepWithOptionLocation(): Promise<string> {
|
|
54
|
-
return "Hello, World!";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@step("Step with all options", {
|
|
58
|
-
box: true,
|
|
59
|
-
timeout: 1000,
|
|
60
|
-
location: {
|
|
61
|
-
file: "intTestV2/page-object-models/testApp/with-options/pages/testPage.page.ts",
|
|
62
|
-
line: 1,
|
|
63
|
-
column: 1,
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
async stepWithTitleAndAllOptions(): Promise<string> {
|
|
67
|
-
return "Hello, World!";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@step("Step with advanced return type")
|
|
71
|
-
async stepWithAdvancedReturnType(): Promise<
|
|
72
|
-
{
|
|
73
|
-
id: string;
|
|
74
|
-
metadata: {
|
|
75
|
-
flags: Set<"alpha" | "beta">;
|
|
76
|
-
versions: Map<string, { hash: string; tags: string[] }>;
|
|
77
|
-
};
|
|
78
|
-
payload: Array<{ index: number; values: ReadonlyArray<{ key: string; value: number }> }>;
|
|
79
|
-
} & {
|
|
80
|
-
readonly status: "ready";
|
|
81
|
-
readonly startedAt: Date;
|
|
82
|
-
}
|
|
83
|
-
> {
|
|
84
|
-
return {
|
|
85
|
-
id: "fixture-id",
|
|
86
|
-
metadata: {
|
|
87
|
-
flags: new Set(["alpha", "beta"]),
|
|
88
|
-
versions: new Map([
|
|
89
|
-
["v1", { hash: "abc123", tags: ["stable", "verified"] }],
|
|
90
|
-
["v2", { hash: "def456", tags: ["next"] }],
|
|
91
|
-
]),
|
|
92
|
-
},
|
|
93
|
-
payload: [
|
|
94
|
-
{ index: 1, values: [{ key: "alpha", value: 10 }] },
|
|
95
|
-
{ index: 2, values: [{ key: "beta", value: 20 }] },
|
|
96
|
-
],
|
|
97
|
-
status: "ready",
|
|
98
|
-
startedAt: new Date(0),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@step
|
|
103
|
-
async stepWithArgs(subscriptionTitle: string, clickCount = 1): Promise<string> {
|
|
104
|
-
return `${subscriptionTitle}:${clickCount}`;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@step("Step with args and object return")
|
|
108
|
-
async stepWithArgsAndObjectReturn(
|
|
109
|
-
input: { id: string; mode?: "basic" | "advanced" },
|
|
110
|
-
retry = 0,
|
|
111
|
-
): Promise<{ ok: true; id: string; mode: "basic" | "advanced"; retry: number }> {
|
|
112
|
-
return {
|
|
113
|
-
ok: true,
|
|
114
|
-
id: input.id,
|
|
115
|
-
mode: input.mode ?? "basic",
|
|
116
|
-
retry,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { LocatorRegistry } from "pomwright";
|
|
2
|
-
|
|
3
|
-
const tableVariants = ["body.table", "body.table@hexCode"] as const;
|
|
4
|
-
|
|
5
|
-
type TableVariants = (typeof tableVariants)[number];
|
|
6
|
-
type TableChildren = "row" | "row.rowheader" | "row.cell";
|
|
7
|
-
|
|
8
|
-
export type Paths = "body" | "body.heading" | TableVariants | `${TableVariants}.${TableChildren}`;
|
|
9
|
-
|
|
10
|
-
export function defineLocators(registry: LocatorRegistry<Paths>) {
|
|
11
|
-
registry.add("body").locator("body");
|
|
12
|
-
|
|
13
|
-
registry.add("body.heading").getByRole("heading", { name: "Your Random Color is:" });
|
|
14
|
-
|
|
15
|
-
const tableLocatorMap: Array<[Paths, { name?: string }]> = [
|
|
16
|
-
["body.table", {}],
|
|
17
|
-
["body.table@hexCode", { name: "Hex Code Information" }],
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
for (const [path, { name }] of tableLocatorMap) {
|
|
21
|
-
registry.add(path).getByRole("table", name ? { name } : undefined);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (const tableVariant of tableVariants) {
|
|
25
|
-
registry.add(`${tableVariant}.row`).getByRole("row");
|
|
26
|
-
registry.add(`${tableVariant}.row.rowheader`).getByRole("rowheader");
|
|
27
|
-
registry.add(`${tableVariant}.row.cell`).getByRole("cell");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { expect, type Page, test } from "@playwright/test";
|
|
2
|
-
import TestApp from "../../../testApp.base";
|
|
3
|
-
import { defineLocators, type Paths } from "./color.locatorSchema";
|
|
4
|
-
|
|
5
|
-
export default class ColorV2 extends TestApp<Paths, { urlPathType: RegExp }> {
|
|
6
|
-
constructor(page: Page) {
|
|
7
|
-
const urlPathRegex = /\/testpath\/([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
8
|
-
super(page, urlPathRegex);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
protected defineLocators(): void {
|
|
12
|
-
defineLocators(this.locatorRegistry);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
protected pageActionsToPerformAfterNavigation(): (() => Promise<void>)[] | null {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async expectThisPage() {
|
|
20
|
-
await test.step("Expect color page", async () => {
|
|
21
|
-
await this.page.waitForURL(this.fullUrl);
|
|
22
|
-
|
|
23
|
-
const heading = this.getNestedLocator("body.heading");
|
|
24
|
-
await heading.waitFor({ state: "visible" });
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async validateColorPage() {
|
|
29
|
-
await test.step("Verify hex code", async () => {
|
|
30
|
-
const currentUrl = this.page.url();
|
|
31
|
-
const hexCode = currentUrl.split("/").pop();
|
|
32
|
-
|
|
33
|
-
await test.step("Verify hex code in table equals hex code in urlPath", async () => {
|
|
34
|
-
const hexCodeCell = this.getNestedLocator("body.table@hexCode.row.cell");
|
|
35
|
-
await expect(hexCodeCell).toContainText(`#${hexCode}`, {
|
|
36
|
-
useInnerText: true,
|
|
37
|
-
ignoreCase: true,
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await test.step("Verify hex code in urlPath is the page background color", async () => {
|
|
42
|
-
const body = this.getNestedLocator("body");
|
|
43
|
-
const bgColor = await body.getAttribute("style");
|
|
44
|
-
expect(bgColor).toContain(`background-color: #${hexCode}`);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LocatorRegistry } from "pomwright";
|
|
2
|
-
|
|
3
|
-
export type Paths = "body" | "body.link@color";
|
|
4
|
-
|
|
5
|
-
export function defineLocators(registry: LocatorRegistry<Paths>) {
|
|
6
|
-
registry.add("body").locator("body");
|
|
7
|
-
|
|
8
|
-
registry.add("body.link@color").getByRole("link", { name: "Random Color Link" });
|
|
9
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Page, test } from "@playwright/test";
|
|
2
|
-
import TestApp from "../../testApp.base";
|
|
3
|
-
import { defineLocators, type Paths } from "./testPath.locatorSchema";
|
|
4
|
-
|
|
5
|
-
export default class TestPathV2 extends TestApp<Paths> {
|
|
6
|
-
constructor(page: Page) {
|
|
7
|
-
super(page, "/testpath");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
protected defineLocators(): void {
|
|
11
|
-
defineLocators(this.locatorRegistry);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
protected pageActionsToPerformAfterNavigation(): (() => Promise<void>)[] | null {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async expectThisPage() {
|
|
19
|
-
await test.step(`Expect Page: ${this.urlPath}`, async () => {
|
|
20
|
-
await this.page.waitForURL(this.fullUrl);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|