// @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-09-01-0700-setting-off-from-campiglia.entry'; const KNOWN_TITLE = 'Setting Off from Campiglia'; const KNOWN_CITY = 'Campiglia Marittima'; const KNOWN_COUNTRY = 'Italy'; // Use two real entries from central-asia-2023 to verify descending order const NEWER_SLUG = '2023-10-18-pixelfed-22.entry'; // newest date in that trip const OLDER_SLUG = '2023-08-28-pixelfed-1.entry'; // oldest date in that trip // ── T1: Dailies page loads ───────────────────────────────────────────────────── test('T1: /trips/italy-2026-demo/dailies loads and shows at least one entry card', async ({ page }) => { await page.goto('/trips/italy-2026-demo/dailies'); await expect(page.locator('.journal-post').first()).toBeVisible(); await expect(page.locator('.site-header')).toBeVisible(); }); // ── T2: Entries are newest-first ────────────────────────────────────────────── // Verify using two known real entries from central-asia-2023 (22 entries, stable order). test('T2: dailies shows newer entries before older entries', async ({ page }) => { await page.goto('/trips/central-asia-2023/dailies'); // 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('.journal-post')].findIndex(c => c.id === el.id); }); const olderIdx = await olderCard.evaluate(el => { return [...document.querySelectorAll('.journal-post')].findIndex(c => c.id === el.id); }); expect(newerIdx).toBeLessThan(olderIdx); }); // ── T3: Individual entry page loads ─────────────────────────────────────────── test('T3: individual entry page loads at /trips/italy-2026-demo/dailies/{slug}', async ({ page }) => { await page.goto(`/trips/italy-2026-demo/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/italy-2026-demo/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/italy-2026-demo/dailies/${KNOWN_SLUG}`); await expect(page.locator('.entry-location')).toContainText(KNOWN_CITY); await expect(page.locator('.entry-location')).toContainText(KNOWN_COUNTRY); }); // ── T6: Entry page has a fixed top back pill and a footer back pill ─────────────── test('T6: entry page has fixed back pill at top and back pill in footer', async ({ page }) => { const KNOWN_ENTRY = '/trips/italy-2026-demo/dailies/2026-09-01-0700-setting-off-from-campiglia.entry'; await page.goto(KNOWN_ENTRY); await expect(page.locator('article.entry')).toBeVisible(); // Fixed top pill (outside the article, before it) const topPill = page.locator('.entry-back-fixed'); await expect(topPill).toBeVisible(); await expect(topPill).toHaveText(/← Back/); // Footer pill const footerPill = page.locator('.entry-footer .back-pill'); await expect(footerPill).toBeVisible(); await expect(footerPill).toHaveText(/← Back/); });