@trackunit/iris-app-playwright 0.2.120-alpha-f04589101e3.0 → 0.2.121
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/README.md +5 -7
- package/migrations.json +1 -7
- package/package.json +1 -1
- package/src/fixtures/acceptTerms.d.ts +33 -0
- package/src/fixtures/acceptTerms.js +109 -0
- package/src/fixtures/baseTest.d.ts +1 -2
- package/src/fixtures/baseTest.js +1 -3
- package/src/fixtures/irisApp.fixture.d.ts +2 -52
- package/src/fixtures/irisApp.fixture.js +3 -61
- package/src/fixtures/login.fixture.d.ts +63 -7
- package/src/fixtures/login.fixture.js +173 -48
- package/src/generators/playwright-configuration/files/root/playwright/tests/app.spec.ts__tmpl__ +1 -1
- package/migrations/entry.js.map +0 -1
- package/migrations/v1-0-0/await-iris-app.js +0 -223
- package/migrations/v1-0-0/await-iris-app.js.map +0 -1
- package/src/credentials/guards.js.map +0 -1
- package/src/credentials/keys.js.map +0 -1
- package/src/credentials/resolveE2EPassword.js.map +0 -1
- package/src/fixtures/baseTest.js.map +0 -1
- package/src/fixtures/describe.js.map +0 -1
- package/src/fixtures/featureFlags.fixture.js.map +0 -1
- package/src/fixtures/harRecording.fixture.js.map +0 -1
- package/src/fixtures/hostReadiness.js.map +0 -1
- package/src/fixtures/hydrateStorageState.js.map +0 -1
- package/src/fixtures/irisApp.fixture.js.map +0 -1
- package/src/fixtures/localDevMode.fixture.js.map +0 -1
- package/src/fixtures/login.fixture.js.map +0 -1
- package/src/fixtures/loginCacheKey.js.map +0 -1
- package/src/fixtures/resolveCredentials.js.map +0 -1
- package/src/fixtures/withTimeout.js.map +0 -1
- package/src/generators/playwright-configuration/generator.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/plugins/createLogFile.js.map +0 -1
- package/src/plugins/defaultPlaywrightConfig.js.map +0 -1
- package/src/plugins/harRecordingPath.js.map +0 -1
- package/src/plugins/logsReporter.js.map +0 -1
- package/src/plugins/nxPreset.js.map +0 -1
- package/src/plugins/redactHar.js.map +0 -1
- package/src/plugins/redactPatterns.js.map +0 -1
- package/src/plugins/redactSensitive.js.map +0 -1
- package/src/plugins/redactTrace.js.map +0 -1
- package/src/plugins/scanArtifactsForSecrets.js.map +0 -1
- package/src/plugins/setupPlugins.js.map +0 -1
- package/src/plugins/writeFileWithPrettier.js.map +0 -1
- package/src/support.js.map +0 -1
- package/src/utils/Codeowner.js.map +0 -1
- package/src/utils/fileNameBuilder.js.map +0 -1
- package/src/utils/fileUpdater.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ describe("My Feature", () => {
|
|
|
63
63
|
test("user can log in", async ({ page, login, irisApp }) => {
|
|
64
64
|
await login();
|
|
65
65
|
|
|
66
|
-
const app =
|
|
66
|
+
const app = irisApp();
|
|
67
67
|
await expect(app.getByTestId("app-content")).toBeVisible();
|
|
68
68
|
});
|
|
69
69
|
});
|
|
@@ -110,15 +110,13 @@ You don't have to do anything to opt in — the cache is wired up automatically.
|
|
|
110
110
|
|
|
111
111
|
### `irisApp`
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Returns a `FrameLocator` for an Iris app iframe.
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
|
-
irisApp(options?: IrisAppOptions):
|
|
116
|
+
irisApp(options?: IrisAppOptions): FrameLocator
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Defaults to
|
|
120
|
-
|
|
121
|
-
Before 1.0.0 `irisApp()` returned the `FrameLocator` synchronously. The `v1-0-0-await-iris-app` migration rewrites existing `irisApp(...)` calls to `await irisApp(...)` and widens local `() => FrameLocator` types for the fixture; run it with `nx g @trackunit/migrations:migrate` followed by `nx g @trackunit/migrations:run-migrations`. Calls outside an async function are reported for manual review.
|
|
119
|
+
Defaults to `iframe[data-testid="app-iframe"]`. Pass `testId` to target a different iframe.
|
|
122
120
|
|
|
123
121
|
### `storybookPreview`
|
|
124
122
|
|
|
@@ -214,7 +212,7 @@ Use the `describe` wrapper exported from `@trackunit/iris-app-playwright/support
|
|
|
214
212
|
| Cypress API | Playwright equivalent |
|
|
215
213
|
|---|---|
|
|
216
214
|
| `cy.login("auth")` | `await login()` |
|
|
217
|
-
| `cy.enterIrisApp()` | `
|
|
215
|
+
| `cy.enterIrisApp()` | `irisApp()` returns `FrameLocator` |
|
|
218
216
|
| `cy.enterStorybookPreview()` | `storybookPreview()` returns `FrameLocator` |
|
|
219
217
|
| `cy.getValidateFeatureFlags()` | `getValidateFeatureFlags()` |
|
|
220
218
|
| `cy.configCat("flag")` | `await configCat("flag")` |
|
package/migrations.json
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"v1-0-0-await-iris-app": {
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "irisApp() now resolves to Promise<FrameLocator> in every environment. Rewrite irisApp(...) calls inside async functions to await irisApp(...), parenthesised when the call is the receiver of a member access, and report calls outside async functions for manual review.",
|
|
6
|
-
"implementation": "./migrations/v1-0-0/await-iris-app"
|
|
7
|
-
}
|
|
8
|
-
}
|
|
2
|
+
"generators": {}
|
|
9
3
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Route Manager's `TermsGate` redirects to while the signed-in user has not accepted the terms. */
|
|
2
|
+
export declare const TERMS_ROUTE = "/terms";
|
|
3
|
+
/** Upper bound on documents to click through, so an unexpected flow fails instead of looping forever. */
|
|
4
|
+
export declare const MAX_TERMS_DOCUMENTS = 20;
|
|
5
|
+
/** Whether `url` is the page `TermsGate` redirects to, not the review-terms preferences page. */
|
|
6
|
+
export declare const isTermsRoute: (url: string) => boolean;
|
|
7
|
+
export type TermsButton = {
|
|
8
|
+
isVisible: () => Promise<boolean>;
|
|
9
|
+
click: (options?: {
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type TermsPromptPage = {
|
|
14
|
+
url: () => string;
|
|
15
|
+
waitForURL: (predicate: (url: URL) => boolean, options?: {
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}) => Promise<unknown>;
|
|
18
|
+
getByTestId: (testId: string) => TermsButton;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Clicks through Manager's terms flow when the signed-in user is being asked to accept.
|
|
22
|
+
*
|
|
23
|
+
* Root cause (GLU-2632): the feature-branch prompt is not a finished login, and waiting
|
|
24
|
+
* never clicks it. Success is leaving `/terms` — the app reloads to `/` and discards the
|
|
25
|
+
* mutation body. Staying on `/terms` until `deadline` is {@link HostNeverBecameReadyError},
|
|
26
|
+
* not a generic "still on /terms" failure.
|
|
27
|
+
*/
|
|
28
|
+
export declare const acceptTermsWithinBudget: ({ page, now, sleep: pause, deadline, }: {
|
|
29
|
+
page: TermsPromptPage;
|
|
30
|
+
now: () => number;
|
|
31
|
+
sleep: (ms: number) => Promise<void>;
|
|
32
|
+
deadline: number;
|
|
33
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.acceptTermsWithinBudget = exports.isTermsRoute = exports.MAX_TERMS_DOCUMENTS = exports.TERMS_ROUTE = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
5
|
+
const hostReadiness_1 = require("./hostReadiness");
|
|
6
|
+
/** Route Manager's `TermsGate` redirects to while the signed-in user has not accepted the terms. */
|
|
7
|
+
exports.TERMS_ROUTE = "/terms";
|
|
8
|
+
/** Upper bound on documents to click through, so an unexpected flow fails instead of looping forever. */
|
|
9
|
+
exports.MAX_TERMS_DOCUMENTS = 20;
|
|
10
|
+
/** Gap between checks while the terms buttons are not on screen yet. */
|
|
11
|
+
const TERMS_POLL_INTERVAL_MS = 1000;
|
|
12
|
+
const ACCEPT_BUTTON_TEST_ID = "terms-accept-document";
|
|
13
|
+
const START_BUTTON_TEST_ID = "terms-start-using-manager";
|
|
14
|
+
const isPlaywrightTimeout = (error) => error instanceof test_1.errors.TimeoutError;
|
|
15
|
+
/** Whether `url` is the page `TermsGate` redirects to, not the review-terms preferences page. */
|
|
16
|
+
const isTermsRoute = (url) => {
|
|
17
|
+
try {
|
|
18
|
+
return new URL(url).pathname === exports.TERMS_ROUTE;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.isTermsRoute = isTermsRoute;
|
|
25
|
+
const pathnameOf = (url) => {
|
|
26
|
+
try {
|
|
27
|
+
return new URL(url).pathname;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const waitForPathname = async (page, matches, now, deadline) => {
|
|
34
|
+
if (matches(pathnameOf(page.url()) ?? "")) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const remaining = deadline - now();
|
|
38
|
+
if (remaining <= 0) {
|
|
39
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
await page.waitForURL(url => matches(url.pathname), { timeout: remaining });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (!isPlaywrightTimeout(error)) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
throw new hostReadiness_1.HostNeverBecameReadyError(error);
|
|
49
|
+
}
|
|
50
|
+
if (!matches(pathnameOf(page.url()) ?? "")) {
|
|
51
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Clicks through Manager's terms flow when the signed-in user is being asked to accept.
|
|
56
|
+
*
|
|
57
|
+
* Root cause (GLU-2632): the feature-branch prompt is not a finished login, and waiting
|
|
58
|
+
* never clicks it. Success is leaving `/terms` — the app reloads to `/` and discards the
|
|
59
|
+
* mutation body. Staying on `/terms` until `deadline` is {@link HostNeverBecameReadyError},
|
|
60
|
+
* not a generic "still on /terms" failure.
|
|
61
|
+
*/
|
|
62
|
+
const acceptTermsWithinBudget = async ({ page, now, sleep: pause, deadline, }) => {
|
|
63
|
+
if (!(0, exports.isTermsRoute)(page.url())) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let documents = 0;
|
|
67
|
+
const clickWithinBudget = async (button) => {
|
|
68
|
+
const remaining = deadline - now();
|
|
69
|
+
if (remaining <= 0) {
|
|
70
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
await button.click({ timeout: remaining });
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (!isPlaywrightTimeout(error)) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
throw new hostReadiness_1.HostNeverBecameReadyError(error);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
for (;;) {
|
|
83
|
+
if (now() >= deadline) {
|
|
84
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
85
|
+
}
|
|
86
|
+
const startUsingManager = page.getByTestId(START_BUTTON_TEST_ID);
|
|
87
|
+
if (await startUsingManager.isVisible()) {
|
|
88
|
+
await clickWithinBudget(startUsingManager);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
const acceptDocument = page.getByTestId(ACCEPT_BUTTON_TEST_ID);
|
|
92
|
+
if (await acceptDocument.isVisible()) {
|
|
93
|
+
if (documents >= exports.MAX_TERMS_DOCUMENTS) {
|
|
94
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
95
|
+
}
|
|
96
|
+
await clickWithinBudget(acceptDocument);
|
|
97
|
+
documents += 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const remaining = deadline - now();
|
|
101
|
+
if (remaining <= 0) {
|
|
102
|
+
throw new hostReadiness_1.HostNeverBecameReadyError();
|
|
103
|
+
}
|
|
104
|
+
await pause(Math.min(TERMS_POLL_INTERVAL_MS, remaining));
|
|
105
|
+
}
|
|
106
|
+
await waitForPathname(page, pathname => pathname !== exports.TERMS_ROUTE, now, deadline);
|
|
107
|
+
};
|
|
108
|
+
exports.acceptTermsWithinBudget = acceptTermsWithinBudget;
|
|
109
|
+
//# sourceMappingURL=acceptTerms.js.map
|
|
@@ -2,7 +2,6 @@ import { expect } from "@playwright/test";
|
|
|
2
2
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./login.fixture").TrackunitBaseFixtures & import("./irisApp.fixture").IrisAppFixtures & import("./featureFlags.fixture").FeatureFlagFixtures & import("./localDevMode.fixture").LocalDevModeFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & import("./login.fixture").LoginCacheFixtures>;
|
|
3
3
|
export { expect };
|
|
4
4
|
export type { FeatureFlag, FeatureFlagFixtures } from "./featureFlags.fixture";
|
|
5
|
-
export {
|
|
6
|
-
export type { CreateIrisAppOptions, IrisAppFixtures, IrisAppOptions, StorybookPreviewOptions } from "./irisApp.fixture";
|
|
5
|
+
export type { IrisAppFixtures, IrisAppOptions, StorybookPreviewOptions } from "./irisApp.fixture";
|
|
7
6
|
export type { LocalDevModeFixtures } from "./localDevMode.fixture";
|
|
8
7
|
export type { AuthCredentials, LoginOptions, TrackunitBaseFixtures } from "./login.fixture";
|
package/src/fixtures/baseTest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.expect = exports.test = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
5
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
|
|
6
6
|
const featureFlags_fixture_1 = require("./featureFlags.fixture");
|
|
@@ -9,6 +9,4 @@ const irisApp_fixture_1 = require("./irisApp.fixture");
|
|
|
9
9
|
const localDevMode_fixture_1 = require("./localDevMode.fixture");
|
|
10
10
|
const login_fixture_1 = require("./login.fixture");
|
|
11
11
|
exports.test = (0, test_1.mergeTests)(harRecording_fixture_1.test, login_fixture_1.test, irisApp_fixture_1.test, featureFlags_fixture_1.test, localDevMode_fixture_1.test);
|
|
12
|
-
var irisApp_fixture_2 = require("./irisApp.fixture");
|
|
13
|
-
Object.defineProperty(exports, "createIrisApp", { enumerable: true, get: function () { return irisApp_fixture_2.createIrisApp; } });
|
|
14
12
|
//# sourceMappingURL=baseTest.js.map
|
|
@@ -6,60 +6,10 @@ export interface StorybookPreviewOptions {
|
|
|
6
6
|
/** Storybook preview iframe element id. Defaults to `storybook-preview-iframe`. */
|
|
7
7
|
iframeId?: string;
|
|
8
8
|
}
|
|
9
|
-
type IrisAppAttachWait = {
|
|
10
|
-
waitFor: (options?: {
|
|
11
|
-
state?: "attached";
|
|
12
|
-
timeout?: number;
|
|
13
|
-
}) => Promise<void>;
|
|
14
|
-
first?: () => IrisAppAttachWait;
|
|
15
|
-
};
|
|
16
|
-
type IrisAppFramePage = {
|
|
17
|
-
locator: (selector: string) => IrisAppAttachWait;
|
|
18
|
-
frameLocator: (selector: string) => FrameLocator;
|
|
19
|
-
};
|
|
20
|
-
type IrisAppTestTimeout = {
|
|
21
|
-
timeout: number;
|
|
22
|
-
setTimeout: (timeout: number) => void;
|
|
23
|
-
};
|
|
24
9
|
export interface IrisAppFixtures {
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* requested iframe is attached first. A missing iframe rejects with
|
|
28
|
-
* {@link HostNeverBecameReadyError} (`host never became ready`) before the
|
|
29
|
-
* locator is returned. Other hosts resolve immediately, without waiting.
|
|
30
|
-
* Callers await this in every environment. Defaults to `data-testid="app-iframe"`
|
|
31
|
-
* and the first match, because a page can render more than one app iframe.
|
|
32
|
-
*/
|
|
33
|
-
irisApp: (options?: IrisAppOptions) => Promise<FrameLocator>;
|
|
10
|
+
/** Returns a FrameLocator for the iris app iframe. Defaults to `data-testid="app-iframe"`. */
|
|
11
|
+
irisApp: (options?: IrisAppOptions) => FrameLocator;
|
|
34
12
|
/** Returns a FrameLocator for the Storybook preview iframe. Defaults to `id="storybook-preview-iframe"`. */
|
|
35
13
|
storybookPreview: (options?: StorybookPreviewOptions) => FrameLocator;
|
|
36
14
|
}
|
|
37
|
-
export type CreateIrisAppOptions = {
|
|
38
|
-
/** When false, do not call `.first()`. Default is true. */
|
|
39
|
-
first?: boolean;
|
|
40
|
-
/** Replaces the default `iframe[data-testid="..."]` selector. */
|
|
41
|
-
selector?: (testId?: string) => string;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Builds the `irisApp` accessor.
|
|
45
|
-
*
|
|
46
|
-
* Root cause (GLU-2633): `page.frameLocator` does not wait for the iframe, and
|
|
47
|
-
* `locator.waitFor` rejects with Playwright's `TimeoutError` when the
|
|
48
|
-
* feature-branch iframe never attaches. The job then reports that wait
|
|
49
|
-
* timeout, or the caller's later page assertion, instead of the host never
|
|
50
|
-
* becoming ready. The accessor waits until the requested iframe is attached.
|
|
51
|
-
* Only that Playwright timeout is rethrown as {@link HostNeverBecameReadyError}
|
|
52
|
-
* before the locator is returned. Any other attach failure is rethrown
|
|
53
|
-
* unchanged. Once the iframe is attached, the locator is returned and later
|
|
54
|
-
* page assertions belong to the caller. A host that is not a feature branch
|
|
55
|
-
* returns the locator immediately and does not extend the test timeout.
|
|
56
|
-
* Playwright's own test timeout would otherwise expire before this wait, so
|
|
57
|
-
* the running test's timeout grows by {@link MAIN_MENU_READY_TIMEOUT_MS} once
|
|
58
|
-
* per test, before the first feature-branch wait. Later `irisApp()` calls in
|
|
59
|
-
* that test do not add the budget again. An unlimited timeout (`0`) is left
|
|
60
|
-
* untouched. The accessor is always a promise, so `const app = await irisApp()`
|
|
61
|
-
* and `await irisApp().then(...)` are the same shape when the gate is off.
|
|
62
|
-
*/
|
|
63
|
-
export declare const createIrisApp: (page: IrisAppFramePage, testInfo?: IrisAppTestTimeout, options?: CreateIrisAppOptions) => IrisAppFixtures["irisApp"];
|
|
64
15
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & IrisAppFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
65
|
-
export {};
|
|
@@ -1,68 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.test =
|
|
3
|
+
exports.test = void 0;
|
|
4
4
|
const test_1 = require("@playwright/test");
|
|
5
|
-
const hostReadiness_1 = require("./hostReadiness");
|
|
6
|
-
const login_fixture_1 = require("./login.fixture");
|
|
7
|
-
const irisAppFrameSelector = (testId) => `iframe[data-testid="${testId ?? "app-iframe"}"]`;
|
|
8
|
-
const firstMatch = (value, useFirst) => useFirst && value.first !== undefined ? value.first() : value;
|
|
9
|
-
/**
|
|
10
|
-
* Builds the `irisApp` accessor.
|
|
11
|
-
*
|
|
12
|
-
* Root cause (GLU-2633): `page.frameLocator` does not wait for the iframe, and
|
|
13
|
-
* `locator.waitFor` rejects with Playwright's `TimeoutError` when the
|
|
14
|
-
* feature-branch iframe never attaches. The job then reports that wait
|
|
15
|
-
* timeout, or the caller's later page assertion, instead of the host never
|
|
16
|
-
* becoming ready. The accessor waits until the requested iframe is attached.
|
|
17
|
-
* Only that Playwright timeout is rethrown as {@link HostNeverBecameReadyError}
|
|
18
|
-
* before the locator is returned. Any other attach failure is rethrown
|
|
19
|
-
* unchanged. Once the iframe is attached, the locator is returned and later
|
|
20
|
-
* page assertions belong to the caller. A host that is not a feature branch
|
|
21
|
-
* returns the locator immediately and does not extend the test timeout.
|
|
22
|
-
* Playwright's own test timeout would otherwise expire before this wait, so
|
|
23
|
-
* the running test's timeout grows by {@link MAIN_MENU_READY_TIMEOUT_MS} once
|
|
24
|
-
* per test, before the first feature-branch wait. Later `irisApp()` calls in
|
|
25
|
-
* that test do not add the budget again. An unlimited timeout (`0`) is left
|
|
26
|
-
* untouched. The accessor is always a promise, so `const app = await irisApp()`
|
|
27
|
-
* and `await irisApp().then(...)` are the same shape when the gate is off.
|
|
28
|
-
*/
|
|
29
|
-
const createIrisApp = (page, testInfo, options) => {
|
|
30
|
-
const useFirst = options?.first !== false;
|
|
31
|
-
const selectorFor = options?.selector ?? irisAppFrameSelector;
|
|
32
|
-
let budgetReserved = false;
|
|
33
|
-
return async (irisOptions) => {
|
|
34
|
-
const selector = selectorFor(irisOptions?.testId);
|
|
35
|
-
const frame = () => firstMatch(page.frameLocator(selector), useFirst);
|
|
36
|
-
if (!(0, hostReadiness_1.isFeatureBranchHost)()) {
|
|
37
|
-
return frame();
|
|
38
|
-
}
|
|
39
|
-
if (!budgetReserved) {
|
|
40
|
-
(0, login_fixture_1.extendTestTimeout)(testInfo, login_fixture_1.MAIN_MENU_READY_TIMEOUT_MS);
|
|
41
|
-
budgetReserved = true;
|
|
42
|
-
}
|
|
43
|
-
return waitForAttachedIrisAppFrame(page, selector, useFirst);
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
exports.createIrisApp = createIrisApp;
|
|
47
|
-
const isPlaywrightTimeout = (error) => error instanceof test_1.errors.TimeoutError;
|
|
48
|
-
const waitForAttachedIrisAppFrame = async (page, selector, useFirst) => {
|
|
49
|
-
try {
|
|
50
|
-
await firstMatch(page.locator(selector), useFirst).waitFor({
|
|
51
|
-
state: "attached",
|
|
52
|
-
timeout: login_fixture_1.MAIN_MENU_READY_TIMEOUT_MS,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (isPlaywrightTimeout(error)) {
|
|
57
|
-
throw new hostReadiness_1.HostNeverBecameReadyError(error);
|
|
58
|
-
}
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
return firstMatch(page.frameLocator(selector), useFirst);
|
|
62
|
-
};
|
|
63
5
|
exports.test = test_1.test.extend({
|
|
64
|
-
irisApp: async ({ page }, provide
|
|
65
|
-
await provide((
|
|
6
|
+
irisApp: async ({ page }, provide) => {
|
|
7
|
+
await provide((options) => page.frameLocator(`iframe[data-testid="${options?.testId ?? "app-iframe"}"]`));
|
|
66
8
|
},
|
|
67
9
|
storybookPreview: async ({ page }, provide) => {
|
|
68
10
|
await provide((options) => page.frameLocator(`iframe[id="${options?.iframeId ?? "storybook-preview-iframe"}"]`));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CachedStorageState } from "./hydrateStorageState";
|
|
1
|
+
import { type CachedStorageState, type StorageStateHydrator } from "./hydrateStorageState";
|
|
2
2
|
import { type AuthCredentials, type ResolveCredentialsOptions } from "./resolveCredentials";
|
|
3
3
|
export type { AuthCredentials };
|
|
4
4
|
export type LoginOptions = ResolveCredentialsOptions;
|
|
@@ -26,6 +26,14 @@ export declare const MAIN_MENU_READY_SELECTOR = "[data-testid=\"mainMenu\"]:not(
|
|
|
26
26
|
type MainMenuReadinessInput = {
|
|
27
27
|
readonly selector: string;
|
|
28
28
|
readonly fragments: ReadonlyArray<string>;
|
|
29
|
+
/** Exact route handled by `termsCountsAsReady`; excluded from the substring fragments. */
|
|
30
|
+
readonly termsRoute?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the exact `termsRoute` is ready. The first feature-branch wait sets
|
|
33
|
+
* this to true so `/terms` can win; the final shell wait sets it to false.
|
|
34
|
+
* The predicate runs in the browser, so this decision is passed from Node.
|
|
35
|
+
*/
|
|
36
|
+
readonly termsCountsAsReady?: boolean;
|
|
29
37
|
};
|
|
30
38
|
type MainMenuWaitPage = {
|
|
31
39
|
waitForFunction: (pageFunction: (input: MainMenuReadinessInput) => boolean, input: MainMenuReadinessInput, options?: {
|
|
@@ -53,12 +61,23 @@ export declare const extendTestTimeout: (testInfo: TestTimeoutInfo | undefined,
|
|
|
53
61
|
* branch is unchanged.
|
|
54
62
|
*/
|
|
55
63
|
export declare const reserveFeatureBranchLoginBudget: (testInfo?: TestTimeoutInfo) => void;
|
|
56
|
-
/**
|
|
57
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Returns whether the main menu is ready or intentionally hidden for the current route.
|
|
66
|
+
*
|
|
67
|
+
* Root cause (GLU-2632): `/terms` is in {@link HIDE_MENU_URL_FRAGMENTS}, so every
|
|
68
|
+
* host treated the unfinished prompt as a finished login. `termsRoute` gives
|
|
69
|
+
* that route exact-match semantics, and callers decide whether it is an
|
|
70
|
+
* intermediate ready state or must keep waiting for the final shell.
|
|
71
|
+
*/
|
|
72
|
+
export declare const isMainMenuReady: ({ selector, fragments, termsRoute, termsCountsAsReady, }: MainMenuReadinessInput) => boolean;
|
|
58
73
|
/**
|
|
59
74
|
* Waits until Manager's main menu is rendered without a loading skeleton, or
|
|
60
75
|
* until the browser is on a HostLayout hide-menu route (marketplace / auth /
|
|
61
76
|
* terms) where the menu is intentionally absent.
|
|
77
|
+
*
|
|
78
|
+
* On a feature-branch host, `/terms` is excluded: the prompt is not a finished
|
|
79
|
+
* login (GLU-2632). The flag is computed here, in Node, and passed in because
|
|
80
|
+
* {@link isMainMenuReady} is evaluated in the page.
|
|
62
81
|
*/
|
|
63
82
|
export declare const waitForMainMenuReady: (page: MainMenuWaitPage, testInfo?: TestTimeoutInfo) => Promise<void>;
|
|
64
83
|
type EnvReadyResponse = {
|
|
@@ -138,6 +157,12 @@ type LoginRequestContext = {
|
|
|
138
157
|
type SessionDocument = {
|
|
139
158
|
ok: () => boolean;
|
|
140
159
|
};
|
|
160
|
+
type TermsButton = {
|
|
161
|
+
isVisible: () => Promise<boolean>;
|
|
162
|
+
click: (options?: {
|
|
163
|
+
timeout?: number;
|
|
164
|
+
}) => Promise<void>;
|
|
165
|
+
};
|
|
141
166
|
type OktaLoginPage = {
|
|
142
167
|
goto: (url: string, options?: {
|
|
143
168
|
timeout?: number;
|
|
@@ -147,19 +172,26 @@ type OktaLoginPage = {
|
|
|
147
172
|
}) => Promise<unknown>;
|
|
148
173
|
locator: (selector: string) => {
|
|
149
174
|
waitFor: (options: {
|
|
150
|
-
state: "visible";
|
|
175
|
+
state: "visible" | "hidden";
|
|
151
176
|
timeout: number;
|
|
152
177
|
}) => Promise<unknown>;
|
|
178
|
+
isVisible?: () => Promise<boolean>;
|
|
153
179
|
};
|
|
180
|
+
/** Present on a real Playwright page. Session-handoff fakes omit it. */
|
|
181
|
+
url?: () => string;
|
|
182
|
+
getByTestId?: (testId: string) => TermsButton;
|
|
183
|
+
waitForFunction?: MainMenuWaitPage["waitForFunction"];
|
|
154
184
|
};
|
|
155
185
|
/**
|
|
156
186
|
* Performs the slow path: wait for the branch host to serve `/env`, hit Okta's
|
|
157
187
|
* `/api/v1/authn`, redeem the `sessionToken` via the manager-classic redirect,
|
|
158
|
-
* and wait for the host layout to render.
|
|
159
|
-
*
|
|
188
|
+
* and wait for the host layout to render. On a feature-branch host it then
|
|
189
|
+
* finishes the terms prompt and waits for the main shell inside the same
|
|
190
|
+
* budget. Factored out so the cache hit/miss branches read clearly.
|
|
160
191
|
*
|
|
161
192
|
* `createRequestContext`, `now`, and `sleep` are injectable so a unit test can
|
|
162
|
-
* drive the session handoff without a browser or a real
|
|
193
|
+
* drive the session handoff and the terms prompt without a browser or a real
|
|
194
|
+
* three-minute wait.
|
|
163
195
|
*/
|
|
164
196
|
export declare const performOktaLogin: ({ page, baseURL, credentials, testInfo, createRequestContext, now, sleep: pause, }: {
|
|
165
197
|
page: OktaLoginPage;
|
|
@@ -172,4 +204,28 @@ export declare const performOktaLogin: ({ page, baseURL, credentials, testInfo,
|
|
|
172
204
|
/** Injectable pause between session document reloads. Production waits on the event loop. */
|
|
173
205
|
sleep?: (ms: number) => Promise<void>;
|
|
174
206
|
}) => Promise<void>;
|
|
207
|
+
type SignInPage = Omit<OktaLoginPage, "waitForFunction"> & {
|
|
208
|
+
context: () => StorageStateHydrator & {
|
|
209
|
+
storageState: () => Promise<CachedStorageState>;
|
|
210
|
+
};
|
|
211
|
+
/** Required so the shell wait after a restored session can run in the page. */
|
|
212
|
+
waitForFunction: MainMenuWaitPage["waitForFunction"];
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Signs in, reusing this worker's cached session when one exists.
|
|
216
|
+
*
|
|
217
|
+
* `now` and `sleep` are injectable so a unit test can drive the restored
|
|
218
|
+
* feature-branch terms wait without a browser or a real three-minute clock.
|
|
219
|
+
* Production uses `Date.now` and the event loop.
|
|
220
|
+
*/
|
|
221
|
+
export declare const signIn: ({ page, baseURL, cache, testInfo, options, now, sleep: pause, createRequestContext, }: {
|
|
222
|
+
page: SignInPage;
|
|
223
|
+
baseURL: string | undefined;
|
|
224
|
+
cache: Map<string, CachedStorageState>;
|
|
225
|
+
testInfo?: TestTimeoutInfo;
|
|
226
|
+
options?: LoginOptions;
|
|
227
|
+
now?: () => number;
|
|
228
|
+
sleep?: (ms: number) => Promise<void>;
|
|
229
|
+
createRequestContext?: (baseURL: string | undefined) => Promise<LoginRequestContext>;
|
|
230
|
+
}) => Promise<void>;
|
|
175
231
|
export { expect } from "@playwright/test";
|