Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(ui): rp-014 rp-015 make the drag-and-drop E2E lanes runnable and fail loud
M43937e081ca7
diff --git a/control-ui/e2e/run-gfs-drag-and-drop.mjs b/control-ui/e2e/run-gfs-drag-and-drop.mjsnew file mode 100644index 000000000..667de4fa1--- /dev/null+++ b/control-ui/e2e/run-gfs-drag-and-drop.mjs@@ -0,0 +1,272 @@+#!/usr/bin/env node+// control-ui/e2e/run-gfs-drag-and-drop.mjs+//+// Frontend-owned E2E gate for the EvenDrive drag-and-drop journeys.+//+// WHY THIS EXISTS. The journey suite in `e2e/gfs-drag-and-drop.spec.ts`+// mutates a shared dev environment, so it skips itself unless the operator+// sets the mutation opt-in and configures the admin credential. A skipped+// suite exits 0: "no setup" and "the journeys passed" look identical on the+// command line. That is exactly the failure this gate removes.+//+// THE CONTRACT.+// 1. Requesting the gate WITHOUT the required setup FAILS LOUD (exit 1)+// with an actionable message. It never silently degrades to "skip".+// 2. The gate NEVER reports success for zero executed journeys, and never+// reports success while any journey was skipped.+// 3. The live-fixture opt-in stays EXPLICIT. This gate is a separate,+// named command; the ordinary unit/CI lanes never mutate the dev+// environment, because nothing in `npm test` calls this file.+//+// Usage (from control-ui/):+// QA_RECORDER_CONFIRM_MUTATIONS=1 \+// E2E_ADMIN_USER=<admin> ADMIN_PASSWORD=<password> \+// CONTROL_UI_URL=http://127.0.0.1:<port> \+// CONTROL_API_URL=http://127.0.0.1:<port> \+// npm run e2e:gfs-drag-and-drop+//+// Exit codes: 0 = every requested journey ran and passed. 1 = the gate+// refused to run, or the journey result was not a clean pass.+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import path from 'node:path'+import { fileURLToPath } from 'node:url'++const HERE = path.dirname(fileURLToPath(import.meta.url))+const APP_ROOT = path.resolve(HERE, '..')+const REPO_ROOT = path.resolve(APP_ROOT, '..')++export const CONFIRM_MUTATIONS_FLAG = 'QA_RECORDER_CONFIRM_MUTATIONS'+export const ADMIN_USER_KEYS = ['E2E_ADMIN_USER', 'ADMIN_USER', 'ADMIN_USERNAME']+export const ADMIN_PASSWORD_KEYS = [+ 'E2E_ADMIN_PASSWORD',+ 'ADMIN_PASSWORD',+ 'ADMIN_PASS',+ 'TEST_ADMIN_PASSWORD',+]++const PROBE_TIMEOUT_MS = 10_000+const HEALTH_PATH = '/health'++/** First non-empty value among the candidate env names (never logged). */+export function firstConfiguredValue(env, keys) {+ for (const key of keys) {+ const value = env[key]+ if (typeof value === 'string' && value.trim()) return value.trim()+ }+ return ''+}++export function isLoopbackHostname(hostname) {+ return (+ hostname === '127.0.0.1' ||+ hostname === 'localhost' ||+ hostname === '[::1]' ||+ hostname === '::1'+ )+}++/**+ * The setup the journey suite needs. Returns the problems instead of+ * throwing so the caller can print all of them at once.+ */+export function collectGateProblems(env) {+ const problems = []++ if (env[CONFIRM_MUTATIONS_FLAG] !== '1') {+ problems.push(+ `${CONFIRM_MUTATIONS_FLAG}=1 is not set. The drag-and-drop journeys create, move and delete ` ++ 'real GFS fixtures on the configured environment, so the live-fixture opt-in is required.'+ )+ }++ if (!firstConfiguredValue(env, ADMIN_USER_KEYS)) {+ problems.push(`No admin username configured. Set one of: ${ADMIN_USER_KEYS.join(', ')}.`)+ }++ if (!firstConfiguredValue(env, ADMIN_PASSWORD_KEYS)) {+ problems.push(`No admin password configured. Set one of: ${ADMIN_PASSWORD_KEYS.join(', ')}.`)+ }++ const controlUiUrl = env.CONTROL_UI_URL || 'http://localhost:3000'+ const controlApiUrl = env.CONTROL_API_URL || 'http://localhost:8090'+ for (const [label, rawUrl] of [+ ['CONTROL_UI_URL', controlUiUrl],+ ['CONTROL_API_URL', controlApiUrl],+ ]) {+ let parsed+ try {+ parsed = new URL(rawUrl)+ } catch {+ problems.push(`${label} must be an absolute URL; received "${rawUrl}".`)+ continue+ }+ if (!isLoopbackHostname(parsed.hostname) && env.QA_RECORDER_ALLOW_REMOTE !== '1') {+ problems.push(+ `${label} targets non-local host "${parsed.hostname}". Set QA_RECORDER_ALLOW_REMOTE=1 only ` ++ 'when that environment is intentionally disposable.'+ )+ }+ }++ return problems+}++/**+ * The verdict of a Playwright JSON report. A run is a clean pass only when+ * at least one journey actually executed, nothing was skipped, and nothing+ * failed. A report that ran zero journeys is NOT a pass.+ */+export function evaluateGateReport(report) {+ const problems = []+ const stats = report && typeof report === 'object' ? (report.stats ?? {}) : {}+ const expected = Number(stats.expected ?? 0)+ const skipped = Number(stats.skipped ?? 0)+ const unexpected = Number(stats.unexpected ?? 0)+ const flaky = Number(stats.flaky ?? 0)++ if (!Number.isFinite(expected) || expected <= 0) {+ problems.push(+ 'The journey suite executed zero journeys. A skipped suite is not a green result: ' ++ 'check the mutation opt-in, the admin credential and the endpoint configuration.'+ )+ }+ if (skipped > 0) {+ problems.push(`${skipped} journey(s) were skipped. A skipped journey is not a green result.`)+ }+ if (unexpected > 0) {+ problems.push(`${unexpected} journey(s) failed.`)+ }++ return { problems, stats: { expected, skipped, unexpected, flaky } }+}++/** Bounded reachability probe. Never prints the response body. */+export async function probeReachable(url, timeoutMs = PROBE_TIMEOUT_MS) {+ try {+ const response = await fetch(url, {+ method: 'GET',+ redirect: 'manual',+ signal: AbortSignal.timeout(timeoutMs),+ })+ return { ok: response.status < 500, status: response.status }+ } catch (error) {+ return { ok: false, status: 0, error: error instanceof Error ? error.message : String(error) }+ }+}++function resolvePlaywrightBin() {+ const bin = path.join(+ APP_ROOT,+ 'node_modules',+ '.bin',+ process.platform === 'win32' ? 'playwright.cmd' : 'playwright'+ )+ if (!fs.existsSync(bin)) {+ throw new Error(+ `Playwright is not installed at ${bin}. Run "npm ci" in control-ui before the E2E gate.`+ )+ }+ return bin+}++function artifactDir() {+ const dir = path.join(REPO_ROOT, '.local-notes', 'infra', 'runs', 'control-ui-gfs-drag-and-drop')+ fs.mkdirSync(dir, { recursive: true })+ return dir+}++async function main() {+ const env = process.env+ const problems = collectGateProblems(env)+ if (problems.length > 0) {+ process.stderr.write('[E2E-GATE] The EvenDrive drag-and-drop gate cannot run:\n')+ for (const problem of problems) process.stderr.write(` - ${problem}\n`)+ process.stderr.write('[E2E-GATE] Nothing was executed. This is a FAILURE, not a skip.\n')+ return 1+ }++ const controlUiUrl = env.CONTROL_UI_URL || 'http://localhost:3000'+ const controlApiUrl = env.CONTROL_API_URL || 'http://localhost:8090'++ for (const [label, baseUrl] of [+ ['CONTROL_UI_URL', controlUiUrl],+ ['CONTROL_API_URL', controlApiUrl],+ ]) {+ const probe = await probeReachable(`${baseUrl.replace(/\/$/, '')}${HEALTH_PATH}`)+ if (!probe.ok) {+ process.stderr.write(+ `[E2E-GATE] ${label} is not reachable at ${baseUrl}${HEALTH_PATH}` ++ `${probe.error ? ` (${probe.error})` : ` (HTTP ${probe.status})`}. Nothing was executed.\n`+ )+ return 1+ }+ }++ const dir = artifactDir()+ const reportPath = path.join(dir, 'playwright-report.json')+ const playwrightBin = resolvePlaywrightBin()++ process.stdout.write(+ `[E2E-GATE] running the EvenDrive drag-and-drop journeys (report: ${reportPath})\n`+ )+ const run = spawnSync(+ playwrightBin,+ [+ 'test',+ '--config=playwright.config.ts',+ '--project=chromium',+ 'e2e/gfs-drag-and-drop.spec.ts',+ '--workers=1',+ '--reporter=list,json',+ ],+ {+ cwd: APP_ROOT,+ stdio: 'inherit',+ env: { ...env, PLAYWRIGHT_JSON_OUTPUT_NAME: reportPath },+ }+ )++ if (!fs.existsSync(reportPath)) {+ process.stderr.write(+ '[E2E-GATE] The Playwright JSON report was not written. The gate cannot certify the run.\n'+ )+ return 1+ }++ let report+ try {+ report = JSON.parse(fs.readFileSync(reportPath, 'utf8'))+ } catch (error) {+ process.stderr.write(+ `[E2E-GATE] The Playwright JSON report is unreadable: ${error instanceof Error ? error.message : String(error)}\n`+ )+ return 1+ }++ const verdict = evaluateGateReport(report)+ if (verdict.problems.length > 0) {+ process.stderr.write('[E2E-GATE] The EvenDrive drag-and-drop gate did NOT pass:\n')+ for (const problem of verdict.problems) process.stderr.write(` - ${problem}\n`)+ return 1+ }++ process.stdout.write(+ `[E2E-GATE] PASS — ${verdict.stats.expected} journey(s) executed, 0 skipped, 0 failed.\n`+ )+ return run.status === 0 ? 0 : 1+}++const invokedDirectly =+ process.argv[1] && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url))++if (invokedDirectly) {+ main()+ .then(code => {+ process.exitCode = code+ })+ .catch(error => {+ process.stderr.write(`[E2E-GATE] ${error instanceof Error ? error.message : String(error)}\n`)+ process.exitCode = 1+ })+}diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex e641cf936..1a9b6c5fb 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.749",+ "version": "0.1.750","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.749",+ "version": "0.1.750","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex ddf3215e6..079dfcfa4 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.749",+ "version": "0.1.750","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",@@ -59,7 +59,8 @@"qa:recorder:convert-mp4": "bash ../scripts/qa-recorder/convert-videos-mp4.sh","qa:recorder:all": "PLAYWRIGHT_BROWSERS_PATH=../.local-notes/qa-recorder/browsers playwright test --config=playwright.qa-recorder.config.ts","test": "vitest run",- "test:watch": "vitest"+ "test:watch": "vitest",+ "e2e:gfs-drag-and-drop": "node e2e/run-gfs-drag-and-drop.mjs"},"dependencies": {"@clerum/display-field": "file:../packages/display-field",diff --git a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts b/control-ui/test/__tests__/gfsDragAndDropGate.test.tsnew file mode 100644index 000000000..1283aed08--- /dev/null+++ b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts@@ -0,0 +1,101 @@+import { describe, expect, it } from 'vitest'+import {+ ADMIN_PASSWORD_KEYS,+ ADMIN_USER_KEYS,+ CONFIRM_MUTATIONS_FLAG,+ collectGateProblems,+ evaluateGateReport,+} from '../../e2e/run-gfs-drag-and-drop.mjs'++/**+ * The EvenDrive drag-and-drop gate is the frontend-owned entry point that+ * makes a missing setup LOUD. These regressions pin the two halves of that+ * contract: the gate refuses to run without the required setup, and it never+ * reads a zero-journey or skipped-journey run as a green result.+ */++const completeSetup = {+ [CONFIRM_MUTATIONS_FLAG]: '1',+ [ADMIN_USER_KEYS[0]]: 'admin',+ [ADMIN_PASSWORD_KEYS[0]]: 'secret-value',+ CONTROL_UI_URL: 'http://127.0.0.1:3100',+ CONTROL_API_URL: 'http://127.0.0.1:8090',+}++describe('EvenDrive drag-and-drop E2E gate', () => {+ describe('required setup', () => {+ it('accepts a complete setup', () => {+ expect(collectGateProblems(completeSetup)).toEqual([])+ })++ it('refuses without the live-fixture mutation opt-in', () => {+ const problems = collectGateProblems({+ ...completeSetup,+ [CONFIRM_MUTATIONS_FLAG]: undefined,+ })+ expect(problems.join('\n')).toContain(CONFIRM_MUTATIONS_FLAG)+ })++ it('refuses without an admin username', () => {+ const env = { ...completeSetup }+ for (const key of ADMIN_USER_KEYS) delete env[key]+ expect(collectGateProblems(env).join('\n')).toContain('admin username')+ })++ it('refuses without an admin password', () => {+ const env = { ...completeSetup }+ for (const key of ADMIN_PASSWORD_KEYS) delete env[key]+ expect(collectGateProblems(env).join('\n')).toContain('admin password')+ })++ it('refuses a non-loopback target unless the remote opt-in is set', () => {+ const problems = collectGateProblems({+ ...completeSetup,+ CONTROL_API_URL: 'https://api.example.test',+ })+ expect(problems.join('\n')).toContain('QA_RECORDER_ALLOW_REMOTE')+ })++ it('accepts a non-loopback target with the remote opt-in', () => {+ expect(+ collectGateProblems({+ ...completeSetup,+ CONTROL_API_URL: 'https://api.example.test',+ QA_RECORDER_ALLOW_REMOTE: '1',+ })+ ).toEqual([])+ })++ it('reports every missing piece at once instead of the first one', () => {+ const problems = collectGateProblems({})+ expect(problems.length).toBeGreaterThanOrEqual(3)+ })+ })++ describe('run verdict', () => {+ it('treats a run that executed zero journeys as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 0, skipped: 7, unexpected: 0 } })+ expect(verdict.problems.join('\n')).toContain('executed zero journeys')+ })++ it('treats a skipped journey as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 3, skipped: 1, unexpected: 0 } })+ expect(verdict.problems.join('\n')).toContain('skipped')+ })++ it('treats a failed journey as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 3, skipped: 0, unexpected: 1 } })+ expect(verdict.problems.join('\n')).toContain('failed')+ })++ it('accepts a clean run', () => {+ const verdict = evaluateGateReport({ stats: { expected: 7, skipped: 0, unexpected: 0 } })+ expect(verdict.problems).toEqual([])+ expect(verdict.stats.expected).toBe(7)+ })++ it('treats a missing report as a failure', () => {+ expect(evaluateGateReport(undefined).problems.join('\n')).toContain('executed zero journeys')+ })+ })+})diff --git a/desktop-app/package.json b/desktop-app/package.jsonindex d5b86f643..f3e8628cb 100644--- a/desktop-app/package.json+++ b/desktop-app/package.json@@ -16,6 +16,7 @@"test:e2e": "vitest run --config test/e2e/vitest.config.ts","test:bench-harness": "node ../scripts/tests/run-node-test-files.mjs scripts/bench-chat-open/benchmark.test.mjs","test:e2e:playwright": "npm run build && playwright test --config test/e2e-playwright/playwright.config.ts",+ "test:e2e:playwright:gfs-drag-and-drop": "npm run build && node test/e2e-playwright/run-gfs-drag-and-drop.mjs","test:native:sandbox-find": "npm run build:main --silent && node ./scripts/run-native-sandbox-find.mjs","test:native:sandbox-shortcut-focus": "npm run build:main --silent && node ./scripts/run-native-sandbox-shortcut-focus.mjs","test:native:chat-workspace-geometry": "node ./scripts/run-native-chat-workspace-geometry.mjs",diff --git a/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts b/desktop-app/test/__tests__/gfsDragAndDropGate.test.tsnew file mode 100644index 000000000..594d86952--- /dev/null+++ b/desktop-app/test/__tests__/gfsDragAndDropGate.test.ts@@ -0,0 +1,105 @@+import { describe, expect, it } from 'vitest'+import {+ DESKTOP_EMAIL_KEYS,+ DESKTOP_PASSWORD_KEYS,+ collectGateProblems,+ evaluateGateReport,+} from '../e2e-playwright/run-gfs-drag-and-drop.mjs'++/**+ * The EvenDrive drag-and-drop gate is the frontend-owned entry point that+ * makes a missing setup LOUD. These regressions pin the two halves of that+ * contract: the gate refuses to run without the required setup, and it never+ * reads a zero-journey or skipped-journey run as a green result.+ */++const completeSetup = {+ E2E_K8S_CONTEXT: 'dev',+ E2E_ALLOWED_CONTEXTS: 'dev',+ [DESKTOP_PASSWORD_KEYS[0]]: 'secret-value',+ [DESKTOP_EMAIL_KEYS[0]]: '[email protected]',+ EXTERNAL_REST_API_BASE_URL: 'http://127.0.0.1:8091',+ RPC_PROXY_BASE_URL: 'http://127.0.0.1:8094',+}++describe('EvenDrive drag-and-drop Desktop E2E gate', () => {+ describe('required setup', () => {+ it('accepts a complete setup', () => {+ // The build output check is a filesystem fact, not an env fact: this+ // suite runs against a checked-out tree whose build may be absent.+ const problems = collectGateProblems(completeSetup).filter(problem =>+ problem.includes('build output')+ )+ expect(problems).toEqual([])+ })++ it('refuses without a Kubernetes context', () => {+ const problems = collectGateProblems({ ...completeSetup, E2E_K8S_CONTEXT: undefined })+ expect(problems.join('\n')).toContain('Kubernetes context')+ })++ it('refuses a production context', () => {+ const problems = collectGateProblems({+ ...completeSetup,+ E2E_K8S_CONTEXT: 'prod',+ E2E_ALLOWED_CONTEXTS: 'prod',+ })+ expect(problems.join('\n')).toContain('production')+ })++ it('refuses a context outside the allow-list', () => {+ const problems = collectGateProblems({+ ...completeSetup,+ E2E_K8S_CONTEXT: 'other',+ E2E_ALLOWED_CONTEXTS: 'dev',+ })+ expect(problems.join('\n')).toContain('E2E_ALLOWED_CONTEXTS')+ })++ it('refuses without a Desktop password', () => {+ const env = { ...completeSetup }+ for (const key of DESKTOP_PASSWORD_KEYS) delete env[key]+ expect(collectGateProblems(env).join('\n')).toContain('Desktop password')+ })++ it('refuses a non-loopback endpoint unless the remote opt-in is set', () => {+ const problems = collectGateProblems({+ ...completeSetup,+ RPC_PROXY_BASE_URL: 'https://rpc.example.test',+ })+ expect(problems.join('\n')).toContain('E2E_ALLOW_REMOTE')+ })++ it('reports every missing piece at once instead of the first one', () => {+ const problems = collectGateProblems({})+ expect(problems.length).toBeGreaterThanOrEqual(2)+ })+ })++ describe('run verdict', () => {+ it('treats a run that executed zero journeys as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 0, skipped: 2, unexpected: 0 } })+ expect(verdict.problems.join('\n')).toContain('executed zero journeys')+ })++ it('treats a skipped journey as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 2, skipped: 1, unexpected: 0 } })+ expect(verdict.problems.join('\n')).toContain('skipped')+ })++ it('treats a failed journey as a failure', () => {+ const verdict = evaluateGateReport({ stats: { expected: 2, skipped: 0, unexpected: 1 } })+ expect(verdict.problems.join('\n')).toContain('failed')+ })++ it('accepts a clean run', () => {+ const verdict = evaluateGateReport({ stats: { expected: 2, skipped: 0, unexpected: 0 } })+ expect(verdict.problems).toEqual([])+ expect(verdict.stats.expected).toBe(2)+ })++ it('treats a missing report as a failure', () => {+ expect(evaluateGateReport(undefined).problems.join('\n')).toContain('executed zero journeys')+ })+ })+})diff --git a/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts b/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.tsindex b62128ff1..23d0ccae7 100644--- a/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts+++ b/desktop-app/test/e2e-playwright/gfs-drag-and-drop-desktop.test.ts@@ -11,13 +11,33 @@* sidebar explorer tree variant of the same flows is covered by the* FileExplorerTree vitest suite (including the dragend-race regressions);* this journey covers the visible grid surface end to end.+ *+ * FIXTURE AND AUTHORITY MODEL (why the journey is shaped the way it is).+ * - Fixture names must satisfy the shared harness' E2E namespace guard+ * (`e2e-gfs-*`); the shared-with-me listing is driven by DIRECT grants.+ * - A move is parent-relative (control-api `applyResourcePatch`): it needs+ * write+delete on the OLD parent and write on the destination. The+ * persona therefore holds read/write/delete on the fixture folder, which+ * covers every fixture child.+ * - The shared-with-me listing shows resources with a direct grant, and the+ * Desktop suppresses a FILE that lives inside a listed folder. A file+ * drag therefore happens INSIDE the fixture folder (where the file and+ * the destination folder are siblings), while the folder drag happens at+ * the shared root between two directly granted folders.+ * - Both helpers accept the SAME name and return the SAME fixture folder+ * row, so one fixture name yields a folder that holds both a file and a+ * child folder.*/import { type Locator, type Page, expect, test } from '@playwright/test'import {assertGfsFixtureCleaned,cleanupGfsFixture,+ countGfsLiveChildrenByName,+ getE2EUserId,+ getGfsChildResourceSummary,seedGfsDirectoryFixture,seedGfsFileFixture,+ seedGfsGrant,uniqueGfsFixtureName,} from '../../../tests/e2e/gfsUiFixtures'import { launchAndLogin } from './workflowUi'@@ -30,6 +50,34 @@ function toast(page: Page, text: string): Locator {return page.locator('[role="status"], [role="alert"]').filter({ hasText: text })}+/**+ * Grant the fixture to the seeded E2E persona: read/write/delete, inherited+ * by the fixture subtree. Without this the fixtures exist but the persona+ * cannot read them, cannot move them, and the shared-with-me listing does+ * not carry them at all.+ */+function grantFixtureToE2eUser(resourceId: string): void {+ seedGfsGrant({+ resourceId,+ subjectType: 'user',+ subjectId: getE2EUserId(),+ permissions: ['read', 'write', 'delete'],+ inherit: true,+ grantedBy: 'e2e:gfs-drag-and-drop',+ })+}++/**+ * Open the Files surface at the shared root.+ *+ * The Files surface renders NO aria-current on its breadcrumb, so the old+ * `aria-current="page"` assertion could never pass and both journeys died+ * before they reached a gesture. The signals the UI really renders at the+ * shared root are used instead: the root-only resource menu ("Options for+ * Shared with me" is rendered only when no folder is open) and the+ * breadcrumb's own state — at the root there is no parent to return to, so+ * "Shared with me" is not navigable.+ */async function openFilesSharedRoot(page: Page): Promise<void> {const filesNav = page.getByRole('button', { name: /^Files$/, exact: true }).first()await expect(filesNav).toBeVisible({ timeout: 30_000 })@@ -38,7 +86,28 @@ async function openFilesSharedRoot(page: Page): Promise<void> {.getByRole('navigation', { name: 'File location', exact: true }).getByRole('button', { name: 'Shared with me', exact: true })await expect(sharedWithMe).toBeVisible({ timeout: 30_000 })- await expect(sharedWithMe).toHaveAttribute('aria-current', 'page')+ await expect(+ page.getByRole('button', { name: 'Options for Shared with me', exact: true })+ ).toBeVisible({ timeout: 30_000 })+ await expect(sharedWithMe).toBeDisabled()+}++/** Descend into a fixture folder from the shared root. */+async function openFixtureFolder(page: Page, folderName: string): Promise<void> {+ await openFilesSharedRoot(page)+ const row = gridRow(page, folderName)+ await row.waitFor({ state: 'visible', timeout: 60_000 })+ await row.click()+ // The folder is open: its crumb is in the location trail and the root-only+ // resource menu is gone.+ await expect(+ page+ .getByRole('navigation', { name: 'File location', exact: true })+ .getByRole('button', { name: folderName, exact: true })+ ).toBeVisible({ timeout: 30_000 })+ await expect(+ page.getByRole('button', { name: 'Options for Shared with me', exact: true })+ ).toHaveCount(0)}/**@@ -73,49 +142,72 @@ test.describe('EvenDrive drag and drop (desktop grid)', () => {test.setTimeout(300_000)test('file drag into a folder moves it without a confirmation', async () => {- const fileFixtureName = uniqueGfsFixtureName('e2e-dnd-file')- const dirFixtureName = uniqueGfsFixtureName('e2e-dnd-dir')- const file = seedGfsFileFixture(fileFixtureName)- const dir = seedGfsDirectoryFixture(dirFixtureName)+ // ONE fixture name: the file helper and the directory helper reuse the+ // same fixture folder row, so the folder ends up holding BOTH the file+ // and the destination folder as siblings.+ const fixtureName = uniqueGfsFixtureName('e2e-gfs-dnd-file')+ const file = seedGfsFileFixture(fixtureName)+ const dir = seedGfsDirectoryFixture(fixtureName)+ grantFixtureToE2eUser(dir.resourceId)const { app, page } = await launchAndLogin()try {- await openFilesSharedRoot(page)+ await openFixtureFolder(page, fixtureName)const fileRow = gridRow(page, file.fileName)- const dirRow = gridRow(page, dir.name)+ const dirRow = gridRow(page, dir.childName)await fileRow.waitFor({ state: 'visible', timeout: 60_000 })await dirRow.waitFor({ state: 'visible', timeout: 60_000 })await dragRowOntoRow(page, fileRow, dirRow)- await expect(toast(page, `Moved ${file.fileName} to ${dir.name}`)).toBeVisible({+ await expect(toast(page, `Moved ${file.fileName} to ${dir.childName}`)).toBeVisible({timeout: 30_000,})+ // Persisted location: the file is a live child of the destination+ // folder, and it left the folder it started in.+ await expect+ .poll(+ () =>+ countGfsLiveChildrenByName({+ parentResourceId: dir.childResourceId,+ name: file.fileName,+ }),+ { timeout: 30_000, intervals: [250, 1_000] }+ )+ .toBe(1)+ expect(+ getGfsChildResourceSummary({ parentResourceId: dir.resourceId, name: file.fileName })+ ).toBeNull()+ // The moved file is gone from the folder listing it was dragged out of.await expect(fileRow).toBeHidden({ timeout: 30_000 })} finally {await app.close().catch(() => undefined)- cleanupGfsFixture(fileFixtureName)- cleanupGfsFixture(dirFixtureName)- assertGfsFixtureCleaned(fileFixtureName)- assertGfsFixtureCleaned(dirFixtureName)+ cleanupGfsFixture(fixtureName)+ assertGfsFixtureCleaned(fixtureName)}})test('folder drag stops at the one confirmation: Cancel is a no-op, Move commits with impact info', async () => {- const sourceDirName = uniqueGfsFixtureName('e2e-dnd-src')- const destinationDirName = uniqueGfsFixtureName('e2e-dnd-dst')- const sourceDir = seedGfsDirectoryFixture(sourceDirName)- const destinationDir = seedGfsDirectoryFixture(destinationDirName)+ const sourceName = uniqueGfsFixtureName('e2e-gfs-dnd-src')+ const destinationName = uniqueGfsFixtureName('e2e-gfs-dnd-dst')+ const sourceDir = seedGfsDirectoryFixture(sourceName)+ const destinationDir = seedGfsDirectoryFixture(destinationName)+ // The moved folder is the fixture's CHILD, so its old parent is the+ // fixture folder: the persona holds write+delete there and the move+ // never needs authority on the drive root.+ grantFixtureToE2eUser(sourceDir.resourceId)+ grantFixtureToE2eUser(sourceDir.childResourceId)+ grantFixtureToE2eUser(destinationDir.resourceId)const { app, page } = await launchAndLogin()try {await openFilesSharedRoot(page)- const sourceRow = gridRow(page, sourceDir.name)+ const sourceRow = gridRow(page, sourceDir.childName)const destinationRow = gridRow(page, destinationDir.name)await sourceRow.waitFor({ state: 'visible', timeout: 60_000 })await destinationRow.waitFor({ state: 'visible', timeout: 60_000 })await dragRowOntoRow(page, sourceRow, destinationRow)const confirmDialog = page.getByRole('dialog', {- name: `Move folder ${sourceDir.name} to ${destinationDir.name}`,+ name: `Move folder ${sourceDir.childName} to ${destinationDir.name}`,exact: true,})await expect(confirmDialog).toBeVisible({ timeout: 30_000 })@@ -126,12 +218,20 @@ test.describe('EvenDrive drag and drop (desktop grid)', () => {await expect(confirmDialog).toBeHidden({ timeout: 15_000 })// Cancel committed nothing: the source row is still listed.await expect(sourceRow).toBeVisible({ timeout: 30_000 })+ expect(+ countGfsLiveChildrenByName({+ parentResourceId: destinationDir.resourceId,+ name: sourceDir.childName,+ })+ ).toBe(0)await dragRowOntoRow(page, sourceRow, destinationRow)await expect(confirmDialog).toBeVisible({ timeout: 30_000 })await confirmDialog.getByRole('button', { name: 'Move', exact: true }).click()- await expect(toast(page, `Moved ${sourceDir.name} to ${destinationDir.name}`)).toBeVisible({+ await expect(+ toast(page, `Moved ${sourceDir.childName} to ${destinationDir.name}`)+ ).toBeVisible({timeout: 30_000,})await expect(@@ -140,13 +240,32 @@ test.describe('EvenDrive drag and drop (desktop grid)', () => {'Moving a folder changes who can access its contents — access now follows the new location.')).toBeVisible({ timeout: 30_000 })- await expect(sourceRow).toBeHidden({ timeout: 30_000 })+ // Persisted location: the folder is a live child of the destination+ // and it left the fixture folder it started in. (The shared-with-me+ // listing keeps a directly granted FOLDER visible after the move, so+ // the persisted location — not the row count — is the proof.)+ await expect+ .poll(+ () =>+ countGfsLiveChildrenByName({+ parentResourceId: destinationDir.resourceId,+ name: sourceDir.childName,+ }),+ { timeout: 30_000, intervals: [250, 1_000] }+ )+ .toBe(1)+ expect(+ getGfsChildResourceSummary({+ parentResourceId: sourceDir.resourceId,+ name: sourceDir.childName,+ })+ ).toBeNull()} finally {await app.close().catch(() => undefined)- cleanupGfsFixture(sourceDirName)- cleanupGfsFixture(destinationDirName)- assertGfsFixtureCleaned(sourceDirName)- assertGfsFixtureCleaned(destinationDirName)+ cleanupGfsFixture(sourceName)+ cleanupGfsFixture(destinationName)+ assertGfsFixtureCleaned(sourceName)+ assertGfsFixtureCleaned(destinationName)}})})diff --git a/desktop-app/test/e2e-playwright/run-gfs-drag-and-drop.mjs b/desktop-app/test/e2e-playwright/run-gfs-drag-and-drop.mjsnew file mode 100644index 000000000..fa3559e6e--- /dev/null+++ b/desktop-app/test/e2e-playwright/run-gfs-drag-and-drop.mjs@@ -0,0 +1,294 @@+#!/usr/bin/env node+// desktop-app/test/e2e-playwright/run-gfs-drag-and-drop.mjs+//+// Frontend-owned E2E gate for the EvenDrive drag-and-drop journeys.+//+// WHY THIS EXISTS. The Desktop drag-and-drop spec used to assert an+// `aria-current="page"` attribute the Files surface never renders, so BOTH+// journeys failed before they reached a gesture. A suite that cannot run is+// indistinguishable from a suite that passed when the only signal is the+// exit code of a broad `playwright test` invocation. This gate is the+// explicit, repeatable entry point for the lane:+//+// 1. Requesting the gate WITHOUT the required setup FAILS LOUD (exit 1)+// with an actionable message — it never degrades into "skip".+// 2. The gate NEVER reports success for zero executed journeys, and never+// reports success while a journey was skipped.+// 3. The live-fixture opt-in stays EXPLICIT. Nothing in `npm test` calls+// this file; the journeys mutate a shared dev environment, so only this+// named command runs them.+//+// Usage (from desktop-app/):+// E2E_K8S_CONTEXT=dev \+// E2E_ALLOWED_CONTEXTS=dev \+// E2E_DEV_LOGIN_EMAIL=<user> E2E_DESKTOP_PASSWORD=<password> \+// EXTERNAL_REST_API_BASE_URL=http://127.0.0.1:<port> \+// RPC_PROXY_BASE_URL=http://127.0.0.1:<port> \+// npm run test:e2e:playwright:gfs-drag-and-drop+//+// Exit codes: 0 = every requested journey ran and passed. 1 = the gate+// refused to run, or the journey result was not a clean pass.+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import path from 'node:path'+import { fileURLToPath } from 'node:url'++const HERE = path.dirname(fileURLToPath(import.meta.url))+const APP_ROOT = path.resolve(HERE, '..', '..')+const REPO_ROOT = path.resolve(APP_ROOT, '..')++export const DESKTOP_PASSWORD_KEYS = [+ 'E2E_DESKTOP_PASSWORD',+ 'E2E_TEST_PASSWORD',+ 'ADMIN_PASSWORD',+ 'TEST_ADMIN_PASSWORD',+]+export const DESKTOP_EMAIL_KEYS = [+ 'E2E_DEV_LOGIN_EMAIL',+ 'TEST_USER_EMAIL',+ 'CLERUM_TEST_USER_EMAIL',+]++const PROBE_TIMEOUT_MS = 10_000++/** First non-empty value among the candidate env names (never logged). */+export function firstConfiguredValue(env, keys) {+ for (const key of keys) {+ const value = env[key]+ if (typeof value === 'string' && value.trim()) return value.trim()+ }+ return ''+}++export function isLoopbackHostname(hostname) {+ return (+ hostname === '127.0.0.1' ||+ hostname === 'localhost' ||+ hostname === '[::1]' ||+ hostname === '::1'+ )+}++/**+ * The setup the Desktop lane needs. Returns the problems instead of+ * throwing so the caller can print all of them at once.+ */+export function collectGateProblems(env) {+ const problems = []++ const context = (env.E2E_K8S_CONTEXT || env.KUBECONTEXT || env.K8S_CONTEXT || '').trim()+ if (!context) {+ problems.push(+ 'No Kubernetes context configured. Set E2E_K8S_CONTEXT (or KUBECONTEXT / K8S_CONTEXT) to the ' ++ 'owned dev context the journeys read their fixtures from.'+ )+ } else if (/(^|[-_])(prod|production)([-_]|$)/i.test(context)) {+ problems.push(+ `Refusing a production context ("${context}"). E2E against prod is never allowed.`+ )+ } else {+ const allowed = (env.E2E_ALLOWED_CONTEXTS || '')+ .split(',')+ .map(value => value.trim())+ .filter(Boolean)+ if (allowed.length > 0 && !allowed.includes(context)) {+ problems.push(+ `E2E_K8S_CONTEXT="${context}" is not in E2E_ALLOWED_CONTEXTS (${allowed.join(', ')}).`+ )+ }+ }++ if (!firstConfiguredValue(env, DESKTOP_PASSWORD_KEYS)) {+ problems.push(+ `No Desktop password configured. Set one of: ${DESKTOP_PASSWORD_KEYS.join(', ')}.`+ )+ }++ const endpoints = [+ ['EXTERNAL_REST_API_BASE_URL', env.EXTERNAL_REST_API_BASE_URL || 'http://127.0.0.1:8091'],+ ['RPC_PROXY_BASE_URL', env.RPC_PROXY_BASE_URL || 'http://127.0.0.1:8094'],+ ]+ for (const [label, rawUrl] of endpoints) {+ let parsed+ try {+ parsed = new URL(rawUrl)+ } catch {+ problems.push(`${label} must be an absolute URL; received "${rawUrl}".`)+ continue+ }+ if (!isLoopbackHostname(parsed.hostname) && env.E2E_ALLOW_REMOTE !== '1') {+ problems.push(+ `${label} targets non-local host "${parsed.hostname}". Set E2E_ALLOW_REMOTE=1 only when ` ++ 'that environment is intentionally disposable.'+ )+ }+ }++ const buildOutputs = ['dist/main.js', 'dist/preload.js', 'ui-dist/index.html']+ const missing = buildOutputs.filter(output => !fs.existsSync(path.join(APP_ROOT, output)))+ if (missing.length > 0) {+ problems.push(+ `The Desktop build output is missing (${missing.join(', ')}). Run "npm run build" in desktop-app first.`+ )+ }++ return problems+}++/**+ * The verdict of a Playwright JSON report. A run is a clean pass only when+ * at least one journey actually executed, nothing was skipped, and nothing+ * failed. A report that ran zero journeys is NOT a pass.+ */+export function evaluateGateReport(report) {+ const problems = []+ const stats = report && typeof report === 'object' ? (report.stats ?? {}) : {}+ const expected = Number(stats.expected ?? 0)+ const skipped = Number(stats.skipped ?? 0)+ const unexpected = Number(stats.unexpected ?? 0)+ const flaky = Number(stats.flaky ?? 0)++ if (!Number.isFinite(expected) || expected <= 0) {+ problems.push(+ 'The journey suite executed zero journeys. A skipped suite is not a green result: ' ++ 'check the Kubernetes context, the Desktop credential and the endpoint configuration.'+ )+ }+ if (skipped > 0) {+ problems.push(`${skipped} journey(s) were skipped. A skipped journey is not a green result.`)+ }+ if (unexpected > 0) {+ problems.push(`${unexpected} journey(s) failed.`)+ }++ return { problems, stats: { expected, skipped, unexpected, flaky } }+}++/** Bounded reachability probe. Never prints the response body. */+export async function probeReachable(url, timeoutMs = PROBE_TIMEOUT_MS) {+ try {+ const response = await fetch(url, {+ method: 'GET',+ redirect: 'manual',+ signal: AbortSignal.timeout(timeoutMs),+ })+ return { ok: response.status < 500, status: response.status }+ } catch (error) {+ return { ok: false, status: 0, error: error instanceof Error ? error.message : String(error) }+ }+}++function resolvePlaywrightBin() {+ const bin = path.join(+ APP_ROOT,+ 'node_modules',+ '.bin',+ process.platform === 'win32' ? 'playwright.cmd' : 'playwright'+ )+ if (!fs.existsSync(bin)) {+ throw new Error(+ `Playwright is not installed at ${bin}. Run "npm ci" in desktop-app before the E2E gate.`+ )+ }+ return bin+}++function artifactDir() {+ const dir = path.join(REPO_ROOT, '.local-notes', 'infra', 'runs', 'desktop-gfs-drag-and-drop')+ fs.mkdirSync(dir, { recursive: true })+ return dir+}++async function main() {+ const env = process.env+ const problems = collectGateProblems(env)+ if (problems.length > 0) {+ process.stderr.write('[E2E-GATE] The EvenDrive drag-and-drop gate cannot run:\n')+ for (const problem of problems) process.stderr.write(` - ${problem}\n`)+ process.stderr.write('[E2E-GATE] Nothing was executed. This is a FAILURE, not a skip.\n')+ return 1+ }++ const externalRest = env.EXTERNAL_REST_API_BASE_URL || 'http://127.0.0.1:8091'+ const rpcProxy = env.RPC_PROXY_BASE_URL || 'http://127.0.0.1:8094'+ for (const [label, baseUrl] of [+ ['EXTERNAL_REST_API_BASE_URL', externalRest],+ ['RPC_PROXY_BASE_URL', rpcProxy],+ ]) {+ const probe = await probeReachable(`${baseUrl.replace(/\/$/, '')}/health`)+ if (!probe.ok) {+ process.stderr.write(+ `[E2E-GATE] ${label} is not reachable at ${baseUrl}/health` ++ `${probe.error ? ` (${probe.error})` : ` (HTTP ${probe.status})`}. Nothing was executed.\n`+ )+ return 1+ }+ }++ const dir = artifactDir()+ const reportPath = path.join(dir, 'playwright-report.json')+ const playwrightBin = resolvePlaywrightBin()++ process.stdout.write(+ `[E2E-GATE] running the EvenDrive drag-and-drop journeys (report: ${reportPath})\n`+ )+ const run = spawnSync(+ playwrightBin,+ [+ 'test',+ '--config=test/e2e-playwright/playwright.config.ts',+ 'gfs-drag-and-drop-desktop.test.ts',+ '--project=default',+ '--workers=1',+ '--reporter=list,json',+ ],+ {+ cwd: APP_ROOT,+ stdio: 'inherit',+ env: { ...env, PLAYWRIGHT_JSON_OUTPUT_NAME: reportPath },+ }+ )++ if (!fs.existsSync(reportPath)) {+ process.stderr.write(+ '[E2E-GATE] The Playwright JSON report was not written. The gate cannot certify the run.\n'+ )+ return 1+ }++ let report+ try {+ report = JSON.parse(fs.readFileSync(reportPath, 'utf8'))+ } catch (error) {+ process.stderr.write(+ `[E2E-GATE] The Playwright JSON report is unreadable: ${error instanceof Error ? error.message : String(error)}\n`+ )+ return 1+ }++ const verdict = evaluateGateReport(report)+ if (verdict.problems.length > 0) {+ process.stderr.write('[E2E-GATE] The EvenDrive drag-and-drop gate did NOT pass:\n')+ for (const problem of verdict.problems) process.stderr.write(` - ${problem}\n`)+ return 1+ }++ process.stdout.write(+ `[E2E-GATE] PASS — ${verdict.stats.expected} journey(s) executed, 0 skipped, 0 failed.\n`+ )+ return run.status === 0 ? 0 : 1+}++const invokedDirectly =+ process.argv[1] && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url))++if (invokedDirectly) {+ main()+ .then(code => {+ process.exitCode = code+ })+ .catch(error => {+ process.stderr.write(`[E2E-GATE] ${error instanceof Error ? error.message : String(error)}\n`)+ process.exitCode = 1+ })+}