Also gates the start page's remaining :hover effects behind (hover: hover), which the load-time animation test showed leaking onto touch emulation. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
59 lines
2.3 KiB
TypeScript
59 lines
2.3 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { blockThirdParty, setPref, P, I } from './helpers.ts';
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await blockThirdParty(page);
|
|
});
|
|
|
|
for (const id of [P.byHand, P.someAi, P.aiMade, P.unknown, P.byHand2]) {
|
|
test(`/work/${id}/ loads directly`, async ({ page }) => {
|
|
const res = await page.goto(`/work/${id}/`);
|
|
expect(res!.status()).toBe(200);
|
|
await expect(page.locator('h1').first()).toBeVisible();
|
|
});
|
|
}
|
|
|
|
for (const id of [I.song, I.byHand, I.unknown, I.someAi]) {
|
|
test(`/off-the-clock/${id}/ loads directly`, async ({ page }) => {
|
|
const res = await page.goto(`/off-the-clock/${id}/`);
|
|
expect(res!.status()).toBe(200);
|
|
await expect(page.locator(`article.card[data-id="${id}"]`)).toBeVisible();
|
|
});
|
|
}
|
|
|
|
test('draft projects have no page', async ({ page }) => {
|
|
const res = await page.goto(`/work/${P.draft}/`);
|
|
expect(res!.status()).toBe(404);
|
|
});
|
|
|
|
for (const path of ['/work/nope/', '/off-the-clock/x/', '/nothing-here/']) {
|
|
test(`${path} is a real 404`, async ({ page }) => {
|
|
const res = await page.goto(path);
|
|
expect(res!.status()).toBe(404);
|
|
await expect(page.getByRole('heading', { name: "That page isn't here." })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: 'Work' })).toBeVisible();
|
|
});
|
|
}
|
|
|
|
test('a filtered-out project opened by URL still shows, with a note', async ({ page }) => {
|
|
await setPref(page, 'by-hand-only');
|
|
await page.goto(`/work/${P.aiMade}/`);
|
|
await expect(page.locator('html')).toHaveAttribute('data-pref', 'by-hand-only');
|
|
await expect(page.locator('h1').first()).toBeVisible();
|
|
await expect(page.locator('.pref-note')).toBeVisible();
|
|
await expect(page.locator('.pref-note')).toContainText('shown because you opened it directly');
|
|
});
|
|
|
|
test('a filtered-out item opened by URL still shows, with a note', async ({ page }) => {
|
|
await setPref(page, 'by-hand-only');
|
|
await page.goto(`/off-the-clock/${I.unknown}/`);
|
|
await expect(page.locator(`article.card[data-id="${I.unknown}"]`)).toBeVisible();
|
|
await expect(page.locator('.pref-note')).toBeVisible();
|
|
});
|
|
|
|
test('a project that is not hidden shows no note', async ({ page }) => {
|
|
await setPref(page, 'by-hand-only');
|
|
await page.goto(`/work/${P.byHand}/`);
|
|
await expect(page.locator('.pref-note')).toBeHidden();
|
|
});
|