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:
39
e2e/tests/mobile/mobile-login-on-startup.spec.ts
Normal file
39
e2e/tests/mobile/mobile-login-on-startup.spec.ts
Normal 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 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user