All checks were successful
CD / Build and push images (push) Successful in 1m58s
CI / Lint, typecheck, test (push) Successful in 2m29s
CI / Auth e2e pack (push) Successful in 2m55s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 9s
CD / Smoke tests against Test (push) Successful in 1m11s
CD / Promote to Int (push) Successful in 11s
editor.spec.ts still asserted the M2 REST-autosave UI ("saved" indicator,
save-failure retry) that #36/#38 retired for live collaboration — the pack
(not part of CI) has been failing locally ever since. The tests now assert
the collab connection status via the language-neutral data-status
attribute: connected on entry, honest "offline" while disconnected, and
offline edits reaching the server after reconnect (proven across a reload).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PGdhRiwU1WRL4XxJfZYipY
114 lines
4.9 KiB
TypeScript
114 lines
4.9 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
import { contextForUser } from './helpers';
|
|
|
|
/**
|
|
* TipTap editor pack (issue #25, modernized for live collaboration after
|
|
* #36/#38 — the REST autosave and its "saved" indicator are retired; the
|
|
* editor syncs over the collab server and reports a connection status).
|
|
* Runs against the local dev stack (api + web + collab); no Mailpit needed.
|
|
* Creates its own page per test via the api and navigates straight to
|
|
* `/p/:pondSlug/:pageSlug`. Status assertions use the language-neutral
|
|
* `data-status` attribute — the UI language follows the user's locale.
|
|
*/
|
|
const BASE_URL = process.env.E2E_BASE_URL ?? 'http://localhost:5173';
|
|
|
|
async function createPage(
|
|
context: Awaited<ReturnType<typeof contextForUser>>,
|
|
title: string,
|
|
): Promise<{ pondSlug: string; pageSlug: string }> {
|
|
const ponds = await context.request.get('/api/v1/ponds');
|
|
const pond = (await ponds.json()).find((p: { type: string }) => p.type === 'personal');
|
|
const created = await context.request.post(`/api/v1/ponds/${pond.id}/pages`, {
|
|
data: { title },
|
|
});
|
|
const page = await created.json();
|
|
return { pondSlug: pond.slug, pageSlug: page.slug };
|
|
}
|
|
|
|
test('typing persists across reload and undo/redo work', async ({ browser }) => {
|
|
const context = await contextForUser(browser, BASE_URL, 'fixture-user');
|
|
const { pondSlug, pageSlug } = await createPage(context, `E2E Editor ${Date.now()}`);
|
|
const page = await context.newPage();
|
|
|
|
await page.goto(`/p/${pondSlug}/${pageSlug}`);
|
|
await page.getByRole('button', { name: /edit|bearbeiten/i }).click();
|
|
|
|
const status = page.locator('.editor-connection');
|
|
await expect(status).toHaveAttribute('data-status', 'connected', { timeout: 10000 });
|
|
|
|
const content = page.locator('.ProseMirror');
|
|
await expect(content).toHaveAttribute('contenteditable', 'true');
|
|
await content.click();
|
|
await page.keyboard.type('Hello editor');
|
|
await expect(content).toContainText('Hello editor');
|
|
|
|
await page.reload();
|
|
await page.getByRole('button', { name: /edit|bearbeiten/i }).click();
|
|
await expect(content).toHaveAttribute('contenteditable', 'true');
|
|
await expect(content).toContainText('Hello editor');
|
|
|
|
await content.click();
|
|
await page.keyboard.type(' more');
|
|
await expect(content).toContainText('Hello editor more');
|
|
await page.keyboard.press('ControlOrMeta+z');
|
|
await expect(content).toContainText('Hello editor');
|
|
await expect(content).not.toContainText('Hello editor more');
|
|
await page.keyboard.press('ControlOrMeta+y');
|
|
await expect(content).toContainText('Hello editor more');
|
|
|
|
await context.close();
|
|
});
|
|
|
|
test('edit mode hides the sidebar; leaving edit mode restores it', async ({ browser }) => {
|
|
const context = await contextForUser(browser, BASE_URL, 'fixture-user');
|
|
const { pondSlug, pageSlug } = await createPage(context, `E2E Sidebar ${Date.now()}`);
|
|
const page = await context.newPage();
|
|
|
|
await page.goto(`/p/${pondSlug}/${pageSlug}`);
|
|
// CSS selector, not getByRole: aria-hidden removes the element from the
|
|
// accessibility tree, which would make a role-based locator "disappear"
|
|
// exactly when we need to assert that attribute.
|
|
const sidebar = page.locator('nav.sidebar');
|
|
await expect(sidebar).toHaveAttribute('aria-hidden', 'false');
|
|
|
|
await page.getByRole('button', { name: /edit|bearbeiten/i }).click();
|
|
await expect(sidebar).toHaveAttribute('aria-hidden', 'true');
|
|
|
|
await page.getByRole('button', { name: /read|lesen/i }).click();
|
|
await expect(sidebar).toHaveAttribute('aria-hidden', 'false');
|
|
|
|
await context.close();
|
|
});
|
|
|
|
test('going offline is reported honestly and edits sync after reconnect', async ({ browser }) => {
|
|
const context = await contextForUser(browser, BASE_URL, 'fixture-user');
|
|
const { pondSlug, pageSlug } = await createPage(context, `E2E Offline ${Date.now()}`);
|
|
const page = await context.newPage();
|
|
|
|
await page.goto(`/p/${pondSlug}/${pageSlug}`);
|
|
await page.getByRole('button', { name: /edit|bearbeiten/i }).click();
|
|
|
|
const status = page.locator('.editor-connection');
|
|
await expect(status).toHaveAttribute('data-status', 'connected', { timeout: 10000 });
|
|
|
|
const content = page.locator('.ProseMirror');
|
|
await content.click();
|
|
|
|
// Editing keeps working offline; the status tells the truth about it.
|
|
await context.setOffline(true);
|
|
await page.keyboard.type('offline text');
|
|
await expect(content).toContainText('offline text');
|
|
await expect(status).toHaveAttribute('data-status', 'offline', { timeout: 10000 });
|
|
|
|
// Reconnect: the provider resumes and the offline edit reaches the server —
|
|
// proven by a reload, which resolves the page against the live document.
|
|
await context.setOffline(false);
|
|
await expect(status).toHaveAttribute('data-status', 'connected', { timeout: 20000 });
|
|
await page.reload();
|
|
await page.getByRole('button', { name: /edit|bearbeiten/i }).click();
|
|
await expect(content).toContainText('offline text');
|
|
|
|
await context.close();
|
|
});
|