// ============================================================ // LEARNING HUB (React port) — smoke tests for /app/learning. // // Covers minimum-viable port: search input + category pills + // feed list render; clicking an item opens the viewer (if any // content is seeded) and renders the Back button. // ============================================================ const { test, expect, E2E_BASE } = require('../fixtures'); async function openReactLearning(page) { await page.goto(E2E_BASE + '/app/learning'); await page.waitForSelector('[data-testid="lh-search"]', { timeout: 15000 }); } test.describe('React Learning Hub — shell + feed', () => { test('search + categories render', async ({ authedPage: _, page }) => { await openReactLearning(page); await expect(page.locator('[data-testid="lh-search"]')).toBeVisible(); await expect(page.locator('[data-testid="lh-categories"]')).toBeVisible(); }); test('feed either lists items or shows an empty-state (no crash)', async ({ authedPage: _, page }) => { await openReactLearning(page); // Either the feed grid exists with items, or the empty-state label shows. const feedItems = await page.locator('[data-testid^="lh-feed-item-"]').count(); const empty = await page.getByText('No content found.').count(); expect(feedItems + empty).toBeGreaterThan(0); }); test('typing in search triggers a new request', async ({ authedPage: _, page }) => { await openReactLearning(page); const [resp] = await Promise.all([ page.waitForResponse('**/api/learning/search**', { timeout: 10000 }), page.fill('[data-testid="lh-search"]', 'fever'), ]); expect(resp.status()).toBe(200); }); });