test: update T1/T2 selectors for inline journal-post structure

This commit is contained in:
2026-06-20 14:50:30 +02:00
parent 69820fe1cb
commit b3ceb4a8f7
2 changed files with 9 additions and 9 deletions
+8 -8
View File
@@ -9,13 +9,13 @@ const KNOWN_CITY = 'Tokyo';
const KNOWN_COUNTRY = 'Japan';
// Use two fixture entries with different dates to verify descending order
const NEWER_SLUG = '2026-06-17.entry'; // most recent fixture (June 17)
const OLDER_SLUG = '2026-03-25-1540-wheels-down-narita.entry'; // oldest fixture (March 25)
const NEWER_SLUG = '2026-04-01-0900-seoul-calling.entry'; // newer fixture
const OLDER_SLUG = '2026-03-25-1540-wheels-down-narita.entry'; // older fixture
// ── T1: Dailies page loads ─────────────────────────────────────────────────────
test('T1: /trips/japan-korea-2026/dailies loads and shows at least one entry card', async ({ page }) => {
await page.goto('/trips/japan-korea-2026/dailies');
await expect(page.locator('.entry-card').first()).toBeVisible();
await expect(page.locator('.journal-post').first()).toBeVisible();
await expect(page.locator('.site-header')).toBeVisible();
});
@@ -25,19 +25,19 @@ test('T1: /trips/japan-korea-2026/dailies loads and shows at least one entry car
test('T2: dailies shows newer entries before older entries', async ({ page }) => {
await page.goto('/trips/japan-korea-2026/dailies');
// Both fixture entries must be visible on the page
const newerCard = page.locator(`.entry-card[href*="${NEWER_SLUG}"]`);
const olderCard = page.locator(`.entry-card[href*="${OLDER_SLUG}"]`);
// Use attribute selector to handle dots in slug names (CSS dots are class selectors)
const newerCard = page.locator(`.journal-post[id="entry-${NEWER_SLUG}"]`);
const olderCard = page.locator(`.journal-post[id="entry-${OLDER_SLUG}"]`);
await expect(newerCard).toBeVisible();
await expect(olderCard).toBeVisible();
// The newer entry should appear higher in the DOM (lower index)
const newerIdx = await newerCard.evaluate(el => {
return [...document.querySelectorAll('.entry-card')].findIndex(c => c === el);
return [...document.querySelectorAll('.journal-post')].findIndex(c => c.id === el.id);
});
const olderIdx = await olderCard.evaluate(el => {
return [...document.querySelectorAll('.entry-card')].findIndex(c => c === el);
return [...document.querySelectorAll('.journal-post')].findIndex(c => c.id === el.id);
});
expect(newerIdx).toBeLessThan(olderIdx);