@jskit-ai/auth-web 0.2.15 → 0.2.17
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 +9 -0
- package/fixtures/sign-in/main.js +24 -1
- package/fixtures/sign-in/vite.config.mjs +2 -0
- package/locales/en.json +2 -1
- package/package.json +8 -8
- package/patterns/auth-surface/PATTERN.md +18 -5
- package/patterns/auth-surface/example/src/components/AppBrand.vue +17 -0
- package/patterns/auth-surface/example/src/pages/auth/login.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/reset-password.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/signout.vue +2 -2
- package/patterns/auth-surface/example/src/views/auth/LoginView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/ResetPasswordView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/SignOutView.vue +6 -1
- package/src/client/composables/loginView/constants.js +2 -2
- package/src/client/composables/loginView/useLoginViewState.js +5 -1
- package/src/client/views/AuthProfileWidget.vue +28 -2
- package/src/client/views/AuthScreen.vue +98 -0
- package/src/client/views/DefaultLoginView.vue +294 -290
- package/src/client/views/DefaultResetPasswordView.vue +61 -85
- package/src/client/views/DefaultSignOutView.vue +62 -43
- package/src/test/playwright.js +36 -15
- package/test/authSurfacePatternBrand.test.js +34 -0
- package/test/clientSurface.test.js +29 -26
- package/test/playwright.test.js +82 -22
- package/test/signIn.browser.test.js +214 -0
package/test/playwright.test.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
+
import { createServer } from "node:http";
|
|
2
3
|
import test from "node:test";
|
|
4
|
+
import { request as playwrightRequest } from "@playwright/test";
|
|
3
5
|
import { DEV_AUTH_SECRET_HEADER } from "@jskit-ai/auth-core/server/devAuth";
|
|
4
|
-
import { loginAsExistingUser } from "../src/test/playwright.js";
|
|
6
|
+
import { loginAsExistingUser, loginRequestAsExistingUser } from "../src/test/playwright.js";
|
|
5
7
|
|
|
6
|
-
function createResponse({ status = 200, body = {} } = {}) {
|
|
8
|
+
function createResponse({ status = 200, body = {}, url = "" } = {}) {
|
|
7
9
|
return {
|
|
10
|
+
url() {
|
|
11
|
+
return url;
|
|
12
|
+
},
|
|
8
13
|
ok() {
|
|
9
14
|
return status >= 200 && status < 300;
|
|
10
15
|
},
|
|
@@ -38,10 +43,11 @@ function setPlaywrightEnv(context, env) {
|
|
|
38
43
|
test("local Playwright login exchanges CSRF and the private secret in the page context", async (context) => {
|
|
39
44
|
setPlaywrightEnv(context, {});
|
|
40
45
|
const calls = [];
|
|
46
|
+
// As Playwright's request context does, a path alone resolves against the context's baseURL.
|
|
41
47
|
const request = {
|
|
42
48
|
async get(url) {
|
|
43
49
|
calls.push({ method: "GET", url });
|
|
44
|
-
return createResponse({ body: { csrfToken: "csrf-test" } });
|
|
50
|
+
return createResponse({ body: { csrfToken: "csrf-test" }, url: new URL(url, "http://127.0.0.1:4173").href });
|
|
45
51
|
},
|
|
46
52
|
async post(url, options) {
|
|
47
53
|
calls.push({ method: "POST", url, options });
|
|
@@ -66,7 +72,7 @@ test("local Playwright login exchanges CSRF and the private secret in the page c
|
|
|
66
72
|
assert.deepEqual(calls, [
|
|
67
73
|
{
|
|
68
74
|
method: "GET",
|
|
69
|
-
url: "
|
|
75
|
+
url: "/api/session"
|
|
70
76
|
},
|
|
71
77
|
{
|
|
72
78
|
method: "POST",
|
|
@@ -82,31 +88,85 @@ test("local Playwright login exchanges CSRF and the private secret in the page c
|
|
|
82
88
|
]);
|
|
83
89
|
});
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
/** A worker's app server: answers the session and dev-login routes and records what reached it. */
|
|
92
|
+
async function workerServer(name) {
|
|
93
|
+
const requests = [];
|
|
94
|
+
const server = createServer((request, response) => {
|
|
95
|
+
requests.push(`${request.method} ${request.url}${request.headers[DEV_AUTH_SECRET_HEADER] ? " with the secret" : ""}`);
|
|
96
|
+
response.setHeader("content-type", "application/json");
|
|
97
|
+
if (request.method === "POST") response.setHeader("set-cookie", `session=${name.replace(" ", "-")}; Path=/; HttpOnly; SameSite=Lax`);
|
|
98
|
+
response.end(JSON.stringify(request.method === "GET" ? { csrfToken: `csrf-${name}` } : { ok: true, server: name }));
|
|
99
|
+
});
|
|
100
|
+
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
101
|
+
return { requests, port: server.address().port, close: () => new Promise((resolve) => server.close(resolve)) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test("each worker signs in on its own server, its context's baseURL, whatever PLAYWRIGHT_PORT says", async (context) => {
|
|
105
|
+
const first = await workerServer("worker 0");
|
|
106
|
+
const second = await workerServer("worker 1");
|
|
107
|
+
// The runner's base port is worker 0's; worker 1's config gives its contexts the next server.
|
|
108
|
+
setPlaywrightEnv(context, { PLAYWRIGHT_PORT: String(first.port) });
|
|
109
|
+
const request = await playwrightRequest.newContext({ baseURL: `http://127.0.0.1:${second.port}` });
|
|
110
|
+
context.after(async () => {
|
|
111
|
+
await request.dispose();
|
|
112
|
+
await Promise.all([first.close(), second.close()]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const result = await loginAsExistingUser({ context: () => ({ request }) }, { email: "ada@example.com", secret: "private-test-secret" });
|
|
116
|
+
|
|
117
|
+
assert.deepEqual(result, { ok: true, server: "worker 1" });
|
|
118
|
+
assert.deepEqual(second.requests, ["GET /api/session", "POST /api/dev-auth/login-as with the secret"]);
|
|
119
|
+
assert.deepEqual(first.requests, []);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("a browser test worker's request context signs in once and keeps the session in its storage state", async (context) => {
|
|
123
|
+
setPlaywrightEnv(context, {});
|
|
124
|
+
const server = await workerServer("worker 0");
|
|
125
|
+
const request = await playwrightRequest.newContext({ baseURL: `http://127.0.0.1:${server.port}` });
|
|
126
|
+
context.after(async () => {
|
|
127
|
+
await request.dispose();
|
|
128
|
+
await server.close();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const result = await loginRequestAsExistingUser(request, { email: "ada@example.com", secret: "private-test-secret" });
|
|
132
|
+
|
|
133
|
+
assert.deepEqual(result, { ok: true, server: "worker 0" });
|
|
134
|
+
assert.deepEqual(server.requests, ["GET /api/session", "POST /api/dev-auth/login-as with the secret"]);
|
|
135
|
+
// What browserTestConfig() leaves for the worker's tests: the signed-in session's cookie.
|
|
136
|
+
assert.deepEqual((await request.storageState()).cookies.map(({ name, value }) => `${name}=${value}`), ["session=worker-0"]);
|
|
137
|
+
await assert.rejects(loginRequestAsExistingUser({}, { email: "ada@example.com", secret: "private-test-secret" }),
|
|
138
|
+
/requires a Playwright APIRequestContext/u);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("local Playwright login refuses a managed target before any request when no base URL is given", async (context) => {
|
|
142
|
+
setPlaywrightEnv(context, { PLAYWRIGHT_BASE_URL: "https://preview.example.test" });
|
|
143
|
+
let requestCount = 0;
|
|
144
|
+
const page = { context: () => ({ request: { async get() { requestCount += 1; } } }) };
|
|
145
|
+
|
|
146
|
+
await assert.rejects(
|
|
147
|
+
loginAsExistingUser(page, { email: "ada@example.com", secret: "private-test-secret" }),
|
|
148
|
+
/only sends the dev-auth secret to a local app URL/u
|
|
149
|
+
);
|
|
150
|
+
assert.equal(requestCount, 0);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("local Playwright login sends the secret only to a local server that answered the session request", async (context) => {
|
|
154
|
+
setPlaywrightEnv(context, {});
|
|
155
|
+
const posts = [];
|
|
87
156
|
const request = {
|
|
88
157
|
async get(url) {
|
|
89
|
-
|
|
90
|
-
return createResponse({ body: { csrfToken: "csrf-test" } });
|
|
158
|
+
return createResponse({ body: { csrfToken: "csrf-test" }, url: new URL(url, "https://app.example.test").href });
|
|
91
159
|
},
|
|
92
160
|
async post(url) {
|
|
93
|
-
|
|
94
|
-
return createResponse({ body: { ok: true, userId: "7" } });
|
|
161
|
+
posts.push(url);
|
|
95
162
|
}
|
|
96
163
|
};
|
|
97
|
-
const page = {
|
|
98
|
-
context() {
|
|
99
|
-
return { request };
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
setPlaywrightEnv(context, { PLAYWRIGHT_PORT: "4183" });
|
|
103
|
-
|
|
104
|
-
await loginAsExistingUser(page, { email: "ada@example.com", secret: "private-test-secret" });
|
|
105
164
|
|
|
106
|
-
assert.
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
165
|
+
await assert.rejects(
|
|
166
|
+
loginAsExistingUser({ context: () => ({ request }) }, { email: "ada@example.com", secret: "private-test-secret" }),
|
|
167
|
+
/only sends the dev-auth secret to a local app URL/u
|
|
168
|
+
);
|
|
169
|
+
assert.deepEqual(posts, []);
|
|
110
170
|
});
|
|
111
171
|
|
|
112
172
|
test("local Playwright login refuses to send the private secret to a managed URL", async () => {
|
|
@@ -486,3 +486,217 @@ test("a failed sign-out shows the error and retries, on a phone-sized screen", o
|
|
|
486
486
|
await expect(page.locator(".login-screen--mobile")).toHaveCount(1);
|
|
487
487
|
await finish(api);
|
|
488
488
|
});
|
|
489
|
+
|
|
490
|
+
// The app bar's account control leaves the bar's title and actions their room: an icon button around the avatar on
|
|
491
|
+
// compact and medium windows, and on expanded ones the name beside it, ending in an ellipsis past 12rem.
|
|
492
|
+
test("the account control is the avatar alone up to medium width and truncates a long name beside it on wider windows", options, async () => {
|
|
493
|
+
const name = "Augusta Ada King, Countess of Lovelace and First Programmer";
|
|
494
|
+
const api = await openApp({ session: { ...SIGNED_IN, username: name }, viewport: { width: 768, height: 1024 } });
|
|
495
|
+
const { page } = api;
|
|
496
|
+
await page.goto("/home");
|
|
497
|
+
const control = page.getByRole("button", { name });
|
|
498
|
+
await expect(control).toBeVisible();
|
|
499
|
+
assert.equal(await control.evaluate((element) => element.classList.contains("v-btn--icon")), true, "an icon button at 768");
|
|
500
|
+
await expect(page.locator(".auth-profile-widget__name")).toHaveCount(0);
|
|
501
|
+
|
|
502
|
+
await page.setViewportSize({ width: 1280, height: 900 });
|
|
503
|
+
const label = page.locator(".auth-profile-widget__name");
|
|
504
|
+
await expect(label).toHaveText(name);
|
|
505
|
+
const shown = await label.evaluate((element) => ({
|
|
506
|
+
width: element.getBoundingClientRect().width,
|
|
507
|
+
truncated: element.scrollWidth > element.clientWidth,
|
|
508
|
+
rem: Number.parseFloat(getComputedStyle(document.documentElement).fontSize)
|
|
509
|
+
}));
|
|
510
|
+
assert.ok(shown.width <= 12 * shown.rem + 1, `the name takes at most 12rem: ${shown.width}px`);
|
|
511
|
+
assert.equal(shown.truncated, true, "a long name ends in an ellipsis");
|
|
512
|
+
await finish(api);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// Material 3's segmented button: one outline, equal segments, the selected one on secondary-container with a check.
|
|
516
|
+
// Register has no "Back to sign in": the Sign in segment is the way back.
|
|
517
|
+
test("Sign in and Register are a segmented button, and Register has no way back but its segment", options, async () => {
|
|
518
|
+
const api = await openApp();
|
|
519
|
+
const { page } = api;
|
|
520
|
+
await page.goto("/auth/login");
|
|
521
|
+
const group = page.getByRole("radiogroup", { name: "Sign in or register" });
|
|
522
|
+
await expect(group).toBeVisible();
|
|
523
|
+
const read = () => group.evaluate((element) => {
|
|
524
|
+
const role = (name) => {
|
|
525
|
+
const probe = document.body.appendChild(document.createElement("span"));
|
|
526
|
+
probe.style.color = `rgb(var(--v-theme-${name}))`;
|
|
527
|
+
const color = getComputedStyle(probe).color;
|
|
528
|
+
probe.remove();
|
|
529
|
+
return color;
|
|
530
|
+
};
|
|
531
|
+
const style = getComputedStyle(element);
|
|
532
|
+
return {
|
|
533
|
+
outline: [style.borderTopWidth, style.borderTopColor === role("outline"), style.borderTopLeftRadius],
|
|
534
|
+
height: element.getBoundingClientRect().height,
|
|
535
|
+
segments: [...element.querySelectorAll("[role=radio]")].map((segment) => {
|
|
536
|
+
const segmentStyle = getComputedStyle(segment);
|
|
537
|
+
return {
|
|
538
|
+
name: segment.textContent.trim(),
|
|
539
|
+
checked: segment.getAttribute("aria-checked"),
|
|
540
|
+
width: Math.round(segment.getBoundingClientRect().width),
|
|
541
|
+
check: segment.querySelectorAll(".v-btn__prepend .v-icon").length,
|
|
542
|
+
filled: segmentStyle.backgroundColor === role("secondary-container"),
|
|
543
|
+
type: [segmentStyle.fontSize, segmentStyle.fontWeight]
|
|
544
|
+
};
|
|
545
|
+
})
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
const expected = (selected) => {
|
|
549
|
+
const segments = ["Sign in", "Register"].map((name) => ({
|
|
550
|
+
name,
|
|
551
|
+
checked: String(name === selected),
|
|
552
|
+
check: name === selected ? 1 : 0,
|
|
553
|
+
filled: name === selected,
|
|
554
|
+
type: ["14px", "500"]
|
|
555
|
+
}));
|
|
556
|
+
return { outline: ["1px", true, "9999px"], height: 40, segments };
|
|
557
|
+
};
|
|
558
|
+
const withoutWidths = ({ segments, ...rest }) => ({ ...rest, segments: segments.map(({ width, ...segment }) => segment) });
|
|
559
|
+
|
|
560
|
+
const layout = await read();
|
|
561
|
+
assert.deepEqual(withoutWidths(layout), expected("Sign in"));
|
|
562
|
+
assert.equal(layout.segments[0].width, layout.segments[1].width, "the segments are equal");
|
|
563
|
+
|
|
564
|
+
await page.getByRole("radio", { name: "Register" }).click();
|
|
565
|
+
await expect(page.getByRole("heading", { level: 1, name: "Create your account" })).toBeVisible();
|
|
566
|
+
// The segments' fill changes through Vuetify's background transition.
|
|
567
|
+
await expect.poll(async () => withoutWidths(await read())).toEqual(expected("Register"));
|
|
568
|
+
await expect(page.getByRole("button", { name: "Back to sign in" })).toHaveCount(0);
|
|
569
|
+
await expect(page.getByText("Already have an account?")).toHaveCount(0);
|
|
570
|
+
|
|
571
|
+
await page.getByRole("radio", { name: "Sign in" }).click();
|
|
572
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
573
|
+
await finish(api);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test("every auth screen has its one h1, sign-in's included", options, async () => {
|
|
577
|
+
const api = await openApp({
|
|
578
|
+
routes: {
|
|
579
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
580
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
const { page } = api;
|
|
584
|
+
const heading = async (name) => {
|
|
585
|
+
await expect(page.getByRole("heading", { level: 1, name })).toBeVisible();
|
|
586
|
+
assert.equal(await page.locator("h1").count(), 1, `one h1 for ${name}`);
|
|
587
|
+
};
|
|
588
|
+
await page.goto("/auth/login");
|
|
589
|
+
await heading("Sign in");
|
|
590
|
+
await page.getByTestId("auth-mode-register").click();
|
|
591
|
+
await heading("Create your account");
|
|
592
|
+
await page.getByTestId("auth-mode-sign-in").click();
|
|
593
|
+
await page.getByRole("button", { name: "Forgot password?" }).click();
|
|
594
|
+
await heading("Reset your password");
|
|
595
|
+
await page.goto("/auth/reset-password?token=stale");
|
|
596
|
+
await heading("Reset password");
|
|
597
|
+
await page.goto("/auth/signout");
|
|
598
|
+
await heading("Signing you out");
|
|
599
|
+
await finish(api);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test("an app's brand shows in a pane beside the card on wide windows and in a row above it on phones", options, async () => {
|
|
603
|
+
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
|
604
|
+
const at = `${viewport.width}px`;
|
|
605
|
+
const api = await openApp({
|
|
606
|
+
viewport,
|
|
607
|
+
routes: {
|
|
608
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
609
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
const { page } = api;
|
|
613
|
+
for (const [path, title] of [["/auth/branded/login", "Sign in"], ["/auth/branded/reset-password?token=stale", "Reset password"], ["/auth/branded/signout", "Signing you out"]]) {
|
|
614
|
+
await page.goto(path);
|
|
615
|
+
await expect(page.getByRole("heading", { level: 1, name: title }), `${at} ${path}`).toBeVisible();
|
|
616
|
+
const layout = await page.evaluate(() => {
|
|
617
|
+
const box = (selector) => document.querySelector(selector)?.getBoundingClientRect().toJSON() || null;
|
|
618
|
+
const screen = document.querySelector("[data-testid='auth-screen']");
|
|
619
|
+
return {
|
|
620
|
+
pane: box("[data-testid='auth-brand-pane']"),
|
|
621
|
+
row: box("[data-testid='auth-brand-row']"),
|
|
622
|
+
card: box("[data-testid='auth-screen'] .v-card"),
|
|
623
|
+
treatment: (() => {
|
|
624
|
+
const style = window.getComputedStyle(document.querySelector("[data-testid='auth-screen'] .v-card"));
|
|
625
|
+
return { shadow: style.boxShadow, border: style.borderTopWidth, background: style.backgroundColor };
|
|
626
|
+
})(),
|
|
627
|
+
screenBackground: window.getComputedStyle(screen).backgroundColor,
|
|
628
|
+
h1s: document.querySelectorAll("h1").length,
|
|
629
|
+
overflow: screen.scrollWidth - screen.clientWidth
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
assert.equal(layout.h1s, 1, `${at} ${path}: the brand adds no heading`);
|
|
633
|
+
// Vuetify's flat variant computes as zero-size shadow layers: every offset, blur and spread is 0.
|
|
634
|
+
const shadowSizes = layout.treatment.shadow === "none" ? [] : layout.treatment.shadow.replace(/rgba?\([^)]*\)/gu, "").match(/-?[\d.]+px/gu) || [];
|
|
635
|
+
assert.deepEqual(shadowSizes.filter((size) => Number.parseFloat(size) !== 0), [], `${at} ${path}: the card has no shadow (${layout.treatment.shadow})`);
|
|
636
|
+
assert.equal(layout.treatment.border, "0px", `${at} ${path}: the card has no outline`);
|
|
637
|
+
assert.ok(layout.overflow <= 0, `${at} ${path}: no sideways scroll`);
|
|
638
|
+
if (viewport.width >= 960) {
|
|
639
|
+
assert.equal(layout.row, null, `${at} ${path}: no compact row`);
|
|
640
|
+
await expect(page.getByTestId("fixture-brand-pane")).toBeVisible();
|
|
641
|
+
assert.equal(Math.round(layout.pane.left), 0, `${at} ${path}: the pane starts at the window's edge`);
|
|
642
|
+
assert.equal(Math.round(layout.pane.height), viewport.height, `${at} ${path}: the pane fills the height`);
|
|
643
|
+
assert.ok(layout.card.left >= layout.pane.right, `${at} ${path}: the card is beside the pane`);
|
|
644
|
+
assert.notEqual(layout.treatment.background, layout.screenBackground, `${at} ${path}: the card's tone sets it off the screen`);
|
|
645
|
+
} else {
|
|
646
|
+
assert.equal(layout.pane, null, `${at} ${path}: no pane`);
|
|
647
|
+
await expect(page.getByTestId("fixture-brand-row")).toBeVisible();
|
|
648
|
+
assert.ok(layout.row.bottom <= layout.card.top + 1, `${at} ${path}: the row is above the card`);
|
|
649
|
+
assert.equal(Math.round(layout.card.width), viewport.width, `${at} ${path}: the card is full-bleed`);
|
|
650
|
+
assert.ok(Math.round(layout.card.bottom) >= viewport.height, `${at} ${path}: the card fills the rest`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
// Without a brand there is neither.
|
|
654
|
+
await page.goto("/auth/login");
|
|
655
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
656
|
+
await expect(page.getByTestId("auth-brand-pane")).toHaveCount(0);
|
|
657
|
+
await expect(page.getByTestId("auth-brand-row")).toHaveCount(0);
|
|
658
|
+
await finish(api);
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// The auth-surface pattern's own pages, as an app copies them: each renders the app's view wrapper, which puts the
|
|
663
|
+
// app's name (AppBrand.vue, "Reading Room") in the brand slot, so every screen says which app it signs in to.
|
|
664
|
+
test("the auth-surface pattern's sign-in, reset and sign-out pages show the app's name", options, async () => {
|
|
665
|
+
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
|
666
|
+
const at = `${viewport.width}px`;
|
|
667
|
+
const api = await openApp({
|
|
668
|
+
viewport,
|
|
669
|
+
routes: {
|
|
670
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
671
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
const { page } = api;
|
|
675
|
+
for (const [path, title] of [["/auth/pattern/login", "Sign in"], ["/auth/pattern/reset-password?token=stale", "Reset password"], ["/auth/pattern/signout", "Signing you out"]]) {
|
|
676
|
+
await page.goto(path);
|
|
677
|
+
await expect(page.getByRole("heading", { level: 1, name: title }), `${at} ${path}`).toBeVisible();
|
|
678
|
+
const holder = page.getByTestId(viewport.width >= 960 ? "auth-brand-pane" : "auth-brand-row");
|
|
679
|
+
await expect(holder.getByTestId("app-brand"), `${at} ${path}`).toHaveText("Reading Room");
|
|
680
|
+
await expect(page.getByTestId("app-brand"), `${at} ${path}: one brand`).toHaveCount(1);
|
|
681
|
+
await expect(page.getByRole("heading", { level: 1 }), `${at} ${path}: the brand adds no heading`).toHaveCount(1);
|
|
682
|
+
}
|
|
683
|
+
await finish(api);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
test("an app whose accounts are by invitation offers Register only to an invited person", options, async () => {
|
|
688
|
+
const invitationOnly = {
|
|
689
|
+
...SIGNED_OUT,
|
|
690
|
+
authCapabilities: { ...CAPABILITIES, features: { ...CAPABILITIES.features, password: { login: true, register: true, selfRegister: false } } }
|
|
691
|
+
};
|
|
692
|
+
const api = await openApp({ session: invitationOnly });
|
|
693
|
+
const { page } = api;
|
|
694
|
+
await page.goto("/auth/login");
|
|
695
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
696
|
+
// Sign in alone is no choice: no segmented button.
|
|
697
|
+
await expect(page.getByTestId("auth-mode-switch")).toHaveCount(0);
|
|
698
|
+
await page.goto("/auth/login?invitationToken=invite-for-bea");
|
|
699
|
+
await expect(page.getByTestId("auth-mode-sign-in")).toBeVisible();
|
|
700
|
+
await expect(page.getByTestId("auth-mode-register")).toBeVisible();
|
|
701
|
+
await finish(api);
|
|
702
|
+
});
|