// @ts-check // Tests: T1–T5 — dailies feed and individual entry pages const { test, expect } = require('@playwright/test'); // Known fixture entries that always exist in the repo const KNOWN_SLUG = '2026-03-25-1540-wheels-down-narita.entry'; const KNOWN_TITLE = 'Wheels Down at Narita'; 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) // ── 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('.site-header')).toBeVisible(); }); // ── T2: Entries are newest-first ────────────────────────────────────────────── // Verify using two known fixture entries rather than all entries // (the dailies may contain noisy test-run debris with inconsistent dates). 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 a[href*="${NEWER_SLUG}"]`); const olderCard = page.locator(`.entry-card a[href*="${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.contains(el)); }); const olderIdx = await olderCard.evaluate(el => { return [...document.querySelectorAll('.entry-card')].findIndex(c => c.contains(el)); }); expect(newerIdx).toBeLessThan(olderIdx); }); // ── T3: Individual entry page loads ─────────────────────────────────────────── test('T3: individual entry page loads at /trips/japan-korea-2026/dailies/{slug}', async ({ page }) => { await page.goto(`/trips/japan-korea-2026/dailies/${KNOWN_SLUG}`); await expect(page.locator('article.entry')).toBeVisible(); await expect(page.locator('.site-header')).toBeVisible(); }); // ── T4: Entry page shows title, date, and content ───────────────────────────── test('T4: entry page shows title and body content', async ({ page }) => { await page.goto(`/trips/japan-korea-2026/dailies/${KNOWN_SLUG}`); await expect(page.locator('.entry-title')).toContainText(KNOWN_TITLE); await expect(page.locator('.entry-body')).not.toBeEmpty(); await expect(page.locator('time.entry-date')).toBeVisible(); }); // ── T5: Entry page shows location when present ──────────────────────────────── test('T5: entry page shows city and country when set', async ({ page }) => { await page.goto(`/trips/japan-korea-2026/dailies/${KNOWN_SLUG}`); await expect(page.locator('.entry-location')).toContainText(KNOWN_CITY); await expect(page.locator('.entry-location')).toContainText(KNOWN_COUNTRY); });