59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
// @ts-check
|
|
import { test, expect } from '@playwright/test';
|
|
import { loadTestUser } from '../utils/testUser.js';
|
|
|
|
test.describe('@p0 Interest Inventory → Career Explorer', () => {
|
|
test.setTimeout(20000);
|
|
|
|
test('answer (randomize on dev) → submit → land on Explorer', async ({ page }) => {
|
|
const user = loadTestUser();
|
|
|
|
// Sign in (fresh context each test)
|
|
await page.context().clearCookies();
|
|
await page.goto('/signin', { waitUntil: 'networkidle' });
|
|
await expect(page.getByRole('heading', { name: /Sign In/i })).toBeVisible();
|
|
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 });
|
|
|
|
// Go to Interest Inventory
|
|
await page.goto('/interest-inventory', { waitUntil: 'networkidle' });
|
|
await expect(page.getByRole('heading', { name: /Interest Inventory/i })).toBeVisible();
|
|
|
|
// Wait for questions to render (page 1 of 10, 6 selects)
|
|
await expect(page.getByText(/Page\s+1\s+of\s+10/i)).toBeVisible();
|
|
await expect(page.locator('select')).toHaveCount(6, { timeout: 10000 });
|
|
|
|
// Dev-only helper: Randomize answers
|
|
const randomizeBtn = page.getByRole('button', { name: /Randomize Answers/i });
|
|
if (await randomizeBtn.isVisible()) {
|
|
await randomizeBtn.click();
|
|
await expect(page.getByText(/60\s*\/\s*60\s*answered/i)).toBeVisible();
|
|
} else {
|
|
// Fallback: fill current page with "Neutral" (3), then next; repeat (rare on prod)
|
|
for (let p = 0; p < 10; p++) {
|
|
const selects = page.locator('select');
|
|
const n = await selects.count();
|
|
for (let i = 0; i < n; i++) await selects.nth(i).selectOption('3');
|
|
if (p < 9) await page.getByRole('button', { name: /^Next$/ }).click();
|
|
}
|
|
}
|
|
|
|
// Move to last page if needed (randomize doesn't jump pages)
|
|
for (let i = 0; i < 9; i++) {
|
|
const next = page.getByRole('button', { name: /^Next$/ });
|
|
if (await next.isVisible()) await next.click();
|
|
}
|
|
|
|
// Submit
|
|
await page.getByRole('button', { name: /^Submit$/ }).click();
|
|
|
|
// Land on Career Explorer
|
|
await page.waitForURL('**/career-explorer**', { timeout: 20000 });
|
|
await expect(
|
|
page.getByRole('heading', { name: /Explore Careers - use these tools/i })
|
|
).toBeVisible({ timeout: 20000 });
|
|
});
|
|
});
|