Skip to content
Merged
10 changes: 0 additions & 10 deletions e2e/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ test.describe('Accessibility', () => {
await expect(page.getByText('Lost in the feed')).toHaveCount(0);
});

test('external links have valid URLs', async ({ page }) => {
await page.goto('/#/');

const externalLink = page.getByRole('link', { name: 'Rust Is the Future of JavaScript Infrastructure' });
await expect(externalLink).toBeVisible();

const href = await externalLink.getAttribute('href');
expect(href).toContain('https://example.com');
});

test('best stories page has no critical accessibility violations', async ({ page, makeAxeBuilder }) => {
await page.goto('/#/best');

Expand Down
19 changes: 0 additions & 19 deletions e2e/comment-detail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ test.describe('Comment Detail', () => {
});
});

test.describe('Comment Detail - Desktop', () => {
test.use({ viewport: { width: 1280, height: 720 } });

test.beforeEach(async ({ page }) => {
await setupApiMocks(page);
});

test('shows comment detail page on desktop', async ({ page }) => {
await page.goto('/#/item/1001');

await expect(page.getByText('patio11').first()).toBeVisible();
await expect(page.getByText(/wasm-bindgen/i).first()).toBeVisible();

// Mobile-only swipe container must not appear at desktop width.
const swipeContainer = page.locator('.swipe-snap-container');
await expect(swipeContainer).not.toBeVisible();
});
});

