// @ts-check import { test, expect } from '@playwright/test'; import { loadTestUser } from '../utils/testUser.js'; test.describe('@p2 Coach — quick actions', () => { test.setTimeout(60000); test('Networking Plan triggers and yields reply without leaking hidden prompts', async ({ page }) => { const u = loadTestUser(); await page.route('**/api/premium/subscription/status', async route => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ is_premium: 1, is_pro_premium: 0 }) }); }); await page.context().clearCookies(); await page.goto('/signin', { waitUntil: 'networkidle' }); await page.getByPlaceholder('Username', { exact: true }).fill(u.username); await page.getByPlaceholder('Password', { exact: true }).fill(u.password); await page.getByRole('button', { name: /^Sign In$/ }).click(); await page.waitForURL('**/signin-landing**', { timeout: 15000 }); const scen = await page.request.post('/api/premium/career-profile', { data: { career_name: 'QA Coach', status: 'planned', start_date: '2025-09-01' } }); const { career_profile_id } = await scen.json(); await page.goto(`/career-roadmap/${career_profile_id}`, { waitUntil: 'networkidle' }); await expect(page.getByRole('heading', { name: 'Career Coach' })).toBeVisible({ timeout: 20000 }); await page.getByRole('button', { name: /Networking Plan/i }).click(); await expect(page.getByText(/Coach is typing/i)).toBeVisible(); await expect(page.getByText(/Coach is typing/i)).toHaveCount(0, { timeout: 30000 }); // Hidden system prompts must not leak const leaks = await page.locator('text=/^# ⛔️|^MODE :|\"milestones\"/').count(); expect(leaks).toBe(0); }); });