- Introduce `USE_ANONYMOUS_AUTH_SESSIONS` to make guest access an opt-in feature. - Transition root-level pages into `(app)` and `(public)` route groups for improved access control. - Adopt Figtree as the primary typeface and implement a pre-render theme initialization script. - Decouple audiobook chapter processing into a standalone API route and harden resource ownership logic. - Replace the legacy footer with a unified layout and add skeleton loading states for document lists. - Update environment documentation and test suites to align with the revised routing and auth flows. BREAKING CHANGE: The audiobook generation API has been restructured, moving specific chapter logic to `/api/audiobook/chapter`.
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
import { setupTest, uploadAndDisplay } from './helpers';
|
|
|
|
const AUTH_ENABLED = Boolean(process.env.AUTH_SECRET && process.env.BASE_URL);
|
|
|
|
test.describe('Landing and app routing', () => {
|
|
test('public landing renders without anonymous auth bootstrap call', async ({ page }) => {
|
|
let anonymousSignInCalls = 0;
|
|
|
|
await page.route('**/api/auth/**', async (route) => {
|
|
if (route.request().url().includes('/sign-in/anonymous')) {
|
|
anonymousSignInCalls += 1;
|
|
}
|
|
await route.continue();
|
|
});
|
|
|
|
await page.goto('/');
|
|
await expect(page.getByRole('heading', { name: /your documents,\s*read aloud/i })).toBeVisible({
|
|
timeout: 10000,
|
|
});
|
|
|
|
// Let in-flight requests settle before asserting no anonymous bootstrap happened.
|
|
await page.waitForTimeout(500);
|
|
expect(anonymousSignInCalls).toBe(0);
|
|
});
|
|
|
|
test('existing authenticated session visiting / redirects to /app', async ({ page }) => {
|
|
test.skip(!AUTH_ENABLED);
|
|
|
|
await page.goto('/app');
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForSelector('.fixed.inset-0.bg-base.z-50', { state: 'detached', timeout: 15000 }).catch(() => {});
|
|
|
|
await page.goto('/');
|
|
await expect(page).toHaveURL(/\/app$/);
|
|
});
|
|
|
|
test('documents back link returns to /app', async ({ page }, testInfo) => {
|
|
await setupTest(page, testInfo);
|
|
await uploadAndDisplay(page, 'sample.pdf');
|
|
|
|
await page.getByRole('link', { name: 'Documents' }).click();
|
|
await expect(page).toHaveURL(/\/app$/);
|
|
});
|
|
|
|
test('protected app routes redirect to /signin when anonymous auth is disabled', async ({ page }) => {
|
|
test.skip(!AUTH_ENABLED || process.env.USE_ANONYMOUS_AUTH_SESSIONS !== 'false');
|
|
|
|
await page.goto('/app');
|
|
await expect(page).toHaveURL(/\/signin$/);
|
|
});
|
|
});
|