Skip to content

Commit db635ac

Browse files
committed
test(desktop): cover quiet navigation and full access consent
1 parent 090ff82 commit db635ac

2 files changed

Lines changed: 71 additions & 4 deletions

File tree

‎apps/desktop/e2e/browser-page-dialogs.spec.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,40 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
364364
await panelAction({ action: 'reload' })
365365
await expect.poll(() => pageTitle()).toBe('form')
366366

367+
await check('clean reloads and navigation never ask to discard changes', async () => {
368+
await panelAction({ action: 'reload' })
369+
await expect.poll(() => pageTitle()).toBe('form')
370+
expect(await pageDialog()).toBeNull()
371+
await panelAction({ action: 'navigate', url: `${site}/next` })
372+
await expect.poll(pageUrl).toBe(`${site}/next`)
373+
expect(await pageDialog()).toBeNull()
374+
await panelAction({ action: 'back' })
375+
await expect.poll(pageUrl).toBe(`${site}/form`)
376+
expect(await pageDialog()).toBeNull()
377+
})
378+
379+
await check('clearing a draft removes the leave warning', async () => {
380+
await userInput('#draft', 'temporary draft')
381+
await inPage("document.getElementById('draft').value = ''")
382+
await panelAction({ action: 'navigate', url: `${site}/next` })
383+
await expect.poll(pageUrl).toBe(`${site}/next`)
384+
expect(await pageDialog()).toBeNull()
385+
await panelAction({ action: 'navigate', url: `${site}/form` })
386+
await expect.poll(pageUrl).toBe(`${site}/form`)
387+
})
388+
389+
await check('same-page navigation preserves a draft without a leave warning', async () => {
390+
await userInput('#draft', 'same-page draft')
391+
await panelAction({ action: 'navigate', url: `${site}/form#section` })
392+
await expect.poll(pageUrl).toBe(`${site}/form#section`)
393+
expect(await pageDialog()).toBeNull()
394+
expect(await inPage<string>("document.getElementById('draft').value")).toBe('same-page draft')
395+
await panelAction({ action: 'back' })
396+
await expect.poll(pageUrl).toBe(`${site}/form`)
397+
expect(await pageDialog()).toBeNull()
398+
await inPage("document.getElementById('draft').value = ''")
399+
})
400+
367401
await check('leaving a draft from the URL bar asks, and Stay keeps it', async () => {
368402
await userInput('#draft', 'draft')
369403
await expect

‎apps/desktop/e2e/local-files.spec.ts‎

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,40 @@ createRoot(document.getElementById('settings')).render(
315315
await expect(
316316
window.getByRole('switch', { name: 'Full file access', exact: true })
317317
).not.toBeChecked()
318-
await window.getByRole('switch', { name: 'Full file access', exact: true }).click()
318+
const permission = await requestPermission({ operation: 'read', toolCallId: 'fullAccess' })
319+
const confirmationShown = app.waitForEvent('window')
320+
await permission.prompt
321+
.getByRole('button', { name: 'Allow all files…', exact: true })
322+
.click({ noWaitAfter: true })
323+
const confirmation = await confirmationShown
324+
await expect(confirmation.getByRole('button', { name: 'Cancel', exact: true })).toBeFocused()
325+
const returnedPrompt = app.waitForEvent('window')
326+
await confirmation
327+
.getByRole('button', { name: 'Cancel', exact: true })
328+
.click({ noWaitAfter: true })
329+
const folderPrompt = await returnedPrompt
330+
expect(
331+
await window.evaluate(async () =>
332+
(
333+
globalThis as typeof globalThis & { simDesktop: SimDesktopApi }
334+
).simDesktop.settings.getPreferences()
335+
)
336+
).toMatchObject({ fullFileAccess: false })
337+
const acceptedConfirmation = app.waitForEvent('window')
338+
await folderPrompt
339+
.getByRole('button', { name: 'Allow all files…', exact: true })
340+
.click({ noWaitAfter: true })
341+
const allowAll = await acceptedConfirmation
342+
await allowAll.screenshot({
343+
path: test.info().outputPath('full-file-access-confirmation.png'),
344+
})
345+
await allowAll
346+
.getByRole('button', { name: 'Allow all files', exact: true })
347+
.click({ noWaitAfter: true })
348+
expect(await permission.result).toMatchObject({
349+
ok: true,
350+
data: { text: 'full access contents' },
351+
})
319352
await expect(
320353
window.getByRole('switch', { name: 'Full file access', exact: true })
321354
).toBeChecked()
@@ -383,11 +416,11 @@ createRoot(document.getElementById('settings')).render(
383416
await expect(
384417
window.getByRole('switch', { name: 'Full file access', exact: true })
385418
).not.toBeChecked()
386-
const permission = await requestPermission({ operation: 'read', toolCallId: 'fullAccess' })
387-
await permission.prompt
419+
const revoked = await requestPermission({ operation: 'read', toolCallId: 'fullAccess' })
420+
await revoked.prompt
388421
.getByRole('button', { name: "Don't allow", exact: true })
389422
.click({ noWaitAfter: true })
390-
expect(await permission.result).toMatchObject({ ok: false })
423+
expect(await revoked.result).toMatchObject({ ok: false })
391424
})
392425
await test.step('a folder grant works in another chat but does not permit symlink escapes', async () => {
393426
expect(await invoke({ operation: 'read', toolCallId: 'otherChat' })).toMatchObject({

0 commit comments

Comments
 (0)