47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
// @ts-check
|
|
import { test, expect } from '@playwright/test';
|
|
import { loadTestUser } from '../utils/testUser.js';
|
|
|
|
test.describe('@p0 Chat drawer — Retirement tab visibility (premium-aware)', () => {
|
|
test.setTimeout(20000);
|
|
|
|
test('Retirement tab visible only on /retirement for premium; otherwise Support-only on /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 });
|
|
|
|
// Try to reach Retirement Planner (PremiumRoute)
|
|
await page.goto('/retirement', { waitUntil: 'networkidle' });
|
|
const url = page.url();
|
|
|
|
// Open chat via FAB
|
|
const fab = page.getByRole('button', { name: /^Open chat$/i });
|
|
await expect(fab).toBeVisible({ timeout: 5000 });
|
|
await fab.click();
|
|
|
|
const supportTab = page.getByRole('button', { name: /^Aptiva\s*Support$/i });
|
|
const retireTab = page.getByRole('button', { name: /^Retirement\s*Helper$/i });
|
|
|
|
await expect(supportTab).toBeVisible({ timeout: 5000 });
|
|
|
|
if (/\/paywall(\?|$)/.test(url)) {
|
|
// Non-premium path: Retirement tab should NOT be present
|
|
const visible = await retireTab.isVisible().catch(() => false);
|
|
expect(visible).toBeFalsy();
|
|
} else if (/\/retirement(\?|$)/.test(url)) {
|
|
// Premium path: Retirement tab should be visible
|
|
await expect(retireTab).toBeVisible({ timeout: 5000 });
|
|
} else {
|
|
// Unexpected route; treat as guard behavior: Support-only
|
|
const visible = await retireTab.isVisible().catch(() => false);
|
|
expect(visible).toBeFalsy();
|
|
}
|
|
});
|
|
});
|