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.
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import * as path from 'path';
|
|
import { loadEnv } from './load-env';
|
|
|
|
const startScript = path.join(__dirname, 'start-server.sh');
|
|
|
|
const commonEnv = loadEnv(path.join(__dirname, '../common/server.env'));
|
|
|
|
console.log(`starting playwright with env BUILD_TARGET=${process.env.BUILD_TARGET ?? "debug"}`);
|
|
|
|
const workspace=process.env.GITHUB_WORKSPACE ?? path.join(__dirname, '../..');
|
|
|
|
export default defineConfig({
|
|
testDir: './scenarios',
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: 0,
|
|
workers: 1,
|
|
reporter: process.env.CI ? [['line'], ['github'], ['html']] : [ ['list'], ['html']],
|
|
|
|
globalSetup: require.resolve('./global-setup'),
|
|
globalTeardown: require.resolve('./global-teardown'),
|
|
|
|
use: {
|
|
// 127.0.0.1, not `localhost`: the server binds IPv4 (127.0.0.1:8087) and
|
|
// on CI runners `localhost` resolves to ::1 (IPv6) first, so requests get
|
|
// ECONNREFUSED and the webServer readiness check below times out.
|
|
baseURL: 'http://127.0.0.1:8087',
|
|
trace: 'on-first-retry',
|
|
headless: true,
|
|
// take a screenshot on failure
|
|
screenshot: 'only-on-failure',
|
|
// Tile/file rows expose a `data-testid` of the item name (kept only in e2e
|
|
// builds via VITE_E2E); makes getByTestId + codegen prefer stable selectors.
|
|
testIdAttribute: 'data-testid',
|
|
},
|
|
|
|
expect: {
|
|
toHaveScreenshot: { maxDiffPixelRatio: 0.01 },
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
command: process.env.BUILD_TARGET
|
|
? `bash "${startScript}" "${workspace}/target/${process.env.BUILD_TARGET}/oxicloud"`
|
|
: `bash "${startScript}" cargo run`,
|
|
// Poll the dedicated readiness probe, not `/`: `/ready` returns 200 as soon
|
|
// as the DB pool is live, whereas `/` depends on the SPA build being present
|
|
// and can 404 (Playwright only treats 2xx/3xx/400-403 as "ready").
|
|
url: 'http://127.0.0.1:8087/ready',
|
|
timeout: 600_000,
|
|
reuseExistingServer: false,
|
|
cwd: '../..',
|
|
stdout: 'inherit',
|
|
stderr: 'inherit',
|
|
env: {
|
|
...commonEnv,
|
|
OXICLOUD_SERVER_PORT: '8087',
|
|
OXICLOUD_STORAGE_PATH: './tests/e2e/storage',
|
|
// Verbose startup so a CI webServer-readiness timeout shows where the
|
|
// server stalls (DB connect, migrations, bind) instead of nothing.
|
|
RUST_LOG: 'info,oxicloud=debug,sqlx=warn,tower_http=info',
|
|
},
|
|
},
|
|
});
|