fix: Bug - No login screen mobile phone on startup

Signed-out mobile visitors landing on / or /dashboard were intentionally
kept on a logged-out /dashboard, so they were never greeted with a login
screen on startup. Replace the imperative startup-redirect logic in
App.ngOnInit with a platform-agnostic pure rule
resolveUnauthenticatedStartupRedirect: non-public routes redirect to
/login (with a safe returnUrl), public routes (/login, /register,
/invite/...) are left alone. Mobile is no longer special-cased.

- Unit: auth-navigation.rules.spec.ts
- E2E: e2e/tests/mobile/mobile-login-on-startup.spec.ts (mobile viewport
  set before navigation; /dashboard and / both land on /login)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 03:38:16 +02:00
parent 182828bb1e
commit cb386394d0
6 changed files with 123 additions and 23 deletions

View File

@@ -0,0 +1,39 @@
import { test, expect } from '../../fixtures/multi-client';
/**
* Regression coverage for: "No login screen mobile phone on startup".
*
* Signed-out mobile users used to be left on a logged-out /dashboard (the
* startup redirect special-cased mobile + root/dashboard and kept them there),
* so they were never greeted with the login screen. The fix removes that mobile
* exception: signed-out visitors are sent to /login on every platform.
*
* The mobile viewport must be set BEFORE navigation so ViewportService reports
* `isMobile === true` at app bootstrap, which is exactly when the redirect ran.
*/
const MOBILE_VIEWPORT = { width: 390, height: 844 };
test.describe('Mobile login screen on startup', () => {
test.describe.configure({ timeout: 120_000 });
test('greets a signed-out mobile visitor on /dashboard with the login screen', async ({ createClient }) => {
const { page } = await createClient();
await page.setViewportSize(MOBILE_VIEWPORT);
await page.goto('/dashboard', { waitUntil: 'domcontentloaded' });
await expect(page).toHaveURL(/\/login/, { timeout: 15_000 });
await expect(page.locator('#login-username')).toBeVisible({ timeout: 15_000 });
});
test('greets a signed-out mobile visitor on the app root with the login screen', async ({ createClient }) => {
const { page } = await createClient();
await page.setViewportSize(MOBILE_VIEWPORT);
await page.goto('/', { waitUntil: 'domcontentloaded' });
await expect(page).toHaveURL(/\/login/, { timeout: 15_000 });
await expect(page.locator('#login-username')).toBeVisible({ timeout: 15_000 });
});
});