@owlmeans/test-ui 0.1.19-rc.0 → 0.1.19
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 +28 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/testing-ui/SKILL.md +28 -3
- package/build/consts.local.d.ts +6 -0
- package/build/consts.local.d.ts.map +1 -1
- package/build/consts.local.js +6 -0
- package/build/consts.local.js.map +1 -1
- package/build/email/types.d.ts +45 -0
- package/build/email/types.d.ts.map +1 -0
- package/build/email/types.js +2 -0
- package/build/email/types.js.map +1 -0
- package/build/email.d.ts +8 -0
- package/build/email.d.ts.map +1 -0
- package/build/email.js +43 -0
- package/build/email.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/page/email.d.ts +4 -0
- package/build/page/email.d.ts.map +1 -0
- package/build/page/email.js +165 -0
- package/build/page/email.js.map +1 -0
- package/build/page/types.d.ts +93 -0
- package/build/page/types.d.ts.map +1 -1
- package/build/page.d.ts.map +1 -1
- package/build/page.js +6 -1
- package/build/page.js.map +1 -1
- package/package.json +14 -9
- package/src/consts.local.ts +10 -0
- package/src/email/types.ts +45 -0
- package/src/email.ts +51 -0
- package/src/index.ts +2 -0
- package/src/page/email.ts +183 -0
- package/src/page/types.ts +94 -0
- package/src/page.ts +7 -1
- package/tests/email.spec.ts +105 -0
- package/tsconfig.json +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/page/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,6BAA6B;IAC5C;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;IAChC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CAC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OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAClG;;;;;;;OAOG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAA;CAClF;AAED,uGAAuG;AACvG,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,UAAU,EAAE,kBAAkB,GAAG,mBAAmB,CAAC;CAAG;AAErG,yDAAyD;AACzD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,UAAU,EAAE,eAAe,GAAG,wBAAwB,GAAG,gBAAgB,CAAC;CAAG"}
|
package/build/page.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAItC,OAAO,KAAK,EACmE,UAAU,EACxF,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAItC,OAAO,KAAK,EACmE,UAAU,EACxF,MAAM,iBAAiB,CAAA;AAGxB,eAAO,MAAM,cAAc,SAAU,IAAI,KAAG,UA4L3C,CAAA"}
|
package/build/page.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdir } from 'node:fs/promises';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { CONSENT_SETTLED_WITHOUT_UI, DEFAULT_MARKETING_CONSENT_TIMEOUT, DEFAULT_SUPERVISOR_PATH, } from './consts.local.js';
|
|
4
|
+
import { makeEmailLoginFlow } from './page/email.js';
|
|
4
5
|
export const makePageHelper = (page) => {
|
|
5
6
|
const answerMarketingConsent = async (opts) => {
|
|
6
7
|
const timeout = opts?.timeout ?? DEFAULT_MARKETING_CONSENT_TIMEOUT;
|
|
@@ -163,6 +164,10 @@ export const makePageHelper = (page) => {
|
|
|
163
164
|
if (opts.marketingConsent !== 'ignore')
|
|
164
165
|
await answerMarketingConsent({ accept: 'all', timeout });
|
|
165
166
|
};
|
|
166
|
-
|
|
167
|
+
const email = makeEmailLoginFlow(page, { acceptConsent, answerMarketingConsent, saveScreenshot });
|
|
168
|
+
return {
|
|
169
|
+
answerMarketingConsent, loginViaDispatcher, saveScreenshot, acceptConsent, loginViaSupervisorForm,
|
|
170
|
+
routeEmailWaiver: email.routeEmailWaiver, loginViaEmailForm: email.loginViaEmailForm,
|
|
171
|
+
};
|
|
167
172
|
};
|
|
168
173
|
//# sourceMappingURL=page.js.map
|
package/build/page.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EACL,0BAA0B,EAAE,iCAAiC,EAAE,uBAAuB,GACvF,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EACL,0BAA0B,EAAE,iCAAiC,EAAE,uBAAuB,GACvF,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAU,EAAc,EAAE;IACvD,MAAM,sBAAsB,GAAG,KAAK,EAAE,IAAoC,EAAoB,EAAE;QAC9F,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,iCAAiC,CAAA;QAClE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Q;YAAE,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IAClG,CAAC,CAAA;IAED,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAC,CAAA;IAEjG,OAAO;QACL,sBAAsB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,sBAAsB;QACjG,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KACrF,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/test-ui",
|
|
3
|
-
"version": "0.1.19
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -b",
|
|
8
8
|
"dev": "nodemon -e ts,tsx,json --watch src --exec \"tsc -p ./tsconfig.json\"",
|
|
9
|
-
"watch": "tsc -b -w --preserveWatchOutput --pretty"
|
|
9
|
+
"watch": "tsc -b -w --preserveWatchOutput --pretty",
|
|
10
|
+
"test": "bun test ./tests"
|
|
10
11
|
},
|
|
11
12
|
"main": "build/index.js",
|
|
12
13
|
"module": "build/index.js",
|
|
@@ -22,12 +23,14 @@
|
|
|
22
23
|
"./harness": "./harness/index.html"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@owlmeans/auth": "^0.1.19
|
|
26
|
-
"@owlmeans/
|
|
27
|
-
"@owlmeans/
|
|
28
|
-
"@owlmeans/basic-
|
|
29
|
-
"@owlmeans/
|
|
30
|
-
"@owlmeans/
|
|
26
|
+
"@owlmeans/auth": "^0.1.19",
|
|
27
|
+
"@owlmeans/auth-common": "^0.1.19",
|
|
28
|
+
"@owlmeans/auth-email": "^0.1.19",
|
|
29
|
+
"@owlmeans/basic-envelope": "^0.1.19",
|
|
30
|
+
"@owlmeans/basic-ids": "^0.1.19",
|
|
31
|
+
"@owlmeans/basic-keys": "^0.1.19",
|
|
32
|
+
"@owlmeans/test": "^0.1.19",
|
|
33
|
+
"@owlmeans/test-auth": "^0.1.19",
|
|
31
34
|
"playwright": "^1.64.1"
|
|
32
35
|
},
|
|
33
36
|
"peerDependencies": {
|
|
@@ -43,7 +46,9 @@
|
|
|
43
46
|
}
|
|
44
47
|
},
|
|
45
48
|
"devDependencies": {
|
|
46
|
-
"@owlmeans/
|
|
49
|
+
"@owlmeans/context": "^0.1.19",
|
|
50
|
+
"@owlmeans/dep-config": "^0.1.19",
|
|
51
|
+
"@owlmeans/entrypoint": "^0.1.19",
|
|
47
52
|
"@types/bun": "^1.4.4",
|
|
48
53
|
"@types/react": "^19.3.0",
|
|
49
54
|
"nodemon": "^3.1.14",
|
package/src/consts.local.ts
CHANGED
|
@@ -10,3 +10,13 @@ export const DEFAULT_CONSENT_TRACE_PATH = '/cdn-cgi/trace'
|
|
|
10
10
|
|
|
11
11
|
/** What `acceptConsent` treats as "nothing to answer": the store settled on a decision without UI. */
|
|
12
12
|
export const CONSENT_SETTLED_WITHOUT_UI = 'html[data-consent="decided"], html[data-consent="idle"]'
|
|
13
|
+
|
|
14
|
+
/** The e-mail method's own route (`@owlmeans/auth-email`'s `email` plugin on the typed authentication route). */
|
|
15
|
+
export const DEFAULT_EMAIL_LOGIN_PATH = '/authentication/login/email'
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_DISPATCHER_PATH = '/dispatcher'
|
|
18
|
+
|
|
19
|
+
/** What an OwlMeans app shows once it has landed — the marker `answerMarketingConsent` races too. */
|
|
20
|
+
export const DEFAULT_LANDED_SELECTOR = '#app-prompt'
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_EMAIL_LOGIN_TIMEOUT = 60_000
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Node-side test needs to drive e-mail sign-in without a mailbox: the developer (tech) routes
|
|
3
|
+
* of `@owlmeans/auth-email`, signed as one of the deployment's trusted records.
|
|
4
|
+
*/
|
|
5
|
+
export interface EmailTechClientOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The API base the e-mail routes hang under — for an app whose API lives at `<web>/api`, that
|
|
8
|
+
* address (`https://app.example/api`); the routes are `<apiUrl><path>/tech/*`.
|
|
9
|
+
*/
|
|
10
|
+
apiUrl: string
|
|
11
|
+
/**
|
|
12
|
+
* The private key of a trusted record the deployment allows to sign tech calls (its `tech.signers`
|
|
13
|
+
* names the record), e.g. `ed25519:<base64>` from `.env.dev.secrets`.
|
|
14
|
+
*/
|
|
15
|
+
privateKey: string
|
|
16
|
+
/**
|
|
17
|
+
* The trusted record's id (its DID). By default the key's own address — `ed25519:<address>`, what
|
|
18
|
+
* `makeKeyPairModel(privateKey).exportAddress()` gives and what OwlMeans deployments use as the
|
|
19
|
+
* record id (viable's `shared-key` record reads it from `/etc/app-config/shared-did`). Pass it only
|
|
20
|
+
* for a record whose id is not its key's address.
|
|
21
|
+
*/
|
|
22
|
+
credentialId?: string
|
|
23
|
+
/** The e-mail routes' base path; default `EMAIL_AUTH_API_PATH` (`/auth/email`). */
|
|
24
|
+
path?: string
|
|
25
|
+
fetchImpl?: typeof fetch
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The two developer calls: a captcha/throttle waiver, and rewriting a mailed PIN. */
|
|
29
|
+
export interface EmailTechClient {
|
|
30
|
+
/**
|
|
31
|
+
* A fresh signed waiver (`POST tech/waiver`). Sent in `EMAIL_WAIVER_HEADER` on the e-mail routes,
|
|
32
|
+
* it skips the captcha and the send/password throttles — never the PIN's attempt limit — for about
|
|
33
|
+
* two hours, on a deployment whose tech routes are on.
|
|
34
|
+
*/
|
|
35
|
+
waiver: () => Promise<string>
|
|
36
|
+
/**
|
|
37
|
+
* Replace the PIN of a pending challenge (`POST tech/pin`) — the `challenge` a send-PIN, a
|
|
38
|
+
* device-PIN sign-in or a confirmation answered. Resolves the PIN now valid for it: `pin` when
|
|
39
|
+
* given (6 digits), else 6 random digits.
|
|
40
|
+
*
|
|
41
|
+
* @throws when the server refuses, or answers that nothing was rewritten (the challenge expired,
|
|
42
|
+
* was spent, or names another address).
|
|
43
|
+
*/
|
|
44
|
+
rewritePin: (challenge: string, pin?: string) => Promise<string>
|
|
45
|
+
}
|
package/src/email.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto'
|
|
2
|
+
import { signBasicEd25519Request } from '@owlmeans/auth-common'
|
|
3
|
+
import { EMAIL_AUTH_API_PATH, EMAIL_PIN_LENGTH } from '@owlmeans/auth-email'
|
|
4
|
+
import type { EmailTechPinView, EmailTechWaiverView } from '@owlmeans/auth-email'
|
|
5
|
+
import { makeKeyPairModel } from '@owlmeans/basic-keys'
|
|
6
|
+
import type { EmailTechClient, EmailTechClientOptions } from './email/types.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A client of `@owlmeans/auth-email`'s developer routes, signing every POST exactly as
|
|
10
|
+
* `GUARD_ED25519` verifies it (`signBasicEd25519Request`) — for e2e suites that sign people in by
|
|
11
|
+
* e-mail without reading their mail.
|
|
12
|
+
*/
|
|
13
|
+
export const makeEmailTechClient = (opts: EmailTechClientOptions): EmailTechClient => {
|
|
14
|
+
const key = makeKeyPairModel(opts.privateKey)
|
|
15
|
+
const credential = opts.credentialId ?? key.exportAddress()
|
|
16
|
+
const fetchImpl = opts.fetchImpl ?? fetch
|
|
17
|
+
const path = opts.path ?? EMAIL_AUTH_API_PATH
|
|
18
|
+
const base = `${opts.apiUrl.replace(/\/+$/, '')}/${path.replace(/^\/+|\/+$/g, '')}/tech`
|
|
19
|
+
const pinFormat = new RegExp(`^[0-9]{${EMAIL_PIN_LENGTH}}$`)
|
|
20
|
+
|
|
21
|
+
const post = async <T>(route: string, body: object): Promise<T> => {
|
|
22
|
+
const signed = await signBasicEd25519Request({ body, credential, key })
|
|
23
|
+
const response = await fetchImpl(`${base}${route}`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: { 'content-type': 'application/json', authorization: signed.authorization, ...signed.headers },
|
|
26
|
+
body: JSON.stringify(body),
|
|
27
|
+
})
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error(`[@owlmeans/test-ui] e-mail tech ${route} -> ${response.status}`)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return await response.json() as T
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const waiver = async (): Promise<string> => (await post<EmailTechWaiverView>('/waiver', {})).waiver
|
|
36
|
+
|
|
37
|
+
const rewritePin = async (challenge: string, pin?: string): Promise<string> => {
|
|
38
|
+
const code = pin ?? String(randomInt(0, 10 ** EMAIL_PIN_LENGTH)).padStart(EMAIL_PIN_LENGTH, '0')
|
|
39
|
+
if (!pinFormat.test(code)) {
|
|
40
|
+
throw new SyntaxError(`[@owlmeans/test-ui] a PIN is ${EMAIL_PIN_LENGTH} digits`)
|
|
41
|
+
}
|
|
42
|
+
const { ok } = await post<EmailTechPinView>('/pin', { challenge, pin: code })
|
|
43
|
+
if (!ok) {
|
|
44
|
+
throw new Error('[@owlmeans/test-ui] the PIN was not rewritten: the challenge expired, was spent or names another address')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return code
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { waiver, rewritePin }
|
|
51
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,8 @@ export * from './browser.js'
|
|
|
2
2
|
export * from './consent.js'
|
|
3
3
|
export type * from './consent/types.js'
|
|
4
4
|
export type * from './browser/types.js'
|
|
5
|
+
export * from './email.js'
|
|
6
|
+
export type * from './email/types.js'
|
|
5
7
|
export * from './marketing-consent.js'
|
|
6
8
|
export type * from './types.js'
|
|
7
9
|
export * from './mount.js'
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { Page, Response } from 'playwright'
|
|
2
|
+
import { EMAIL_AUTH_API_PATH, EMAIL_WAIVER_HEADER, EmailSignInReason } from '@owlmeans/auth-email'
|
|
3
|
+
import type { EmailChallengeView, EmailSignInView } from '@owlmeans/auth-email'
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_DISPATCHER_PATH, DEFAULT_EMAIL_LOGIN_PATH, DEFAULT_EMAIL_LOGIN_TIMEOUT, DEFAULT_LANDED_SELECTOR,
|
|
6
|
+
} from '../consts.local.js'
|
|
7
|
+
import type {
|
|
8
|
+
EmailFormLoginOptions, EmailFormLoginResult, EmailLoginFlow, EmailLoginFlowDeps, EmailWaiverRouteOptions,
|
|
9
|
+
} from './types.js'
|
|
10
|
+
|
|
11
|
+
/** `/auth/email` however it was written — one leading slash, no trailing one. */
|
|
12
|
+
const apiPathOf = (path?: string): string => `/${(path ?? EMAIL_AUTH_API_PATH).replace(/^\/+|\/+$/g, '')}`
|
|
13
|
+
|
|
14
|
+
export const makeEmailLoginFlow = (page: Page, deps: EmailLoginFlowDeps): EmailLoginFlow => {
|
|
15
|
+
const routeEmailWaiver = async (waiver: string, opts?: EmailWaiverRouteOptions): Promise<() => Promise<void>> => {
|
|
16
|
+
const marker = `${apiPathOf(opts?.apiPath)}/`
|
|
17
|
+
const matches = (url: URL): boolean => url.pathname.includes(marker)
|
|
18
|
+
const handler = async (route: Parameters<Parameters<Page['route']>[1]>[0]): Promise<void> => {
|
|
19
|
+
await route.continue({ headers: { ...route.request().headers(), [EMAIL_WAIVER_HEADER]: waiver } })
|
|
20
|
+
}
|
|
21
|
+
await page.route(matches, handler)
|
|
22
|
+
|
|
23
|
+
return async () => { await page.unroute(matches, handler) }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const loginViaEmailForm = async (opts: EmailFormLoginOptions): Promise<EmailFormLoginResult> => {
|
|
27
|
+
const timeout = opts.timeout ?? DEFAULT_EMAIL_LOGIN_TIMEOUT
|
|
28
|
+
const waitUntil = opts.waitUntil ?? 'domcontentloaded'
|
|
29
|
+
const path = opts.path ?? DEFAULT_EMAIL_LOGIN_PATH
|
|
30
|
+
const apiPath = apiPathOf(opts.apiPath)
|
|
31
|
+
const result: EmailFormLoginResult = {
|
|
32
|
+
mode: opts.password != null ? 'password' : 'pin', device: false, pins: 0, offer: 'none', marketingConsent: false,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The answer of one e-mail POST, waited for from before the click that sends it. */
|
|
36
|
+
const answerOf = (route: string): Promise<Response> => page.waitForResponse(response =>
|
|
37
|
+
response.request().method() === 'POST' && new URL(response.url()).pathname.endsWith(`${apiPath}${route}`),
|
|
38
|
+
{ timeout })
|
|
39
|
+
|
|
40
|
+
const failed = async (what: string, response: Response): Promise<never> => {
|
|
41
|
+
const refusal = await page.locator('[data-email-login-error]').first()
|
|
42
|
+
.getAttribute('data-refusal', { timeout: 2_000 }).catch(() => null)
|
|
43
|
+
throw new Error(`[@owlmeans/test-ui] ${what} answered ${response.status()}${refusal != null ? ` (${refusal})` : ''}`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const enterPin = async (challenge: string): Promise<void> => {
|
|
47
|
+
const pin = await opts.rewritePin(challenge)
|
|
48
|
+
const field = page.locator('[data-email-login-pin]')
|
|
49
|
+
await field.waitFor({ state: 'visible', timeout })
|
|
50
|
+
await field.fill(pin, { timeout })
|
|
51
|
+
const answer = answerOf('/sign-in')
|
|
52
|
+
await page.locator('[data-email-login-submit]').click({ timeout })
|
|
53
|
+
const response = await answer
|
|
54
|
+
if (!response.ok()) {
|
|
55
|
+
await failed('PIN sign-in', response)
|
|
56
|
+
}
|
|
57
|
+
result.pins++
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Answer the offer — one with nothing to offer (`data-state="leaving"`) moves on by itself. */
|
|
61
|
+
const answerOffer = async (): Promise<void> => {
|
|
62
|
+
const offer = page.locator('[data-email-offer]')
|
|
63
|
+
if (await offer.getAttribute('data-state', { timeout }).catch(() => null) === 'leaving') {
|
|
64
|
+
await offer.waitFor({ state: 'detached', timeout })
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
if (typeof opts.offer === 'object') {
|
|
68
|
+
await page.locator('[data-email-offer-password]').fill(opts.offer.password, { timeout })
|
|
69
|
+
await page.locator('[data-email-offer-repeat]').fill(opts.offer.password, { timeout })
|
|
70
|
+
// `force`: the save is never natively disabled, and a refused password must surface below.
|
|
71
|
+
await page.locator('[data-email-offer-save]').click({ timeout, force: true })
|
|
72
|
+
result.offer = 'set'
|
|
73
|
+
} else {
|
|
74
|
+
await page.locator('[data-email-offer-skip]').click({ timeout })
|
|
75
|
+
result.offer = 'skipped'
|
|
76
|
+
}
|
|
77
|
+
const outcome = await Promise.any([
|
|
78
|
+
offer.waitFor({ state: 'detached', timeout }).then(() => 'left' as const),
|
|
79
|
+
page.locator('[data-email-offer-error]').waitFor({ state: 'visible', timeout }).then(() => 'error' as const),
|
|
80
|
+
]).catch(() => 'stuck' as const)
|
|
81
|
+
if (outcome !== 'left') {
|
|
82
|
+
const refusal = await page.locator('[data-email-offer-error]').getAttribute('data-refusal').catch(() => null)
|
|
83
|
+
throw new Error(`[@owlmeans/test-ui] the password offer did not move on (${refusal ?? outcome})`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Which post-sign-in surface is up next: a step, the landing, or nothing within the budget. */
|
|
88
|
+
const next = async (): Promise<'offer' | 'consent' | 'landed' | 'none'> => {
|
|
89
|
+
const candidates: Array<Promise<'offer' | 'consent' | 'landed'>> = [
|
|
90
|
+
page.locator('[data-email-offer]').waitFor({ state: 'visible', timeout }).then(() => 'offer' as const),
|
|
91
|
+
page.locator('[data-marketing-consent]').waitFor({ state: 'visible', timeout }).then(() => 'consent' as const),
|
|
92
|
+
page.locator(opts.landedSelector ?? DEFAULT_LANDED_SELECTOR).first().waitFor({ state: 'visible', timeout })
|
|
93
|
+
.then(() => 'landed' as const),
|
|
94
|
+
]
|
|
95
|
+
if (opts.expectPath != null) {
|
|
96
|
+
candidates.push(page.waitForURL(url => url.toString().includes(opts.expectPath!), { timeout })
|
|
97
|
+
.then(() => 'landed' as const))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return await Promise.any(candidates).catch(() => 'none' as const)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const removeWaiver = opts.waiver != null ? await routeEmailWaiver(opts.waiver, { apiPath }) : null
|
|
104
|
+
try {
|
|
105
|
+
if (opts.start === 'dispatcher') {
|
|
106
|
+
await page.goto(new URL(opts.dispatcherPath ?? DEFAULT_DISPATCHER_PATH, opts.baseUrl).toString(), { waitUntil, timeout })
|
|
107
|
+
// The app is up once either the cookie dialog or the method button is — see `loginViaSupervisorForm`.
|
|
108
|
+
await page.locator('[data-consent-dialog], [data-login-method="email"]').first().waitFor({ state: 'visible', timeout })
|
|
109
|
+
if (opts.consent !== 'ignore') await deps.acceptConsent({ timeout })
|
|
110
|
+
const terms = page.locator('[data-login-terms]')
|
|
111
|
+
if (await terms.count() > 0 && !(await terms.isChecked())) {
|
|
112
|
+
await terms.check({ timeout })
|
|
113
|
+
}
|
|
114
|
+
await page.locator('[data-login-method="email"]').click({ timeout })
|
|
115
|
+
} else {
|
|
116
|
+
await page.goto(new URL(path, opts.baseUrl).toString(), { waitUntil, timeout })
|
|
117
|
+
await page.locator('[data-consent-dialog], [data-email-login-email]').first().waitFor({ state: 'visible', timeout })
|
|
118
|
+
if (opts.consent !== 'ignore') await deps.acceptConsent({ timeout })
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const email = page.locator('[data-email-login-email]')
|
|
122
|
+
await email.waitFor({ state: 'visible', timeout })
|
|
123
|
+
|
|
124
|
+
if (opts.password != null) {
|
|
125
|
+
await page.locator('[data-email-login-use-password]').click({ timeout })
|
|
126
|
+
await email.fill(opts.email, { timeout })
|
|
127
|
+
await page.locator('[data-email-login-password]').fill(opts.password, { timeout })
|
|
128
|
+
if (opts.screenshotDir != null) await deps.saveScreenshot(opts.screenshotDir, 'email-login-form')
|
|
129
|
+
const answer = answerOf('/sign-in')
|
|
130
|
+
await page.locator('[data-email-login-submit]').click({ timeout })
|
|
131
|
+
const response = await answer
|
|
132
|
+
if (!response.ok()) {
|
|
133
|
+
await failed('password sign-in', response)
|
|
134
|
+
}
|
|
135
|
+
const view = await response.json().catch(() => ({})) as EmailSignInView
|
|
136
|
+
if (view.reason === EmailSignInReason.Device && typeof view.challenge === 'string') {
|
|
137
|
+
result.device = true
|
|
138
|
+
await enterPin(view.challenge)
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
await email.fill(opts.email, { timeout })
|
|
142
|
+
if (opts.screenshotDir != null) await deps.saveScreenshot(opts.screenshotDir, 'email-login-form')
|
|
143
|
+
const answer = answerOf('/pin')
|
|
144
|
+
await page.locator('[data-email-login-send]').click({ timeout })
|
|
145
|
+
const response = await answer
|
|
146
|
+
if (!response.ok()) {
|
|
147
|
+
await failed('send-PIN', response)
|
|
148
|
+
}
|
|
149
|
+
await enterPin((await response.json() as EmailChallengeView).challenge)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// A finished sign-in leaves the card for its landing: a step first, if one is pending.
|
|
153
|
+
await page.waitForURL(url => !url.pathname.startsWith(path), { timeout })
|
|
154
|
+
|
|
155
|
+
for (let round = 0; round < 3; round++) {
|
|
156
|
+
const shown = await next()
|
|
157
|
+
if (shown === 'offer' && result.offer === 'none') {
|
|
158
|
+
if (opts.offer === 'ignore') {
|
|
159
|
+
result.offer = 'shown'
|
|
160
|
+
break
|
|
161
|
+
}
|
|
162
|
+
await answerOffer()
|
|
163
|
+
continue
|
|
164
|
+
}
|
|
165
|
+
if (shown === 'consent' && !result.marketingConsent && opts.marketingConsent !== 'ignore') {
|
|
166
|
+
result.marketingConsent = await deps.answerMarketingConsent({ accept: 'all', timeout })
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
break
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (opts.expectPath != null && result.offer !== 'shown') {
|
|
173
|
+
await page.waitForURL(url => url.toString().includes(opts.expectPath!), { timeout })
|
|
174
|
+
}
|
|
175
|
+
} finally {
|
|
176
|
+
await removeWaiver?.()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { routeEmailWaiver, loginViaEmailForm }
|
|
183
|
+
}
|
package/src/page/types.ts
CHANGED
|
@@ -72,6 +72,77 @@ export interface SupervisorFormLoginOptions {
|
|
|
72
72
|
marketingConsent?: 'save' | 'ignore'
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
export interface EmailWaiverRouteOptions {
|
|
76
|
+
/** The e-mail routes' base path; default `EMAIL_AUTH_API_PATH` (`/auth/email`). */
|
|
77
|
+
apiPath?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface EmailFormLoginOptions {
|
|
81
|
+
baseUrl: string
|
|
82
|
+
/** The address to sign in (registered by its first PIN sign-in). */
|
|
83
|
+
email: string
|
|
84
|
+
/**
|
|
85
|
+
* Turns each mailed challenge into the PIN to type — normally `makeEmailTechClient(…).rewritePin`.
|
|
86
|
+
* Called once per challenge the form receives: the send-PIN answer, or a password sign-in's
|
|
87
|
+
* device answer.
|
|
88
|
+
*/
|
|
89
|
+
rewritePin: (challenge: string) => Promise<string>
|
|
90
|
+
/**
|
|
91
|
+
* Sign in with this password instead of asking for a PIN. On a device the account does not know
|
|
92
|
+
* the server mails a PIN instead (`reason: 'device'`), which the helper then answers like any other.
|
|
93
|
+
*/
|
|
94
|
+
password?: string
|
|
95
|
+
/**
|
|
96
|
+
* A developer waiver (`makeEmailTechClient(…).waiver()`): sent in `EMAIL_WAIVER_HEADER` on the
|
|
97
|
+
* e-mail routes only — never on any other request — while this login runs.
|
|
98
|
+
*/
|
|
99
|
+
waiver?: string
|
|
100
|
+
/**
|
|
101
|
+
* `email` (default) opens the e-mail card at `path` directly; `dispatcher` opens the chooser at
|
|
102
|
+
* `dispatcherPath` and presses "Continue with email" (`[data-login-method="email"]`), ticking a
|
|
103
|
+
* Terms box first when the chooser shows one.
|
|
104
|
+
*/
|
|
105
|
+
start?: 'email' | 'dispatcher'
|
|
106
|
+
/** The e-mail card's path; default `/authentication/login/email`. */
|
|
107
|
+
path?: string
|
|
108
|
+
/** The chooser's path; default `/dispatcher`. */
|
|
109
|
+
dispatcherPath?: string
|
|
110
|
+
/** The e-mail routes' base path, as their URLs end; default `/auth/email`. */
|
|
111
|
+
apiPath?: string
|
|
112
|
+
/**
|
|
113
|
+
* The post-sign-in password offer: `'skip'` (default) presses "Not now"; `{ password }` sets that
|
|
114
|
+
* password; `'ignore'` leaves the step on screen for the spec.
|
|
115
|
+
*/
|
|
116
|
+
offer?: 'skip' | 'ignore' | { password: string }
|
|
117
|
+
/** Answer the marketing-consent step (`'save'`, default) or leave it to the spec (`'ignore'`). */
|
|
118
|
+
marketingConsent?: 'save' | 'ignore'
|
|
119
|
+
/** What counts as landed: a URL containing this. Default — the landed marker (`landedSelector`). */
|
|
120
|
+
expectPath?: string
|
|
121
|
+
/** The element a landed app shows; default `#app-prompt`. Without it and `expectPath` the wait costs the full timeout. */
|
|
122
|
+
landedSelector?: string
|
|
123
|
+
/** One budget for every wait; default 60s. */
|
|
124
|
+
timeout?: number
|
|
125
|
+
/** Default `domcontentloaded` — see `MountOptions.waitUntil`. */
|
|
126
|
+
waitUntil?: 'commit' | 'domcontentloaded' | 'load' | 'networkidle'
|
|
127
|
+
/** The cookie-consent dialog: `'accept'` (default) or `'ignore'`. */
|
|
128
|
+
consent?: 'accept' | 'ignore'
|
|
129
|
+
/** When set, capture the filled form (`email-login-form.png`) before it is submitted. */
|
|
130
|
+
screenshotDir?: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** What a {@link PageHelper.loginViaEmailForm} went through. */
|
|
134
|
+
export interface EmailFormLoginResult {
|
|
135
|
+
mode: 'pin' | 'password'
|
|
136
|
+
/** A password sign-in met an unknown device and was finished with a PIN. */
|
|
137
|
+
device: boolean
|
|
138
|
+
/** PIN challenges answered. */
|
|
139
|
+
pins: number
|
|
140
|
+
/** The password offer: never shown, skipped, answered with a password, or left on screen. */
|
|
141
|
+
offer: 'none' | 'skipped' | 'set' | 'shown'
|
|
142
|
+
/** The marketing-consent step was shown and answered. */
|
|
143
|
+
marketingConsent: boolean
|
|
144
|
+
}
|
|
145
|
+
|
|
75
146
|
/** Driving one page of an OwlMeans app: consent dialogs, the login flows, screenshots. */
|
|
76
147
|
export interface PageHelper {
|
|
77
148
|
/**
|
|
@@ -141,4 +212,27 @@ export interface PageHelper {
|
|
|
141
212
|
* the app to leave the login screen.
|
|
142
213
|
*/
|
|
143
214
|
loginViaSupervisorForm: (opts: SupervisorFormLoginOptions) => Promise<void>
|
|
215
|
+
/**
|
|
216
|
+
* Send `waiver` in `EMAIL_WAIVER_HEADER` on every request of this page whose URL path contains
|
|
217
|
+
* `<apiPath>/` — and on nothing else. Resolves the function that stops it.
|
|
218
|
+
*
|
|
219
|
+
* It is a `page.route`, and routing turns Playwright's HTTP cache off for the page while it is
|
|
220
|
+
* installed; the predicate keeps every other request untouched otherwise.
|
|
221
|
+
*/
|
|
222
|
+
routeEmailWaiver: (waiver: string, opts?: EmailWaiverRouteOptions) => Promise<() => Promise<void>>
|
|
223
|
+
/**
|
|
224
|
+
* Sign in through the real e-mail card (`@owlmeans/web-auth-email`): open it (or the chooser),
|
|
225
|
+
* answer the cookie dialog, type the address, send for a PIN — the challenge is read from the
|
|
226
|
+
* send-PIN answer and handed to `rewritePin` for the PIN to type — then submit it. With `password`
|
|
227
|
+
* the password is tried first, and a device answer is finished with a PIN. After the sign-in it
|
|
228
|
+
* answers the password offer and the marketing-consent step in whatever order they come, and
|
|
229
|
+
* waits for the landing (`expectPath`, else `landedSelector`).
|
|
230
|
+
*/
|
|
231
|
+
loginViaEmailForm: (opts: EmailFormLoginOptions) => Promise<EmailFormLoginResult>
|
|
144
232
|
}
|
|
233
|
+
|
|
234
|
+
/** The e-mail half of {@link PageHelper}, built over the page and the helper's own consent answers. */
|
|
235
|
+
export interface EmailLoginFlow extends Pick<PageHelper, 'routeEmailWaiver' | 'loginViaEmailForm'> {}
|
|
236
|
+
|
|
237
|
+
/** What the e-mail flow borrows from the page helper. */
|
|
238
|
+
export interface EmailLoginFlowDeps extends Pick<PageHelper, 'acceptConsent' | 'answerMarketingConsent' | 'saveScreenshot'> {}
|
package/src/page.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import type {
|
|
8
8
|
AcceptConsentOptions, AnswerMarketingConsentOptions, DispatcherLoginOptions, PageHelper, SupervisorFormLoginOptions,
|
|
9
9
|
} from './page/types.js'
|
|
10
|
+
import { makeEmailLoginFlow } from './page/email.js'
|
|
10
11
|
|
|
11
12
|
export const makePageHelper = (page: Page): PageHelper => {
|
|
12
13
|
const answerMarketingConsent = async (opts?: AnswerMarketingConsentOptions): Promise<boolean> => {
|
|
@@ -190,5 +191,10 @@ export const makePageHelper = (page: Page): PageHelper => {
|
|
|
190
191
|
if (opts.marketingConsent !== 'ignore') await answerMarketingConsent({ accept: 'all', timeout })
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
|
|
194
|
+
const email = makeEmailLoginFlow(page, { acceptConsent, answerMarketingConsent, saveScreenshot })
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
answerMarketingConsent, loginViaDispatcher, saveScreenshot, acceptConsent, loginViaSupervisorForm,
|
|
198
|
+
routeEmailWaiver: email.routeEmailWaiver, loginViaEmailForm: email.loginViaEmailForm,
|
|
199
|
+
}
|
|
194
200
|
}
|