Merge branch 'feat/mobile-admin-entry' into chore/reconcile-ui-review

This commit is contained in:
MechaCat02
2026-06-25 21:13:55 +02:00
3 changed files with 34 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ const DESKTOP = { width: 1280, height: 720 } as const;
async function mockSession(
page: Page,
opts: { authed?: boolean; logoutCalls?: { count: number } } = {}
opts: { authed?: boolean; admin?: boolean; logoutCalls?: { count: number } } = {}
) {
const authed = opts.authed ?? false;
await page.route('**/api/v1/auth/config', (route) =>
@@ -31,7 +31,7 @@ async function mockSession(
id: 'u1',
username: 'fabian',
created_at: '2026-01-05T00:00:00Z',
is_admin: false
is_admin: opts.admin ?? false
}
})
: JSON.stringify({
@@ -175,11 +175,27 @@ test.describe('mobile account hub', () => {
await expect(page.getByTestId('account-row-preferences')).toBeVisible();
await expect(page.getByTestId('account-row-change-password')).toBeVisible();
await expect(page.getByTestId('account-row-logout')).toBeVisible();
// A non-admin never sees the Admin entry.
await expect(page.getByTestId('account-row-admin')).toHaveCount(0);
// Desktop card MUST not render — only the hub view is active
// on mobile so we don't double-up the password form testids.
await expect(page.getByTestId('account-desktop-card')).toHaveCount(0);
});
test('phone viewport admin: the account hub offers an Admin row linking to /admin', async ({
page
}) => {
// Admin is reachable from the desktop header but had no mobile entry
// point — admins had to type the URL. The Account hub now carries it.
await mockSession(page, { authed: true, admin: true });
await page.setViewportSize(MOBILE);
await page.goto('/profile/account');
const adminRow = page.getByTestId('account-row-admin');
await expect(adminRow).toBeVisible();
await expect(adminRow).toHaveAttribute('href', '/admin');
});
test('phone viewport authed: Change password row opens the bottom sheet', async ({
page
}) => {