test: align pro trial browser proof

This commit is contained in:
rcourtman 2026-04-24 22:48:33 +01:00
parent ce7f7e38e6
commit 06d605c33c
2 changed files with 36 additions and 13 deletions

View file

@ -52,6 +52,9 @@ test.describe.serial('Trial signup return flow', () => {
pre.trial_eligible,
'Expected trial_eligible=true before test.',
).toBe(true);
expect(pre.tier).toBe('free');
expect(pre.valid ?? false).toBe(false);
expect(pre.is_lifetime ?? false).toBe(false);
// Start hosted trial via API.
const startRes = await apiRequest(page, '/api/license/trial/start', {
@ -71,19 +74,19 @@ test.describe.serial('Trial signup return flow', () => {
expectTrialRateLimited(startPayload, startRetryAfterHeader);
}
// Verify entitlements remain unchanged until the hosted flow returns.
// Verify commercial entitlements remain unchanged until the hosted flow returns.
const postRes = await apiRequest(page, '/api/license/entitlements');
expect(postRes.ok(), `entitlements post-check failed: HTTP ${postRes.status()}`).toBeTruthy();
const post = (await postRes.json()) as EntitlementPayload;
expect(post.subscription_state).toBe('expired');
expect(post.tier).toBe('free');
expect(post.valid).toBe(false);
expect(post.is_lifetime ?? false).toBe(false);
expect(post.subscription_state).toBe(pre.subscription_state);
expect(post.tier).toBe(pre.tier);
expect(post.valid ?? false).toBe(pre.valid ?? false);
expect(post.is_lifetime ?? false).toBe(pre.is_lifetime ?? false);
expect(post.trial_days_remaining ?? 0).toBe(pre.trial_days_remaining ?? 0);
expect(post.trial_eligible).toBe(true);
// Verify UI still reflects the unactivated local state.
await page.goto('/settings');
await page.getByRole('button', { name: /pulse pro/i }).first().click();
await page.goto('/settings/system/billing');
await expect(page.getByRole('heading', { name: 'Plans & Activation' }).first()).toBeVisible();
await expect(page.getByText(/No Pro license is active/i)).toBeVisible();

View file

@ -4,21 +4,41 @@ import { ensureAuthenticated } from './helpers';
const FREE_TRIAL_ELIGIBLE_ENTITLEMENTS = {
capabilities: [],
limits: [],
subscription_state: 'expired',
subscription_state: 'active',
upgrade_reasons: [],
tier: 'free',
trial_eligible: true,
};
test.describe.serial('Self-hosted trial rate-limit UI', () => {
test('shows Retry-After guidance on the Pulse Pro trial CTA', async ({ page }, testInfo) => {
test('shows Retry-After guidance on Pro feature-gate trial CTAs', async ({ page }, testInfo) => {
test.skip(
testInfo.project.name.startsWith('mobile-'),
'Desktop-only plans coverage',
'Desktop-only feature-gate coverage',
);
await ensureAuthenticated(page);
await page.route('**/api/license/runtime-capabilities', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
capabilities: [],
limits: [],
max_history_days: 7,
}),
});
});
await page.route('**/api/license/commercial-posture', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(FREE_TRIAL_ELIGIBLE_ENTITLEMENTS),
});
});
await page.route('**/api/license/entitlements', async (route) => {
await route.fulfill({
status: 200,
@ -44,10 +64,10 @@ test.describe.serial('Self-hosted trial rate-limit UI', () => {
});
});
await page.goto('/settings/system/billing');
await expect(page.getByRole('heading', { name: 'Plans & Activation' }).first()).toBeVisible();
await page.goto('/settings/security-roles');
await expect(page.getByRole('heading', { name: 'Roles' }).first()).toBeVisible();
const startTrialButton = page.getByRole('button', { name: /start 14-day pro trial/i });
const startTrialButton = page.getByRole('button', { name: /start free trial/i });
await expect(startTrialButton).toBeVisible();
await startTrialButton.click();