From 6050ff78c309b01819d61cd7b3efd7e119864d86 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Thu, 12 Nov 2026 17:31:36 -0700 Subject: [PATCH] Match dashboard paths in any letter case, and stop the e2e tests waiting on .desktop - bootsDashboard() matches /dashboard and /app/ case-insensitively, as the server routes them, so /App/ boots the dashboard. - The request-permission hardening tests wait for the page's own answer instead of the removed .desktop element. - Remove the error_user_or_path_not_found string from fr.js. --- src/gui/src/helpers/bootsDashboard.js | 7 ++-- src/gui/src/helpers/bootsDashboard.test.js | 7 ++++ src/gui/src/i18n/translations/en.js | 1 - src/gui/src/i18n/translations/fr.js | 2 -- .../tests/e2e/specs/requestPermission.spec.js | 33 +++++++++++++++---- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/gui/src/helpers/bootsDashboard.js b/src/gui/src/helpers/bootsDashboard.js index a7dcaedf5..c3f1c614c 100644 --- a/src/gui/src/helpers/bootsDashboard.js +++ b/src/gui/src/helpers/bootsDashboard.js @@ -20,7 +20,8 @@ /** * Whether a page load boots the dashboard instead of the desktop. The root * path and `/app/` boot the dashboard unless the page is a popup, which - * the desktop still handles; `/dashboard` always does. + * the desktop still handles; `/dashboard` always does. The server matches + * these routes case-insensitively, so this does too. * * @param {Object} location * @param {string} location.pathname @@ -28,8 +29,8 @@ * @returns {boolean} */ export function bootsDashboard ({ pathname, embeddedInPopup }) { - if ( pathname === '/dashboard' || pathname === '/dashboard/' ) return true; - const isAppLanding = /^\/app\/[^/]+\/?$/.test(pathname); + if ( /^\/dashboard\/?$/i.test(pathname) ) return true; + const isAppLanding = /^\/app\/[^/]+\/?$/i.test(pathname); if ( pathname !== '/' && !isAppLanding ) return false; return !embeddedInPopup; } diff --git a/src/gui/src/helpers/bootsDashboard.test.js b/src/gui/src/helpers/bootsDashboard.test.js index c8bf417b9..c196b5af4 100644 --- a/src/gui/src/helpers/bootsDashboard.test.js +++ b/src/gui/src/helpers/bootsDashboard.test.js @@ -33,6 +33,13 @@ describe('bootsDashboard', () => { expect(boots('/app/editor')).toBe(true); }); + it('matches the paths in any letter case, as the server routes them', () => { + expect(boots('/Dashboard')).toBe(true); + expect(boots('/App/editor')).toBe(true); + expect(boots('/APP/Editor/')).toBe(true); + expect(boots('/App/editor', { embeddedInPopup: true })).toBe(false); + }); + it('boots the desktop on action pages', () => { expect(boots('/action/sign-in')).toBe(false); }); diff --git a/src/gui/src/i18n/translations/en.js b/src/gui/src/i18n/translations/en.js index ef2d67cee..b1603bb6b 100644 --- a/src/gui/src/i18n/translations/en.js +++ b/src/gui/src/i18n/translations/en.js @@ -962,7 +962,6 @@ const en = { 'enable_push_not_now': 'Not now', 'enable_push_footnote': 'You can turn them off anytime in Settings.', - // Auth token auth_token: 'Auth Token', token_copied: 'Token copied', diff --git a/src/gui/src/i18n/translations/fr.js b/src/gui/src/i18n/translations/fr.js index 89a636957..0995362ad 100644 --- a/src/gui/src/i18n/translations/fr.js +++ b/src/gui/src/i18n/translations/fr.js @@ -396,8 +396,6 @@ const fr = { 'perm_subdomains_read': 'voir vos sous-domaines', 'perm_subdomains_write': 'gérer vos sous-domaines', - 'error_user_or_path_not_found': 'Utilisateur ou chemin introuvable.', - // Auth token auth_token: 'Jeton d\'authentification', token_copied: 'Jeton copié', diff --git a/src/puter-js/tests/e2e/specs/requestPermission.spec.js b/src/puter-js/tests/e2e/specs/requestPermission.spec.js index 733b53dfb..a65fef7c2 100644 --- a/src/puter-js/tests/e2e/specs/requestPermission.spec.js +++ b/src/puter-js/tests/e2e/specs/requestPermission.spec.js @@ -1131,19 +1131,38 @@ test.describe('grant-user-app permission length', () => { }); }); +/** + * A top-level request-permission page posts its answer to itself. Resolves + * with that answer, or with null if a prompt shows up first. + */ +async function answerWithoutPrompt (page, url) { + await page.addInitScript(() => { + window.addEventListener('message', (event) => { + if ( event.data?.msg === 'permissionGranted' ) window.__permissionAnswer = event.data; + }); + }); + await page.goto(url); + const settled = await page.waitForFunction( + () => window.__permissionAnswer ?? (document.querySelector('dialog.perm-dialog') ? 'prompted' : undefined), + null, + { timeout: 60_000 }, + ); + const answer = await settled.jsonValue(); + return answer === 'prompted' ? null : answer; +} + test.describe('request-permission action hardening', () => { test('an app_uid in the URL never produces a prompt on its own', async ({ page }) => { // The uid identifies who receives the grant, so it must come from the // requesting origin — never from the link. A link carrying only a uid // would otherwise prompt for an unnamed requester and grant to an app // the dialog never showed the user. - await page.goto( + const answer = await answerWithoutPrompt( + page, `/action/request-permission?permission=${encodeURIComponent(UNHELD_PERMISSION)}` + '&app_uid=app-00000000-0000-4000-8000-000000000000', ); - await page.waitForFunction(() => !!window.puter?.authToken, null, { timeout: 60_000 }); - // Give the post-auth action a chance to run before asserting absence. - await page.locator('.desktop').waitFor({ timeout: 60_000 }); + expect(answer?.granted).toBe(false); await expect(page.locator('dialog.perm-dialog')).toHaveCount(0); }); @@ -1274,12 +1293,12 @@ test.describe('request-permission action hardening', () => { // (the referrer, or the opener's reply to the `requestOrigin` // handshake). Believing the query string would let a bare link raise a // consent prompt in any app's name and commit the user's grant to it. - await page.goto( + const answer = await answerWithoutPrompt( + page, `/action/request-permission?permission=${encodeURIComponent(UNHELD_PERMISSION)}` + `&origin=${encodeURIComponent('https://not-the-requester.example/')}`, ); - await page.waitForFunction(() => !!window.puter?.authToken, null, { timeout: 60_000 }); - await page.locator('.desktop').waitFor({ timeout: 60_000 }); + expect(answer?.granted).toBe(false); await expect(page.locator('dialog.perm-dialog')).toHaveCount(0); });