32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
// @ts-check
|
|
import { test, expect } from '@playwright/test';
|
|
import { loadTestUser } from '../utils/testUser.js';
|
|
|
|
test.describe('@p0 PremiumRoute guard', () => {
|
|
test.setTimeout(20000);
|
|
|
|
test('non-premium user is redirected to /paywall from premium routes', async ({ page }) => {
|
|
const user = loadTestUser();
|
|
|
|
// Sign in
|
|
await page.context().clearCookies();
|
|
await page.goto('/signin', { waitUntil: 'networkidle' });
|
|
await page.getByPlaceholder('Username', { exact: true }).fill(user.username);
|
|
await page.getByPlaceholder('Password', { exact: true }).fill(user.password);
|
|
await page.getByRole('button', { name: /^Sign In$/ }).click();
|
|
await page.waitForURL('**/signin-landing**', { timeout: 15000 });
|
|
|
|
// 1) /enhancing should bounce to /paywall
|
|
await page.goto('/enhancing', { waitUntil: 'networkidle' });
|
|
await expect(page).toHaveURL(/\/paywall(\?|$)/, { timeout: 8000 });
|
|
|
|
// 2) /retirement should bounce to /paywall
|
|
await page.goto('/retirement', { waitUntil: 'networkidle' });
|
|
await expect(page).toHaveURL(/\/paywall(\?|$)/, { timeout: 8000 });
|
|
|
|
// 3) /career-roadmap (premium) should bounce to /paywall
|
|
await page.goto('/career-roadmap', { waitUntil: 'networkidle' });
|
|
await expect(page).toHaveURL(/\/paywall(\?|$)/, { timeout: 8000 });
|
|
});
|
|
});
|