diff --git a/apps/desktop/e2e/local-files.spec.ts b/apps/desktop/e2e/local-files.spec.ts index 43e9a3e4fc9..31c32c8bdf4 100644 --- a/apps/desktop/e2e/local-files.spec.ts +++ b/apps/desktop/e2e/local-files.spec.ts @@ -17,6 +17,7 @@ import type { import { answerShellDialog } from './executor-sim' import { test as base, + bundleSimFixture, type DesktopApp, type DesktopBridge, expect, @@ -28,40 +29,48 @@ const PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Y9Zl1sAAAAASUVORK5CYII=' /** - * The app's own page stands in for Sim: a Forget button and a Full file access switch that drive - * the same bridge calls Sim's Desktop settings make (a real click supplies the user activation the - * setter requires), and the switch shows whatever the desktop last reported. + * Sim's real Desktop settings page, so the Full file access switch is the one users get: a real + * click supplies the user activation the setter requires, and a failed save shows Sim's own error. + * The Forget button stands in for Sim's chat-side folder removal, which has no settings UI. */ -const FIXTURE_PAGE = `Local file fixture

Local files

+const SETTINGS_SOURCE = `import { createRoot } from 'react-dom/client'; +import { ToastProvider } from '@sim/emcn'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { AppRouterContext } from 'next/dist/shared/lib/app-router-context.shared-runtime'; +import { PathParamsContext } from 'next/dist/shared/lib/hooks-client-context.shared-runtime'; +import { Desktop } from '@/app/workspace/[workspaceId]/settings/components/desktop/desktop'; +import { FeatureFlagsProvider } from '@/app/workspace/[workspaceId]/providers/feature-flags-provider'; +import { SettingsHeaderProvider, SettingsHeaderShell } from '@/components/settings/settings-header'; +import { SettingsSectionProvider } from '@/components/settings/settings-panel'; +const router = { back() {}, forward() {}, refresh() {}, push() {}, replace() {}, prefetch() {} }; +const flags = { dashboards: false, 'workflow-tests': false, 'workflow-code': false, changelog: false, 'mothership-model-selector': false, 'mothership-plan-mode': false }; +createRoot(document.getElementById('settings')).render( + + + + + + + + + +);` + +const FIXTURE_PAGE = `Local file fixture +

Local files

- - +
` + +` type LocalFileResponse = Awaited>> @@ -143,7 +152,14 @@ const test = base.extend<{ localFiles: LocalFilesFixture }>({ args: { path: source, targetWorkspaceId: 'target-workspace' }, }, } + const settings = await bundleSimFixture({ source: SETTINGS_SOURCE }, { external: ['postgres'] }) const server = await serve(async (request, response, url) => { + if (url.pathname === '/settings.js' || url.pathname === '/settings.css') { + const script = url.pathname.endsWith('.js') + response.writeHead(200, { 'Content-Type': script ? 'text/javascript' : 'text/css' }) + response.end(script ? settings.js : settings.css) + return + } if (url.pathname === '/api/auth/get-session') { response .writeHead(200, { 'Content-Type': 'application/json' }) @@ -672,7 +688,12 @@ test('Full file access is opt-in, survives restart, turns off cleanly, and fails mkdirSync(settingsPath) try { await session.fullAccess.click() - await expect(session.window.getByRole('status')).toHaveText('Not saved') + await expect( + session.window.getByText( + 'Could not save file access settings. Your previous setting may return after restarting Sim.', + { exact: true } + ) + ).toBeVisible() await expect(session.fullAccess).not.toBeChecked() expect(await session.preferences()).toMatchObject({ fullFileAccess: false }) expect(await session.invoke({ operation: 'read', toolCallId: 'text' })).toMatchObject({