30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
// @ts-check
|
|
import { test, expect } from '@playwright/test';
|
|
import { loadTestUser } from '../utils/testUser.js';
|
|
|
|
test.describe('@p0 Paywall CTA', () => {
|
|
test.setTimeout(20000);
|
|
|
|
test('Upgrade to Premium visible on non-premium pages and navigates to /paywall', 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 });
|
|
|
|
// On /signin-landing (non-premium path) CTA should be visible for non-premium users
|
|
const cta = page.getByRole('button', { name: /^Upgrade to Premium$/i }).or(
|
|
page.getByText(/^Upgrade to Premium$/i)
|
|
);
|
|
await expect(cta).toBeVisible({ timeout: 5000 });
|
|
|
|
// Click navigates to /paywall
|
|
await cta.click();
|
|
await expect(page).toHaveURL(/\/paywall(\?|$)/, { timeout: 8000 });
|
|
});
|
|
});
|