dev1/tests/e2e/18-nav-menus.spec.mjs

48 lines
2.1 KiB
JavaScript

// @ts-check
import { test, expect } from '@playwright/test';
import { loadTestUser } from '../utils/testUser.js';
test.describe('@p0 Header nav menus', () => {
test.setTimeout(15000);
test('Find Your Career menu → Career Explorer & Interest Inventory', async ({ page }) => {
const u = loadTestUser();
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 });
// Open "Find Your Career" dropdown (group-hover)
const findBtn = page.getByRole('button', { name: /^Find Your Career$/i });
await findBtn.hover();
// Click "Career Explorer"
await page.getByRole('link', { name: /^Career Explorer$/i }).click();
await expect(page.getByRole('heading', { name: /Explore Careers - use these tools/i }))
.toBeVisible({ timeout: 8000 });
// Back to header and open dropdown again
await findBtn.hover();
await page.getByRole('link', { name: /^Interest Inventory$/i }).click();
await expect(page.getByRole('heading', { name: /^Interest Inventory$/i }))
.toBeVisible({ timeout: 8000 });
});
test('Preparing menu → Educational Programs', async ({ page }) => {
const u = loadTestUser();
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 prepBtn = page.getByRole('button', { name: /Preparing & UpSkilling for Your Career/i });
await prepBtn.hover();
await page.getByRole('link', { name: /^Educational Programs$/i }).click();
await expect(page).toHaveURL(/\/educational-programs(\?|$)/, { timeout: 8000 });
});
});