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.
81 lines
3.1 KiB
TypeScript
81 lines
3.1 KiB
TypeScript
import { test, expect } from './coverage-helpers';
|
|
import { apiLogin, apiCreateFolder, apiUploadFile, SAMPLE_FILES } from '../scenarios/helpers';
|
|
|
|
/**
|
|
* Photos route — populate the grid with uploaded images, open the lightbox and
|
|
* navigate it, and switch the moments/places/people subnav. Covers the photos
|
|
* page + PhotoLightbox (and mounts PlacesMap / PeopleView).
|
|
*/
|
|
test.beforeEach(async ({ page }) => {
|
|
await apiLogin(page);
|
|
});
|
|
|
|
function uniq(p: string): string {
|
|
return `${p}-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
|
|
}
|
|
|
|
async function seedPhotos(page: import('@playwright/test').Page, n: number): Promise<void> {
|
|
const folder = await apiCreateFolder(page, uniq('Photos'));
|
|
for (let i = 0; i < n; i++) {
|
|
await apiUploadFile(
|
|
page,
|
|
{ name: `${uniq('pic')}.png`, mimeType: 'image/png', body: SAMPLE_FILES.png().body },
|
|
folder.id,
|
|
);
|
|
}
|
|
}
|
|
|
|
test('photo grid opens the lightbox and navigates', async ({ page }) => {
|
|
await seedPhotos(page, 3);
|
|
await page.goto('/photos');
|
|
await expect(page.getByTestId('appshell-logo-link')).toBeVisible({ timeout: 15_000 });
|
|
|
|
const tile = page.locator('[data-testid^="photo-tile-"]').first();
|
|
await expect(tile).toBeVisible({ timeout: 15_000 });
|
|
await tile.click();
|
|
|
|
await expect(page.getByTestId('photo-lightbox')).toBeVisible({ timeout: 15_000 });
|
|
await page.getByTestId('photo-lightbox-next-btn').click({ timeout: 3_000 }).catch(() => {});
|
|
await page.getByTestId('photo-lightbox-prev-btn').click({ timeout: 3_000 }).catch(() => {});
|
|
await page.getByTestId('photo-lightbox-close-btn').click();
|
|
await expect(page.getByTestId('photo-lightbox')).toHaveCount(0);
|
|
});
|
|
|
|
test('select photos, toggle layout, and batch-delete', async ({ page }) => {
|
|
await seedPhotos(page, 3);
|
|
await page.goto('/photos');
|
|
|
|
// The tile check button is hover-revealed; dispatch the click to select.
|
|
const tileCheck = page.locator('[data-testid^="photo-tile-check-"]').first();
|
|
await expect(tileCheck).toBeAttached({ timeout: 15_000 });
|
|
await tileCheck.dispatchEvent('click');
|
|
await expect(page.getByTestId('photos-batch-bar')).toBeVisible({ timeout: 5_000 });
|
|
|
|
// Layout toggles.
|
|
await page.getByTestId('photos-layout-justified-btn').click();
|
|
await page.getByTestId('photos-layout-square-btn').click();
|
|
|
|
// Batch-delete the selection (confirm if prompted).
|
|
await page.getByTestId('photos-batch-delete-btn').click();
|
|
const confirm = page.getByTestId('dialog-host-confirm-btn');
|
|
if (await confirm.isVisible().catch(() => false)) await confirm.click();
|
|
});
|
|
|
|
test('photos subnav switches to places and people', async ({ page }) => {
|
|
await seedPhotos(page, 2);
|
|
await page.goto('/photos');
|
|
await expect(page.getByTestId('photos-tab-places')).toBeVisible({ timeout: 15_000 });
|
|
|
|
await page.getByTestId('photos-tab-places').click();
|
|
await page.waitForTimeout(800);
|
|
|
|
const peopleTab = page.getByTestId('photos-tab-people');
|
|
if (await peopleTab.isVisible().catch(() => false)) {
|
|
await peopleTab.click();
|
|
await page.waitForTimeout(800);
|
|
}
|
|
|
|
await page.getByTestId('photos-tab-moments').click();
|
|
await expect(page.getByTestId('photos-tab-moments')).toHaveAttribute('aria-selected', 'true');
|
|
});
|