Match dashboard paths in any letter case, and stop the e2e tests waiting on .desktop

- bootsDashboard() matches /dashboard and /app/<name> case-insensitively, as the server routes them, so /App/<name> 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.
This commit is contained in:
Nariman Jelveh committed 2026-11-12 17:31:36 -07:00
1 parent abb647d227
commit 6050ff78c3
5 files changed
+37 -13

No files matched your search

+4 -3
View File
@@ -20,7 +20,8 @@
/**
* Whether a page load boots the dashboard instead of the desktop. The root
* path and `/app/<name>` 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;
}
@@ -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);
});
-1
View File
@@ -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',
-2
View File
@@ -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é',
@@ -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);
});