test.describe('Comment Detail - Error + Retry', () => {
test.use({ viewport: { width: 1280, height: 720 } });

Expand Down
53 changes: 0 additions & 53 deletions e2e/comment-swipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ test.describe('Mobile Comment Swipe Viewer', () => {
await expect(page).toHaveURL(/\/item\/1001/, { timeout: 5000 });
});

test('shows comment content in swipe viewer on mobile', async ({ page }) => {
await page.goto('/#/item/1001');

const swipeContainer = page.getByTestId('swipe-container');
await expect(swipeContainer).toBeVisible();

await expectActiveSwipePanelText(page, 'patio11', { timeout: 10000 });

await expectActiveSwipePanelText(page, /wasm-bindgen/i);
});

test('loads sibling comments as swipeable panels', async ({ page }) => {
await page.goto('/#/item/1001');

Expand All @@ -78,21 +67,6 @@ test.describe('Mobile Comment Swipe Viewer', () => {
await expect(panels).toHaveCount(4);
});

test('can swipe to next sibling comment', async ({ page }) => {
await page.goto('/#/item/1001');

await waitForSwipeReady(page, 4);

const container = page.getByTestId('swipe-container');
const panelWidth = await container.evaluate((el) => el.getBoundingClientRect().width);

await smoothScrollAndAwaitSettled(container, panelWidth);
await waitForScrollAtIndex(page, 1);
await expect(page).toHaveURL(/\/item\/1002/, { timeout: 5000 });

await expectActiveSwipePanelText(page, 'jgrahamc', { minPanels: 4, timeout: 10000 });
});

test('custom swipe scrollbar moves when document scrolls in comment viewer', async ({ page }) => {
await page.goto('/#/item/1002');

Expand Down Expand Up @@ -156,25 +130,6 @@ test.describe('Mobile Comment Swipe Viewer', () => {
await expect(page).toHaveURL(/\/item\/1001/, { timeout: 5000 });
});

test('shows parent and story links in comment', async ({ page }) => {
await page.goto('/#/item/1001');

await expectActiveSwipePanelText(page, 'patio11', { timeout: 10000 });

const parentLink = page.getByRole('link', { name: 'parent' }).first();
await expect(parentLink).toBeVisible();

await expectActiveSwipePanelText(page, 'Rust Is the Future of JavaScript Infrastructure');
});

test('header shows "comments" indicator on mobile comment view', async ({ page }) => {
await page.goto('/#/item/1001');

await expectActiveSwipePanelText(page, 'patio11', { timeout: 10000 });

await expect(page.getByText('comments').first()).toBeVisible();
});

test('swipe uses replaceState — no extra history entries', async ({ page }) => {
await page.goto('/#/item/1001');

Expand Down Expand Up @@ -342,14 +297,6 @@ test.describe('Mobile Comment Swipe Viewer', () => {
await expect(page.getByText('Failed to load comments').first()).toBeVisible({ timeout: 30000 });
});

test('sets document title to "Comment by {author}" for the current comment', async ({ page }) => {
await page.goto('/#/item/1001');

await expectActiveSwipePanelText(page, 'patio11', { timeout: 10000 });

await expect(page).toHaveTitle(/Comment by patio11/);
});

test('clicking item title link navigates to story viewer, not comment viewer', async ({ page }) => {
await page.goto('/#/item/1001');

Expand Down
112 changes: 11 additions & 101 deletions e2e/domain-filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,6 @@ import {
setOfflineAndWaitForBar,
} from './fixtures/layout-helpers';

test.describe('Domain Filter', () => {
test.beforeEach(async ({ page }) => {
await setupApiMocks(page);
});

test('displays items filtered by domain', async ({ page }) => {
await page.goto('/#/from/example.com');

// Two valid landing URLs:
// - Desktop: stays at /#/from/example.com (DomainStories list).
// - Mobile: SwipeDomainStoryViewer immediately replaceState()s
// to /#/item/:firstId (objectID '77777' from the mock). This
// rewrite races Playwright's first poll, so a strict
// /#/from/example.com regex deterministically loses on mobile.
// Same pattern as the empty-domain test at the bottom of this
// file, which uses /\/#\/(item\/\d+)?$/ for the same reason.
await expect(page).toHaveURL(/\/#\/(from\/example\.com|item\/77777)/);

// Story-title visibility is the load-bearing assertion: the title
// appears whether the desktop list or the mobile swipe panel
// rendered, and it only appears if the domain filter actually
// worked (the mock filters on `?query=example.com`).
await expect(page.getByText('Google Announces Gemini 3.0 with Extended Context').first()).toBeVisible({ timeout: 10000 });

await expect(page.getByText(/example\.com/i).first()).toBeVisible();
});
});

test.describe('Domain Filter - Edge Cases', () => {
test.beforeEach(async ({ page }) => {
await setupApiMocks(page);
Expand All @@ -54,12 +26,6 @@ test.describe('Domain Filter - Edge Cases', () => {

await expect(page).toHaveTitle(/unknown-domain\.xyz.*HackerTok/);
});

test('domain with subdomain works', async ({ page }) => {
await page.goto('/#/from/blog.example.com');

await expect(page).toHaveURL(/\/#\/from\/blog\.example\.com/);
});
});

test.describe('Domain Filter - Centered state layouts', () => {
Expand Down Expand Up @@ -89,10 +55,10 @@ test.describe('Domain Filter - Header "from" button', () => {
// story" and "browser back restores the list" tests below click
// StoryCard links inside DomainStories, which only renders on desktop —
// on mobile, SwipeDomainStoryViewer replaces the URL with /#/item/:id
// before any list card is visible. The earlier "visible + active" and
// "hidden on non-domain pages" assertions would also hold on mobile
// (Header's `isFromActive` stays true across the URL rewrite via
// state.fromDomain), but they are kept here for locality. The mobile
// before any list card is visible. The "visible + active" assertions
// would also hold on mobile (Header's `isFromActive` stays true across
// the URL rewrite via state.fromDomain), but they are kept here for
// locality. The mobile
// rewrite path is covered by "updates URL to /item/:id and carries
// fromDomain state on swipe" in the Mobile Swipe describe below.
test.use({ viewport: { width: 1280, height: 720 }, deviceScaleFactor: 1 });
Expand All @@ -114,16 +80,6 @@ test.describe('Domain Filter - Header "from" button', () => {
await expect(page.getByRole('link', { name: 'ask', exact: true })).not.toHaveClass(/bg-accent/);
});

test('"from" button is hidden on non-domain pages', async ({ page }) => {
const fromButton = page.locator('header nav span', { hasText: 'from' });

await page.goto('/#/');
await expect(fromButton).toHaveCount(0);

await page.goto('/#/best');
await expect(fromButton).toHaveCount(0);
});

test('"from" button stays active after opening a story\'s comments from a domain list', async ({ page }) => {
// Desktop: StoryCard inside DomainStories renders the domain as fromDomain,
// so the "comments" link carries state.fromDomain instead of state.from.
Expand Down Expand Up @@ -254,15 +210,9 @@ test.describe('Domain Filter - Pagination', () => {
});

test.describe('Domain Filter - Domain change reset', () => {
// Desktop-scoped: on mobile, SwipeDomainStoryViewer is keyed by `domain`
// in App.tsx, which unmounts the old viewer and mounts a fresh one on
// every domain change — the new instance initializes cleanly through
// the hook's lazy useState init, so the `if (prevDomain !== domain)`
// reset block never runs. DomainStories is NOT keyed and stays mounted
// across /#/from/:a → /#/from/:b transitions, which is the only browser
// path that exercises the reset block. (Unit tests pin the branch
// directly; this pins the wiring between StoryCard's hostname pill and
// the hook.)
// Desktop-scoped: pins the `key` on DomainStories in App.tsx. The route
// element stays the same across /#/from/:a → /#/from/:b, so without the
// key the page would keep the old domain's list state.
test.use({ viewport: { width: 1280, height: 720 }, deviceScaleFactor: 1 });

test.beforeEach(async ({ page }) => {
Expand All @@ -275,15 +225,14 @@ test.describe('Domain Filter - Domain change reset', () => {

// Client-side hash change — same mechanism React Router dispatches
// when StoryCard's hostname pill is clicked to cross-link into a
// different domain. No page reload, so the DomainStories instance
// stays mounted and the hook re-renders with a new `domain` prop.
// different domain. No page reload; only the key remounts the page.
await page.evaluate(() => { window.location.hash = '#/from/example.org'; });

// The default mock returns mockDomainItem (URL: https://example.com/…)
// regardless of the `query` param, so the hook's URL-filter rejects
// every hit for example.org and we land on the empty state. That
// state rendering is only possible if the reset block cleared the
// old `stories` array — otherwise the first commit after the hash
// state rendering is only possible if the remount dropped the old
// `stories` array — otherwise the first commit after the hash
// change would still show the example.com items.
await expect(page.getByText('Google Announces Gemini 3.0 with Extended Context')).not.toBeVisible({ timeout: 5000 });
await expect(page.getByText(/No submissions found from.*example\.org/i)).toBeVisible({ timeout: 10000 });
Expand Down Expand Up @@ -376,36 +325,11 @@ test.describe('Domain Filter - Mobile Swipe', () => {
// desktop list (SwipeStoryViewerCore vs DomainStories) with different copy
// ("Failed to load item" singular vs "Failed to load items" plural) and
// different surrounding markup (swipe-snap-container). The "Algolia Error
// Handling" describe below pins the desktop path; these mirror it for the
// Handling" describe below pins the desktop path; this mirrors it for the
// mobile swipe wiring so a regression in either codepath is caught.
// Auto-retry exhausts 3 backoff attempts (2s+4s+8s ≈ 14s) before showing
// error UI, hence the per-test timeout override.

test('shows error state when Algolia returns 503 on mobile swipe', async ({ page }) => {
test.setTimeout(60000);

await page.route(`${ALGOLIA_API}/search_by_date*`, async (route) => {
await route.fulfill({ status: 503, json: { message: 'Service unavailable' } });
});

await page.goto('/#/from/example.com');

// Mobile copy is singular ("item") — the desktop test's regex
// `/Failed to load items/` would not match here, so an exact assertion
// pins the mobile branch specifically.
await expect(page.getByText('Failed to load item', { exact: true })).toBeVisible({ timeout: 30000 });
// Mobile's StateView omits the `description` prop, so the default copy
// ("We couldn't load this content. Please try again.") renders alongside
// the action label. Use the button role to disambiguate from that text.
await expect(page.getByRole('button', { name: /try again/i })).toBeVisible();

// Confirm the error UI is rendered inside the swipe viewer's container,
// not the desktop list's wrapper. Catches a regression that flips
// `useCanSwipe` — its width half or its pointer half — and leaks the
// desktop list into a phone.
await expect(page.getByTestId('swipe-container')).toBeVisible();
});

test('recovers after retry when Algolia temporarily fails on mobile swipe', async ({ page }) => {
test.setTimeout(60000);

Expand Down Expand Up @@ -506,20 +430,6 @@ test.describe('Domain Filter - Algolia Error Handling', () => {
// Auto-retry exhausts 3 backoff attempts (2s+4s+8s) before surfacing error.
test.setTimeout(60000);

test('shows error state when Algolia returns 503', async ({ page }) => {
await setupApiMocks(page);

await page.route(`${ALGOLIA_API}/search_by_date*`, async (route) => {
await route.fulfill({ status: 503, json: { message: 'Service unavailable' } });
});

await page.goto('/#/from/example.com');

// 30s timeout covers the 2+4+8 backoff plus slack.
await expect(page.getByText(/Failed to load items/)).toBeVisible({ timeout: 30000 });
await expect(page.getByText(/try again/i)).toBeVisible();
});

test('recovers after retry when Algolia temporarily fails', async ({ page }) => {
await setupApiMocks(page);

Expand Down
42 changes: 0 additions & 42 deletions e2e/header-overflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,6 @@ test.describe('Header overflow — More dropdown', () => {
const userPill = (page: Page) =>
page.locator('header nav span', { hasText: 'user' });

test('shows the "More tabs" trigger when nav items overflow', async ({ page }) => {
await page.goto('/#/submitted/pg');
await expect(userPill(page)).toBeVisible();

const moreBtn = page.getByRole('button', { name: 'More tabs' });
await expect(moreBtn).toBeVisible();
await expect(moreBtn).toHaveAttribute('aria-haspopup', 'menu');
// Closed menus must NOT mount their portal content.
await expect(page.getByRole('menuitem')).toHaveCount(0);
});

test('opens the menu on click and reveals hidden feed tabs as menuitems', async ({ page }) => {
await page.goto('/#/submitted/pg');
await expect(userPill(page)).toBeVisible();

await page.getByRole('button', { name: 'More tabs' }).click();

// Asserting on menuitem visibility is the strongest "menu actually
// opened" signal. We avoid asserting `aria-expanded='true'` on the
// trigger because Radix re-applies props via a Slot wrapper on open,
// which can briefly invalidate any stored locator handle in Playwright
// even though the underlying button is still in the DOM. The menuitem
// existence test is the user-facing contract.
await expect(page.getByRole('menuitem').first()).toBeVisible();
});

test('clicking a hidden feed in the menu navigates to that route', async ({ page }) => {
await page.goto('/#/submitted/pg');
await expect(userPill(page)).toBeVisible();
Expand Down Expand Up @@ -390,19 +364,3 @@ test.describe('Header overflow — the trigger stays a target', () => {
expect(box.height).toBeCloseTo(pill.height, 0);
});
});

test.describe('Theme toggle — accessible label', () => {
test.beforeEach(async ({ page }) => {
await setupApiMocks(page);
});

test('theme toggle button has an accessible label describing the action', async ({ page }) => {
await page.goto('/#/');
await expect(
page.getByText('Rust Is the Future of JavaScript Infrastructure').first(),
).toBeVisible();

const toggle = page.getByTestId('theme-toggle');
await expect(toggle).toHaveAccessibleName(/switch to (system|light|dark)/i);
});
});
23 changes: 0 additions & 23 deletions e2e/item-detail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ test.describe('Item Detail', () => {
await expect(page.getByText('tptacek').first()).toBeVisible();
});

test('can expand and collapse replies', async ({ page }) => {
await page.goto('/#/item/12345');

await expect(page.getByText('patio11').first()).toBeVisible({ timeout: 10000 });

await page.getByText(/1 reply/i).first().click();
await expect(page.getByText('tptacek').first()).toBeVisible();

// Trunk line button collapses the whole subtree, not just the immediate child.
await page.getByRole('button', { name: /collapse replies/i }).first().click();
await expect(page.getByText('tptacek').first()).not.toBeVisible();
});

test('handles item not found', async ({ page }) => {
// 99999999 returns null in the mock — exercises the not-found branch.
await page.goto('/#/item/99999999');
Expand Down Expand Up @@ -238,16 +225,6 @@ test.describe('Item Detail - Desktop', () => {
await setupApiMocks(page);
});

test('shows full item detail page on desktop', async ({ page }) => {
await page.goto('/#/item/12345');

// Mobile-only swipe container must not appear at desktop width.
const swipeContainer = page.locator('.swipe-snap-container');
await expect(swipeContainer).not.toBeVisible();

await expect(page.getByText('Rust Is the Future of JavaScript Infrastructure').first()).toBeVisible();
});

test('back from item detail returns to item list', async ({ page }) => {
await page.goto('/#/');
await expect(page.getByText('Rust Is the Future of JavaScript Infrastructure').first()).toBeVisible();
Expand Down
Loading