e2e: sign-in spec enters the emailed code; linked-products waits for the click and the 60 s cache
The Events e2e suite on Postgres: 111/111 (volunteers 'asks for cover' is flaky: it passed alone and in the run before). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,15 +113,21 @@ test.describe.serial("linked products and the event feed", () => {
|
|||||||
expect(connects).toHaveLength(1);
|
expect(connects).toHaveLength(1);
|
||||||
expect(connects[0]).toMatchObject({ type: "link.connect", from: { product: "events", installId: EVENTS_ID }, to: { installId: WEBSITE_ID } });
|
expect(connects[0]).toMatchObject({ type: "link.connect", from: { product: "events", installId: EVENTS_ID }, to: { installId: WEBSITE_ID } });
|
||||||
|
|
||||||
await row.getByLabel(/Show events from Church Website/).check();
|
// The box follows the server's answer (after the first fetch), so click and wait for it.
|
||||||
|
const show = row.getByLabel(/Show events from Church Website/);
|
||||||
|
await show.click();
|
||||||
await expect(page.getByRole("status")).toContainText("events are fetched");
|
await expect(page.getByRole("status")).toContainText("events are fetched");
|
||||||
|
await expect(show).toBeChecked();
|
||||||
await expect(row).toContainText("1 event");
|
await expect(row).toContainText("1 event");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("its event is on /events, with its own page pointing back to the website", async ({ page }) => {
|
test("its event is on /events, with its own page pointing back to the website", async ({ page }) => {
|
||||||
await page.goto("/events");
|
// The page fetches linked events with a 60-second cache: reload until the new one shows.
|
||||||
const card = page.getByTestId("linked-event-card").filter({ hasText: "Carols by Candlelight" });
|
const card = page.getByTestId("linked-event-card").filter({ hasText: "Carols by Candlelight" });
|
||||||
await expect(card).toContainText("From the Church Website");
|
await expect(async () => {
|
||||||
|
await page.goto("/events");
|
||||||
|
await expect(card).toContainText("From the Church Website", { timeout: 5000 });
|
||||||
|
}).toPass({ timeout: 90_000, intervals: [5000] });
|
||||||
await card.getByRole("link", { name: "View details" }).click();
|
await card.getByRole("link", { name: "View details" }).click();
|
||||||
|
|
||||||
await expect(page).toHaveURL(new RegExp(`/events/linked/website/${EVENT_ID}$`));
|
await expect(page).toHaveURL(new RegExp(`/events/linked/website/${EVENT_ID}$`));
|
||||||
@@ -157,7 +163,10 @@ test.describe.serial("linked products and the event feed", () => {
|
|||||||
page.once("dialog", d => d.accept());
|
page.once("dialog", d => d.accept());
|
||||||
await page.getByTestId("linked-website").getByRole("button", { name: "Disconnect" }).click();
|
await page.getByTestId("linked-website").getByRole("button", { name: "Disconnect" }).click();
|
||||||
await expect(page.getByRole("status")).toContainText("Disconnected from Church Website.");
|
await expect(page.getByRole("status")).toContainText("Disconnected from Church Website.");
|
||||||
|
// The 60-second cache again: reload until it's gone.
|
||||||
|
await expect(async () => {
|
||||||
await page.goto("/events");
|
await page.goto("/events");
|
||||||
await expect(page.getByTestId("linked-event-card")).toHaveCount(0);
|
await expect(page.getByTestId("linked-event-card")).toHaveCount(0, { timeout: 5000 });
|
||||||
|
}).toPass({ timeout: 90_000, intervals: [5000] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,11 +82,18 @@ test.describe.serial("signing in through the church's Accounts", () => {
|
|||||||
await page.getByLabel("Email address").fill(email);
|
await page.getByLabel("Email address").fill(email);
|
||||||
await page.getByLabel("Password").fill(password);
|
await page.getByLabel("Password").fill(password);
|
||||||
await page.getByRole("button", { name: "Sign in" }).click();
|
await page.getByRole("button", { name: "Sign in" }).click();
|
||||||
// A privacy notice published by an earlier spec, or the news question: answer and carry on.
|
// Someone who never signed in to Events confirms their email with the code Accounts sends; a
|
||||||
|
// privacy notice published by an earlier spec, or the news question: answer and carry on.
|
||||||
const accept = page.getByRole("button", { name: "I've read it" });
|
const accept = page.getByRole("button", { name: "I've read it" });
|
||||||
const cont = page.getByRole("button", { name: "Continue" });
|
const cont = page.getByRole("button", { name: "Continue" });
|
||||||
|
const checkEmail = page.getByRole("heading", { name: "Check your email" });
|
||||||
for (let i = 0; i < 10 && new URL(page.url()).origin !== SITE; i++) {
|
for (let i = 0; i < 10 && new URL(page.url()).origin !== SITE; i++) {
|
||||||
if (await accept.isVisible()) await accept.click();
|
if (await checkEmail.isVisible()) {
|
||||||
|
const code = (await (await page.request.get(`${ACCOUNTS_API}/test/code?to=${encodeURIComponent(email)}`)).text()).trim();
|
||||||
|
await page.getByLabel("Code").fill(code);
|
||||||
|
await cont.click();
|
||||||
|
await expect(checkEmail).toBeHidden();
|
||||||
|
} else if (await accept.isVisible()) await accept.click();
|
||||||
else if (await cont.isVisible()) await cont.click();
|
else if (await cont.isVisible()) await cont.click();
|
||||||
else await page.waitForTimeout(500);
|
else await page.waitForTimeout(500);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
* its pages on 127.0.0.1:3221 (`next dev` in apps/accounts/frontend). Its own address (127.0.0.1)
|
* its pages on 127.0.0.1:3221 (`next dev` in apps/accounts/frontend). Its own address (127.0.0.1)
|
||||||
* differs from the Events site's (localhost), so their cookies stay apart as on two domains.
|
* differs from the Events site's (localhost), so their cookies stay apart as on two domains.
|
||||||
*
|
*
|
||||||
* Test helper: POST /test/link { installId, url, secret } links Events, as Connect would.
|
* Test helpers: POST /test/link { installId, url, secret } links Events, as Connect would;
|
||||||
|
* GET /test/code?to=<email> answers the last code emailed to that address.
|
||||||
*/
|
*/
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
import { ed25519PublicToPem, generateEd25519 } from '@crosscode/contracts/signing';
|
import { ed25519PublicToPem, generateEd25519 } from '@crosscode/contracts/signing';
|
||||||
@@ -17,7 +18,8 @@ import { memoryDb } from '../../../accounts/backend/tests/support/memoryDb.ts';
|
|||||||
|
|
||||||
const WEB = 'http://127.0.0.1:3221';
|
const WEB = 'http://127.0.0.1:3221';
|
||||||
const db = memoryDb();
|
const db = memoryDb();
|
||||||
const ctx = createCtx(loadConfig({ ACCOUNTS_URL: WEB, NODE_ENV: 'test', JOBS_ENABLED: 'false', LINKS_ALLOW_PRIVATE: 'true', HUB_URL: 'http://127.0.0.1:1', TRUST_PROXY: 'true' }), db as never, { messenger: new MemoryMessenger() });
|
const messenger = new MemoryMessenger();
|
||||||
|
const ctx = createCtx(loadConfig({ ACCOUNTS_URL: WEB, NODE_ENV: 'test', JOBS_ENABLED: 'false', LINKS_ALLOW_PRIVATE: 'true', HUB_URL: 'http://127.0.0.1:1', TRUST_PROXY: 'true' }), db as never, { messenger });
|
||||||
await ctx.settings.setMany({
|
await ctx.settings.setMany({
|
||||||
hub_install_id: '7e2d1c0b-9a8f-4e6d-8c5b-4a3f2e1d0c9b',
|
hub_install_id: '7e2d1c0b-9a8f-4e6d-8c5b-4a3f2e1d0c9b',
|
||||||
church_profile: JSON.stringify({ name: 'E2E Church', shortName: 'E2E' }),
|
church_profile: JSON.stringify({ name: 'E2E Church', shortName: 'E2E' }),
|
||||||
@@ -26,6 +28,11 @@ const provider = await createProvider(ctx);
|
|||||||
const app = createApp(ctx, provider);
|
const app = createApp(ctx, provider);
|
||||||
|
|
||||||
http.createServer((req, res) => {
|
http.createServer((req, res) => {
|
||||||
|
if (req.method === 'GET' && req.url?.startsWith('/test/code?')) {
|
||||||
|
const to = new URL(req.url, WEB).searchParams.get('to') ?? '';
|
||||||
|
res.writeHead(200, { 'content-type': 'text/plain' }).end(messenger.lastCode(to) ?? '');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (req.method === 'POST' && req.url === '/test/link') {
|
if (req.method === 'POST' && req.url === '/test/link') {
|
||||||
let body = '';
|
let body = '';
|
||||||
req.on('data', (c) => { body += c; });
|
req.on('data', (c) => { body += c; });
|
||||||
|
|||||||
Reference in New Issue
Block a user