e3823ce470
Add an end-to-end and unit test suite for the SvelteKit frontend:
- Playwright e2e specs (tests/e2e/spa) with a throwaway container stack,
codegen scenarios, and an Istanbul-based coverage report pipeline.
- Vitest unit tests across API endpoints, components, stores and composables.
- `data-testid` hooks on interactive elements (AppShell, FileViewer,
ShareDialog, search, photos, files breadcrumbs, login/Nextcloud flows,
public share pages) so the e2e suite can target them deterministically.
- Serve the SPA app-shell CSP from a <meta> policy (svelte.config.js) plus a
middleware that skips the CSP header on HTML; move the Nextcloud Login Flow
v2 grant page to the SvelteKit /nextcloud/login route.
- `just front-codegen` recipe and start-server-spa.sh harness.
Make the test environment robust and consistent:
- Install a deterministic in-memory localStorage/sessionStorage in the Vitest
setup so storage behaves identically across Node versions (Node 26 ships a
native Web Storage global that otherwise shadows jsdom's).
- Pin devenv to Node 26 + PostgreSQL 18 and pin every CI job to Node 26.3.0
so the dev shell and CI run the same toolchain versions.
Repair the API/WebDAV (hurl) suite, which had drifted from the backend:
- Migrate the removed `/api/folders/{id}/listing` endpoint to `/resources`
(cursor-paginated `{items:[{resource_type,resource}]}` shape) across the
batch-copy, grants, nested-group, and WebDAV NC tests + the dav_helpers
wipe routine.
- Stop photos_etag from uploading the dedup-tracked fixture so the dedup
blob-lifecycle test can own its content-addressed blob exclusively.
- dedup_create now asserts the idempotent same-content re-upload (201 +
existing file id) instead of the stale 409 expectation.
Generated coverage reports, nyc output and the e2e server runtime data dir
are gitignored rather than committed.
77 lines
3.2 KiB
TypeScript
77 lines
3.2 KiB
TypeScript
import { test, expect } from './coverage-helpers';
|
|
import { apiLogin, apiAdminCreateUser } from '../scenarios/helpers';
|
|
|
|
/**
|
|
* Groups route — create a group, expand it, search members, rename, and delete
|
|
* (delete is a type-the-name confirm). Group rows are id-keyed, so we scope to
|
|
* our own `li.group` by its unique name and prefix-match the buttons.
|
|
*/
|
|
test.beforeEach(async ({ page }) => {
|
|
await apiLogin(page);
|
|
});
|
|
|
|
function uniq(p: string): string {
|
|
return `${p}-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
}
|
|
|
|
test('group lifecycle: create, expand, rename, delete', async ({ page }) => {
|
|
const name = uniq('Grp');
|
|
const renamed = uniq('Grpr');
|
|
await page.goto('/groups');
|
|
await expect(page.getByTestId('groups-create-btn')).toBeVisible({ timeout: 15_000 });
|
|
|
|
await page.getByTestId('groups-create-btn').click();
|
|
await page.getByTestId('dialog-host-prompt-input').fill(name);
|
|
await page.getByTestId('dialog-host-submit-btn').click();
|
|
|
|
const row = page.locator('li.group').filter({ hasText: name });
|
|
await expect(row).toBeVisible({ timeout: 15_000 });
|
|
|
|
// Expand → members panel, then run a member search (covers recipients).
|
|
await row.locator('[data-testid^="groups-expand-"]').click();
|
|
await expect(row.locator('[data-testid^="groups-members-panel-"]')).toBeVisible();
|
|
await row.getByTestId('groups-member-add-input').fill('admin').catch(() => {});
|
|
await page.waitForTimeout(600);
|
|
|
|
// Rename.
|
|
await row.locator('[data-testid^="groups-rename-"]').click();
|
|
await page.getByTestId('dialog-host-prompt-input').fill(renamed);
|
|
await page.getByTestId('dialog-host-submit-btn').click();
|
|
const renamedRow = page.locator('li.group').filter({ hasText: renamed });
|
|
await expect(renamedRow).toBeVisible({ timeout: 15_000 });
|
|
|
|
// Delete — the confirm prompt requires typing the group name.
|
|
await renamedRow.locator('[data-testid^="groups-delete-"]').click();
|
|
await page.getByTestId('dialog-host-prompt-input').fill(renamed);
|
|
await page.getByTestId('dialog-host-submit-btn').click();
|
|
await expect(page.locator('li.group').filter({ hasText: renamed })).toHaveCount(0, {
|
|
timeout: 15_000,
|
|
});
|
|
});
|
|
|
|
test('add and remove a group member', async ({ page }) => {
|
|
const username = await apiAdminCreateUser(page, uniq('grpmem'));
|
|
const groupName = uniq('GrpM');
|
|
|
|
await page.goto('/groups');
|
|
await page.getByTestId('groups-create-btn').click();
|
|
await page.getByTestId('dialog-host-prompt-input').fill(groupName);
|
|
await page.getByTestId('dialog-host-submit-btn').click();
|
|
|
|
const row = page.locator('li.group').filter({ hasText: groupName });
|
|
await expect(row).toBeVisible({ timeout: 15_000 });
|
|
await row.locator('[data-testid^="groups-expand-"]').click();
|
|
await expect(row.locator('[data-testid^="groups-members-panel-"]')).toBeVisible();
|
|
|
|
// Search the new user and add them.
|
|
await row.getByTestId('groups-member-add-input').fill(username);
|
|
const opt = row.locator('[data-testid^="groups-member-add-opt-user-"]').first();
|
|
await expect(opt).toBeVisible({ timeout: 15_000 });
|
|
await opt.click();
|
|
|
|
// Remove the member we just added.
|
|
const remove = row.locator('[data-testid^="groups-member-remove-"]').first();
|
|
await expect(remove).toBeVisible({ timeout: 15_000 });
|
|
await remove.click();
|
|
});
|