@owlmeans/test-ui 0.1.18-rc.1 → 0.1.18-rc.11
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/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/testing-ui/SKILL.md +14 -2
- package/build/mount.d.ts +13 -0
- package/build/mount.d.ts.map +1 -1
- package/build/mount.js +4 -1
- package/build/mount.js.map +1 -1
- package/build/supervisor.d.ts +35 -0
- package/build/supervisor.d.ts.map +1 -1
- package/build/supervisor.js +50 -6
- package/build/supervisor.js.map +1 -1
- package/package.json +9 -9
- package/src/mount.ts +17 -1
- package/src/supervisor.ts +71 -7
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/test-ui",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-08-
|
|
4
|
+
"version": "0.1.18-rc.8",
|
|
5
|
+
"generatedAt": "2026-08-27T16:32:18.461Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -109,7 +109,7 @@ The per-package `tests/harness/mount.tsx` reads `?component=<name>` and `?props=
|
|
|
109
109
|
|
|
110
110
|
## Smoke-only baseline
|
|
111
111
|
|
|
112
|
-
For a package that only needs to prove the bun-test + chromium pipeline works
|
|
112
|
+
For a package that only needs to prove the bun-test + chromium pipeline works, skip the Vite harness and serve a `data:text/html` URL inline. Use this for a first spec in a package that has no harness yet — `web-panel` keeps one alongside a full Vite + chromium harness (`tests/harness/` plus a `tests/context.ts` wiring the Tailwind plugin, the `@` alias and a react dedupe), and that harness is the reference to copy for any package rendering real components:
|
|
113
113
|
|
|
114
114
|
```ts
|
|
115
115
|
import { afterAll, describe, expect, test } from 'bun:test'
|
|
@@ -142,7 +142,7 @@ Same line as categories A/B/C. No `playwright.config.ts`, no `bun x playwright t
|
|
|
142
142
|
|
|
143
143
|
## Tailwind + shadcn packages
|
|
144
144
|
|
|
145
|
-
For shadcn-based OwlMeans packages the `tests/context.ts` Vite config needs
|
|
145
|
+
For shadcn-based OwlMeans packages the `tests/context.ts` Vite config needs three additions beyond the standard setup:
|
|
146
146
|
|
|
147
147
|
```ts
|
|
148
148
|
import tailwindcss from '@tailwindcss/vite'
|
|
@@ -154,11 +154,14 @@ const server = await createServer({
|
|
|
154
154
|
plugins: [react(), tailwindcss()], // add Tailwind v4 Vite plugin
|
|
155
155
|
resolve: {
|
|
156
156
|
alias: { '@': resolve(here, '../src/@') }, // resolve @/ to the package's local copy
|
|
157
|
+
dedupe: ['react', 'react-dom'], // one React across the workspace links
|
|
157
158
|
},
|
|
158
159
|
server: { port: 0 },
|
|
159
160
|
})
|
|
160
161
|
```
|
|
161
162
|
|
|
163
|
+
`dedupe` is not optional in a workspace: symlinked sibling packages otherwise resolve their own React copy and every hook throws.
|
|
164
|
+
|
|
162
165
|
`tests/harness/mount.tsx` imports the package CSS so components render with Tailwind styles:
|
|
163
166
|
|
|
164
167
|
```tsx
|
|
@@ -166,6 +169,15 @@ import '../../src/@/globals.css'
|
|
|
166
169
|
// ... dynamic component mounting ...
|
|
167
170
|
```
|
|
168
171
|
|
|
172
|
+
### Testing routed UI (navigation, layouts)
|
|
173
|
+
|
|
174
|
+
A spec that exercises navigation opens a **path** on the harness origin instead of a `?component=` query, and `mount.tsx` builds a real context with real entrypoints — the OwlMeans router drives the History API, so nothing about the routing may be faked. Two shapes the harness must get right, because a spec that trips them fails obscurely:
|
|
175
|
+
|
|
176
|
+
- **Leave the context un-initialized** (`ready` false). The Router compiles the entrypoint tree into routes only while the context is un-initialized; a pre-readied context renders a blank page.
|
|
177
|
+
- **Give every entrypoint that has children one child declared `default: true`**, or the parent's own path renders blank.
|
|
178
|
+
|
|
179
|
+
Include the framework's own `modules` in the harness entrypoint list: the panel context registers the api-config middleware, which resolves one of them during init and throws before any route is compiled if they are missing.
|
|
180
|
+
|
|
169
181
|
Shadcn components are plain React — no theme provider needed. Assert via `getByRole` / text as usual. To verify that Tailwind classes took visual effect, read computed styles:
|
|
170
182
|
|
|
171
183
|
```ts
|
package/build/mount.d.ts
CHANGED
|
@@ -18,6 +18,19 @@ export interface MountOptions {
|
|
|
18
18
|
* URL as `?props=<json>` for the harness's `mount.tsx` to read.
|
|
19
19
|
*/
|
|
20
20
|
props?: Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* What counts as "arrived". Defaults to `domcontentloaded`.
|
|
23
|
+
*
|
|
24
|
+
* NOT `load`, which is playwright's own default and is wrong for any page that is a real
|
|
25
|
+
* application: `load` waits for EVERY subresource, and an analytics beacon, a long-poll or a
|
|
26
|
+
* third-party pixel that never settles holds it open until the navigation times out — with the
|
|
27
|
+
* page fully rendered and working the whole time. The failure reads as "the site is down".
|
|
28
|
+
*
|
|
29
|
+
* A spec waits for the selector it actually needs; that is the assertion, not the load event.
|
|
30
|
+
*/
|
|
31
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle';
|
|
32
|
+
/** Navigation timeout in ms. */
|
|
33
|
+
timeout?: number;
|
|
21
34
|
}
|
|
22
35
|
export interface Mounted {
|
|
23
36
|
page: Page;
|
package/build/mount.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,kBAAkB,GAAG,MAAM,GAAG,aAAa,CAAA;IAClE,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,IAAI,CAAA;IACV,0EAA0E;IAC1E,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AAYD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,SAAgB,YAAY,KAAG,OAAO,CAAC,OAAO,CAYxE,CAAA"}
|
package/build/mount.js
CHANGED
|
@@ -27,7 +27,10 @@ export const mountComponent = async (opts) => {
|
|
|
27
27
|
const browser = await launchBrowser();
|
|
28
28
|
const context = await browser.newContext();
|
|
29
29
|
const page = await context.newPage();
|
|
30
|
-
await page.goto(buildUrl(opts)
|
|
30
|
+
await page.goto(buildUrl(opts), {
|
|
31
|
+
waitUntil: opts.waitUntil ?? 'domcontentloaded',
|
|
32
|
+
...(opts.timeout != null ? { timeout: opts.timeout } : {}),
|
|
33
|
+
});
|
|
31
34
|
return {
|
|
32
35
|
page,
|
|
33
36
|
close: async () => { await context.close(); },
|
package/build/mount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../src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,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC,CAAA;IACF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA,CAAC,CAAC;KAC7C,CAAA;AACH,CAAC,CAAA"}
|
package/build/supervisor.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const pregenerateAuthToken: (opts: PregenerateAuthTokenOptions) =
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const loginViaDispatcher: (page: Page, baseUrl: string, token: string, opts?: {
|
|
36
36
|
dispatcherPath?: string;
|
|
37
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle';
|
|
37
38
|
}) => Promise<void>;
|
|
38
39
|
export interface SupervisorApiAuthOptions {
|
|
39
40
|
/** Auth-manager API base URL (the backend serving /authentication/* and /authenticate). */
|
|
@@ -78,9 +79,43 @@ export interface SupervisorFormLoginOptions {
|
|
|
78
79
|
/** Predicate/URL fragment that signals a successful landing (default: leaving the login path). */
|
|
79
80
|
expectPath?: string;
|
|
80
81
|
timeout?: number;
|
|
82
|
+
/**
|
|
83
|
+
* What counts as "arrived" for the initial navigation. Defaults to `domcontentloaded`.
|
|
84
|
+
*
|
|
85
|
+
* See the note on `MountOptions.waitUntil`: `load` is playwright's default and is wrong for a
|
|
86
|
+
* real application, because it waits for every subresource — a tag manager, an analytics beacon
|
|
87
|
+
* or any pixel that never settles holds it open until the navigation times out, with the login
|
|
88
|
+
* form rendered and fillable the whole time.
|
|
89
|
+
*/
|
|
90
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle';
|
|
91
|
+
/**
|
|
92
|
+
* What to do about a cookie-consent dialog covering the form. Defaults to `accept`, because an
|
|
93
|
+
* OwlMeans app will not start an authentication flow until consent is answered — see
|
|
94
|
+
* {@link acceptConsent}. Pass `ignore` only in a spec that answers the dialog itself.
|
|
95
|
+
*/
|
|
96
|
+
consent?: 'accept' | 'ignore';
|
|
81
97
|
/** When set, capture the filled login form (`supervisor-login-form.png`) before submit. */
|
|
82
98
|
screenshotDir?: string;
|
|
83
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Answer the cookie-consent dialog if one is up, so the page underneath can be driven.
|
|
102
|
+
*
|
|
103
|
+
* An OwlMeans app asks for consent BEFORE it will start an authentication flow, and the dialog is
|
|
104
|
+
* a modal with no dismissal — by design, since a decision is what the gate is waiting for. For a
|
|
105
|
+
* test that means the login form renders, resolves, reports itself "visible, enabled and stable"
|
|
106
|
+
* and still cannot be clicked, because the overlay intercepts the pointer. Playwright retries for
|
|
107
|
+
* the full timeout and then blames the button, which is the most misleading failure in this file:
|
|
108
|
+
* nothing is wrong with the form.
|
|
109
|
+
*
|
|
110
|
+
* Accepting is the honest default for a login helper — the flow it is about to drive is exactly
|
|
111
|
+
* what the dialog is gating — but it is best-effort: an app without the widget, or one where the
|
|
112
|
+
* visitor already decided, simply has no dialog and this returns at once.
|
|
113
|
+
*
|
|
114
|
+
* @returns whether a dialog was actually answered.
|
|
115
|
+
*/
|
|
116
|
+
export declare const acceptConsent: (page: Page, opts?: {
|
|
117
|
+
timeout?: number;
|
|
118
|
+
}) => Promise<boolean>;
|
|
84
119
|
/**
|
|
85
120
|
* Drive the PK-based supervisor login FORM end-to-end (the faithful path that
|
|
86
121
|
* exercises the real supervisor plugin + registration): navigate to the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AASrE,MAAM,WAAW,2BAA2B;IAC1C,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,MAA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;AACH,eAAO,MAAM,sBAAsB,SAC3B,IAAI,QAAQ,0BAA0B,KAC3C,OAAO,CAAC,IAAI,CAiCd,CAAA"}
|
package/build/supervisor.js
CHANGED
|
@@ -19,7 +19,7 @@ export const pregenerateAuthToken = async (opts) => {
|
|
|
19
19
|
token: createIdOfLength(32),
|
|
20
20
|
userId: opts.userId,
|
|
21
21
|
profileId: opts.profileId ?? opts.userId,
|
|
22
|
-
|
|
22
|
+
entitySlug: opts.entityId,
|
|
23
23
|
scopes: opts.scopes ?? ['*'],
|
|
24
24
|
role: opts.role ?? Role.User,
|
|
25
25
|
type: AuthroizationType.Ed25519BasicToken,
|
|
@@ -39,7 +39,8 @@ export const loginViaDispatcher = async (page, baseUrl, token, opts) => {
|
|
|
39
39
|
const path = opts?.dispatcherPath ?? '/dispatcher';
|
|
40
40
|
const url = new URL(path, baseUrl);
|
|
41
41
|
url.searchParams.set('token', token);
|
|
42
|
-
|
|
42
|
+
// `domcontentloaded`, not playwright's `load` default — see the note on `MountOptions.waitUntil`.
|
|
43
|
+
await page.goto(url.toString(), { waitUntil: opts?.waitUntil ?? 'domcontentloaded' });
|
|
43
44
|
// Wait until the dispatcher has navigated away (token consumed).
|
|
44
45
|
await page.waitForURL(u => !u.pathname.startsWith(path), { timeout: 30_000 });
|
|
45
46
|
};
|
|
@@ -106,6 +107,36 @@ export const saveScreenshot = async (page, dir, name) => {
|
|
|
106
107
|
return file;
|
|
107
108
|
};
|
|
108
109
|
const DEFAULT_SUPERVISOR_PATH = '/authentication/login/pk-supervisor';
|
|
110
|
+
/**
|
|
111
|
+
* Answer the cookie-consent dialog if one is up, so the page underneath can be driven.
|
|
112
|
+
*
|
|
113
|
+
* An OwlMeans app asks for consent BEFORE it will start an authentication flow, and the dialog is
|
|
114
|
+
* a modal with no dismissal — by design, since a decision is what the gate is waiting for. For a
|
|
115
|
+
* test that means the login form renders, resolves, reports itself "visible, enabled and stable"
|
|
116
|
+
* and still cannot be clicked, because the overlay intercepts the pointer. Playwright retries for
|
|
117
|
+
* the full timeout and then blames the button, which is the most misleading failure in this file:
|
|
118
|
+
* nothing is wrong with the form.
|
|
119
|
+
*
|
|
120
|
+
* Accepting is the honest default for a login helper — the flow it is about to drive is exactly
|
|
121
|
+
* what the dialog is gating — but it is best-effort: an app without the widget, or one where the
|
|
122
|
+
* visitor already decided, simply has no dialog and this returns at once.
|
|
123
|
+
*
|
|
124
|
+
* @returns whether a dialog was actually answered.
|
|
125
|
+
*/
|
|
126
|
+
export const acceptConsent = async (page, opts) => {
|
|
127
|
+
const dialog = page.locator('[data-consent-dialog]');
|
|
128
|
+
try {
|
|
129
|
+
await dialog.waitFor({ state: 'visible', timeout: opts?.timeout ?? 5_000 });
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
// Accept-all rather than essential-only: a test asserting a narrower decision should make that
|
|
135
|
+
// decision itself, and silently choosing the minimum here would hide it from the spec.
|
|
136
|
+
await page.locator('[data-consent-accept-all]').click();
|
|
137
|
+
await dialog.waitFor({ state: 'detached', timeout: opts?.timeout ?? 5_000 });
|
|
138
|
+
return true;
|
|
139
|
+
};
|
|
109
140
|
/**
|
|
110
141
|
* Drive the PK-based supervisor login FORM end-to-end (the faithful path that
|
|
111
142
|
* exercises the real supervisor plugin + registration): navigate to the
|
|
@@ -115,13 +146,26 @@ const DEFAULT_SUPERVISOR_PATH = '/authentication/login/pk-supervisor';
|
|
|
115
146
|
export const loginViaSupervisorForm = async (page, opts) => {
|
|
116
147
|
const path = opts.path ?? DEFAULT_SUPERVISOR_PATH;
|
|
117
148
|
const timeout = opts.timeout ?? 60_000;
|
|
118
|
-
await page.goto(new URL(path, opts.baseUrl).toString()
|
|
119
|
-
|
|
120
|
-
|
|
149
|
+
await page.goto(new URL(path, opts.baseUrl).toString(), {
|
|
150
|
+
waitUntil: opts.waitUntil ?? 'domcontentloaded', timeout
|
|
151
|
+
});
|
|
152
|
+
// Wait for the app to MOUNT before deciding whether there is a dialog to answer. `domcontentloaded`
|
|
153
|
+
// returns while the SPA is still booting, and on a dev server that boot is occasionally tens of
|
|
154
|
+
// seconds — so a short consent probe reports "no dialog", the dialog then mounts over the form,
|
|
155
|
+
// and the fill below waits out its own timeout on a field that is present but covered. Either
|
|
156
|
+
// marker proves the app is up: the dialog, or the form itself when consent was already given.
|
|
157
|
+
await page.locator('[data-consent-dialog], [data-testid="supervisor-user-id"]')
|
|
158
|
+
.first().waitFor({ state: 'visible', timeout });
|
|
159
|
+
if (opts.consent !== 'ignore')
|
|
160
|
+
await acceptConsent(page, { timeout });
|
|
161
|
+
// The form renders only AFTER the dialog is dismissed, so these carry the caller's budget rather
|
|
162
|
+
// than playwright's 30s default — the whole point of accepting an explicit `timeout` here.
|
|
163
|
+
await page.getByTestId('supervisor-user-id').fill(opts.userId, { timeout });
|
|
164
|
+
await page.getByTestId('supervisor-pk').fill(opts.pk, { timeout });
|
|
121
165
|
if (opts.screenshotDir != null) {
|
|
122
166
|
await saveScreenshot(page, opts.screenshotDir, 'supervisor-login-form');
|
|
123
167
|
}
|
|
124
|
-
await page.getByTestId('supervisor-submit').click();
|
|
168
|
+
await page.getByTestId('supervisor-submit').click({ timeout });
|
|
125
169
|
if (opts.expectPath != null) {
|
|
126
170
|
await page.waitForURL(url => url.toString().includes(opts.expectPath), { timeout });
|
|
127
171
|
}
|
package/build/supervisor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGzC,OAAO,EACL,iBAAiB,EAAE,QAAQ,IAAI,IAAI,EAAE,kBAAkB,EAAE,sBAAsB,EAChF,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CA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|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"./harness": "./harness/index.html"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/basic-envelope": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/basic-ids": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/basic-keys": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/test": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/test-auth": "^0.1.18-rc.
|
|
25
|
+
"@owlmeans/auth": "^0.1.18-rc.7",
|
|
26
|
+
"@owlmeans/basic-envelope": "^0.1.18-rc.9",
|
|
27
|
+
"@owlmeans/basic-ids": "^0.1.18-rc.7",
|
|
28
|
+
"@owlmeans/basic-keys": "^0.1.18-rc.9",
|
|
29
|
+
"@owlmeans/test": "^0.1.18-rc.6",
|
|
30
|
+
"@owlmeans/test-auth": "^0.1.18-rc.9",
|
|
31
31
|
"playwright": "^1.61.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@owlmeans/dep-config": "^0.1.18-rc.
|
|
47
|
-
"@types/bun": "^1.
|
|
46
|
+
"@owlmeans/dep-config": "^0.1.18-rc.6",
|
|
47
|
+
"@types/bun": "^1.4.0",
|
|
48
48
|
"@types/react": "^19.2.17",
|
|
49
49
|
"nodemon": "^3.1.14",
|
|
50
50
|
"typescript": "^7.0.2"
|
package/src/mount.ts
CHANGED
|
@@ -20,6 +20,19 @@ export interface MountOptions {
|
|
|
20
20
|
* URL as `?props=<json>` for the harness's `mount.tsx` to read.
|
|
21
21
|
*/
|
|
22
22
|
props?: Record<string, unknown>
|
|
23
|
+
/**
|
|
24
|
+
* What counts as "arrived". Defaults to `domcontentloaded`.
|
|
25
|
+
*
|
|
26
|
+
* NOT `load`, which is playwright's own default and is wrong for any page that is a real
|
|
27
|
+
* application: `load` waits for EVERY subresource, and an analytics beacon, a long-poll or a
|
|
28
|
+
* third-party pixel that never settles holds it open until the navigation times out — with the
|
|
29
|
+
* page fully rendered and working the whole time. The failure reads as "the site is down".
|
|
30
|
+
*
|
|
31
|
+
* A spec waits for the selector it actually needs; that is the assertion, not the load event.
|
|
32
|
+
*/
|
|
33
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle'
|
|
34
|
+
/** Navigation timeout in ms. */
|
|
35
|
+
timeout?: number
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
export interface Mounted {
|
|
@@ -54,7 +67,10 @@ export const mountComponent = async (opts: MountOptions): Promise<Mounted> => {
|
|
|
54
67
|
const browser = await launchBrowser()
|
|
55
68
|
const context = await browser.newContext()
|
|
56
69
|
const page = await context.newPage()
|
|
57
|
-
await page.goto(buildUrl(opts)
|
|
70
|
+
await page.goto(buildUrl(opts), {
|
|
71
|
+
waitUntil: opts.waitUntil ?? 'domcontentloaded',
|
|
72
|
+
...(opts.timeout != null ? { timeout: opts.timeout } : {}),
|
|
73
|
+
})
|
|
58
74
|
return {
|
|
59
75
|
page,
|
|
60
76
|
close: async () => { await context.close() },
|
package/src/supervisor.ts
CHANGED
|
@@ -41,7 +41,7 @@ export const pregenerateAuthToken = async (opts: PregenerateAuthTokenOptions): P
|
|
|
41
41
|
token: createIdOfLength(32),
|
|
42
42
|
userId: opts.userId,
|
|
43
43
|
profileId: opts.profileId ?? opts.userId,
|
|
44
|
-
|
|
44
|
+
entitySlug: opts.entityId,
|
|
45
45
|
scopes: opts.scopes ?? ['*'],
|
|
46
46
|
role: opts.role ?? Role.User,
|
|
47
47
|
type: AuthroizationType.Ed25519BasicToken,
|
|
@@ -60,12 +60,14 @@ export const pregenerateAuthToken = async (opts: PregenerateAuthTokenOptions): P
|
|
|
60
60
|
* (e.g. to force an external IdP) should use {@link loginViaSupervisorForm}.
|
|
61
61
|
*/
|
|
62
62
|
export const loginViaDispatcher = async (
|
|
63
|
-
page: Page, baseUrl: string, token: string,
|
|
63
|
+
page: Page, baseUrl: string, token: string,
|
|
64
|
+
opts?: { dispatcherPath?: string, waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle' }
|
|
64
65
|
): Promise<void> => {
|
|
65
66
|
const path = opts?.dispatcherPath ?? '/dispatcher'
|
|
66
67
|
const url = new URL(path, baseUrl)
|
|
67
68
|
url.searchParams.set('token', token)
|
|
68
|
-
|
|
69
|
+
// `domcontentloaded`, not playwright's `load` default — see the note on `MountOptions.waitUntil`.
|
|
70
|
+
await page.goto(url.toString(), { waitUntil: opts?.waitUntil ?? 'domcontentloaded' })
|
|
69
71
|
// Wait until the dispatcher has navigated away (token consumed).
|
|
70
72
|
await page.waitForURL(u => !u.pathname.startsWith(path), { timeout: 30_000 })
|
|
71
73
|
}
|
|
@@ -168,12 +170,60 @@ export interface SupervisorFormLoginOptions {
|
|
|
168
170
|
/** Predicate/URL fragment that signals a successful landing (default: leaving the login path). */
|
|
169
171
|
expectPath?: string
|
|
170
172
|
timeout?: number
|
|
173
|
+
/**
|
|
174
|
+
* What counts as "arrived" for the initial navigation. Defaults to `domcontentloaded`.
|
|
175
|
+
*
|
|
176
|
+
* See the note on `MountOptions.waitUntil`: `load` is playwright's default and is wrong for a
|
|
177
|
+
* real application, because it waits for every subresource — a tag manager, an analytics beacon
|
|
178
|
+
* or any pixel that never settles holds it open until the navigation times out, with the login
|
|
179
|
+
* form rendered and fillable the whole time.
|
|
180
|
+
*/
|
|
181
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle'
|
|
182
|
+
/**
|
|
183
|
+
* What to do about a cookie-consent dialog covering the form. Defaults to `accept`, because an
|
|
184
|
+
* OwlMeans app will not start an authentication flow until consent is answered — see
|
|
185
|
+
* {@link acceptConsent}. Pass `ignore` only in a spec that answers the dialog itself.
|
|
186
|
+
*/
|
|
187
|
+
consent?: 'accept' | 'ignore'
|
|
171
188
|
/** When set, capture the filled login form (`supervisor-login-form.png`) before submit. */
|
|
172
189
|
screenshotDir?: string
|
|
173
190
|
}
|
|
174
191
|
|
|
175
192
|
const DEFAULT_SUPERVISOR_PATH = '/authentication/login/pk-supervisor'
|
|
176
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Answer the cookie-consent dialog if one is up, so the page underneath can be driven.
|
|
196
|
+
*
|
|
197
|
+
* An OwlMeans app asks for consent BEFORE it will start an authentication flow, and the dialog is
|
|
198
|
+
* a modal with no dismissal — by design, since a decision is what the gate is waiting for. For a
|
|
199
|
+
* test that means the login form renders, resolves, reports itself "visible, enabled and stable"
|
|
200
|
+
* and still cannot be clicked, because the overlay intercepts the pointer. Playwright retries for
|
|
201
|
+
* the full timeout and then blames the button, which is the most misleading failure in this file:
|
|
202
|
+
* nothing is wrong with the form.
|
|
203
|
+
*
|
|
204
|
+
* Accepting is the honest default for a login helper — the flow it is about to drive is exactly
|
|
205
|
+
* what the dialog is gating — but it is best-effort: an app without the widget, or one where the
|
|
206
|
+
* visitor already decided, simply has no dialog and this returns at once.
|
|
207
|
+
*
|
|
208
|
+
* @returns whether a dialog was actually answered.
|
|
209
|
+
*/
|
|
210
|
+
export const acceptConsent = async (
|
|
211
|
+
page: Page, opts?: { timeout?: number }
|
|
212
|
+
): Promise<boolean> => {
|
|
213
|
+
const dialog = page.locator('[data-consent-dialog]')
|
|
214
|
+
try {
|
|
215
|
+
await dialog.waitFor({ state: 'visible', timeout: opts?.timeout ?? 5_000 })
|
|
216
|
+
} catch {
|
|
217
|
+
return false
|
|
218
|
+
}
|
|
219
|
+
// Accept-all rather than essential-only: a test asserting a narrower decision should make that
|
|
220
|
+
// decision itself, and silently choosing the minimum here would hide it from the spec.
|
|
221
|
+
await page.locator('[data-consent-accept-all]').click()
|
|
222
|
+
await dialog.waitFor({ state: 'detached', timeout: opts?.timeout ?? 5_000 })
|
|
223
|
+
|
|
224
|
+
return true
|
|
225
|
+
}
|
|
226
|
+
|
|
177
227
|
/**
|
|
178
228
|
* Drive the PK-based supervisor login FORM end-to-end (the faithful path that
|
|
179
229
|
* exercises the real supervisor plugin + registration): navigate to the
|
|
@@ -185,16 +235,30 @@ export const loginViaSupervisorForm = async (
|
|
|
185
235
|
): Promise<void> => {
|
|
186
236
|
const path = opts.path ?? DEFAULT_SUPERVISOR_PATH
|
|
187
237
|
const timeout = opts.timeout ?? 60_000
|
|
188
|
-
await page.goto(new URL(path, opts.baseUrl).toString()
|
|
238
|
+
await page.goto(new URL(path, opts.baseUrl).toString(), {
|
|
239
|
+
waitUntil: opts.waitUntil ?? 'domcontentloaded', timeout
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
// Wait for the app to MOUNT before deciding whether there is a dialog to answer. `domcontentloaded`
|
|
243
|
+
// returns while the SPA is still booting, and on a dev server that boot is occasionally tens of
|
|
244
|
+
// seconds — so a short consent probe reports "no dialog", the dialog then mounts over the form,
|
|
245
|
+
// and the fill below waits out its own timeout on a field that is present but covered. Either
|
|
246
|
+
// marker proves the app is up: the dialog, or the form itself when consent was already given.
|
|
247
|
+
await page.locator('[data-consent-dialog], [data-testid="supervisor-user-id"]')
|
|
248
|
+
.first().waitFor({ state: 'visible', timeout })
|
|
249
|
+
|
|
250
|
+
if (opts.consent !== 'ignore') await acceptConsent(page, { timeout })
|
|
189
251
|
|
|
190
|
-
|
|
191
|
-
|
|
252
|
+
// The form renders only AFTER the dialog is dismissed, so these carry the caller's budget rather
|
|
253
|
+
// than playwright's 30s default — the whole point of accepting an explicit `timeout` here.
|
|
254
|
+
await page.getByTestId('supervisor-user-id').fill(opts.userId, { timeout })
|
|
255
|
+
await page.getByTestId('supervisor-pk').fill(opts.pk, { timeout })
|
|
192
256
|
|
|
193
257
|
if (opts.screenshotDir != null) {
|
|
194
258
|
await saveScreenshot(page, opts.screenshotDir, 'supervisor-login-form')
|
|
195
259
|
}
|
|
196
260
|
|
|
197
|
-
await page.getByTestId('supervisor-submit').click()
|
|
261
|
+
await page.getByTestId('supervisor-submit').click({ timeout })
|
|
198
262
|
|
|
199
263
|
if (opts.expectPath != null) {
|
|
200
264
|
await page.waitForURL(url => url.toString().includes(opts.expectPath!), { timeout })
|