diff --git a/docs/plans/002-dual-interests-and-content.md b/docs/plans/002-dual-interests-and-content.md index ac70b98..3c86832 100644 --- a/docs/plans/002-dual-interests-and-content.md +++ b/docs/plans/002-dual-interests-and-content.md @@ -48,15 +48,15 @@ The three card changes are pure Astro/CSS on top of existing islands (`EmbedOnCl **Interfaces:** - Produces: `Item.interests: string[]` (non-empty after a valid load), `Item.interest === Item.interests[0]`. -- [ ] **Step 1: Failing tests** in `describe('loadContent')`: +- [x] **Step 1: Failing tests** in `describe('loadContent')`: - `'accepts an interest list, primary first'`: item `{ interest: ['comics', 'writing'] }` → `items[0].interests` equals `['comics','writing']`, `interest` is `'comics'`. - `'a single interest becomes a one-element list'`: default item → `interests` equals `['writing']`. - `'reports bad interest lists'`: three items, `interest: []`, `['comics','comics']`, `['comics','nowhere']` → each yields an error with field `interest`; messages contain `must not be empty`, `repeats "comics"`, `unknown interest "nowhere"`. - Change `'rejects unsupported contract'` to use `contract: 3`; add `'accepts contract 2'` (no errors, `site.contract === 2`). -- [ ] **Step 2:** `bun test test/library/load.test.ts` → the new tests FAIL. -- [ ] **Step 3: Implement.** `interestList(v: unknown, report: Report): string[]` in `load.ts`: string → `[v]`; array of non-empty strings → itself (report `must not be empty` / `repeats ""`); anything else → `required`'s message. The unknown-id check in `loadContent` loops over `i.interests`. -- [ ] **Step 4:** `bun test` → all PASS. `bun run typecheck` clean. -- [ ] **Step 5:** Docs as listed, then commit `feat(library): items take one interest or a list; accept contract 2`. +- [x] **Step 2:** `bun test test/library/load.test.ts` → the new tests FAIL. +- [x] **Step 3: Implement.** `interestList(v: unknown, report: Report): string[]` in `load.ts`: string → `[v]`; array of non-empty strings → itself (report `must not be empty` / `repeats ""`); anything else → `required`'s message. The unknown-id check in `loadContent` loops over `i.interests`. +- [x] **Step 4:** `bun test` → all PASS. `bun run typecheck` clean. +- [x] **Step 5:** Docs as listed, then commit `feat(library): items take one interest or a list; accept contract 2`. ### Task 2: One `data-interests` attribute, chips filter by membership, meta names the extra interests @@ -71,11 +71,11 @@ The three card changes are pure Astro/CSS on top of existing islands (`EmbedOnCl - Consumes: `Item.interests` (Task 1). - Produces: `Entry.interests: string[]`, `Entry.also: string[]` (lower-case names of `interests.slice(1)`, minus any equal to `kindLabel(entry)`). -- [ ] **Step 1: Failing tests.** In build.test `'wall renders one card per personal entry…'`: expect `data-interests="${it.interests.join(' ')}"` and `expect(html).not.toContain('data-interest=')`. New test `'a two-interest item counts under both chips'`: the chips island props in `off-the-clock/index.html` give film-tv and music counts that include `fixture-soundtrack-film`, and the card's meta contains `film & tv` then `music`. e2e `'chips filter the wall by interest'`: read `dataset.interests`; every shown card's list includes `music`; then `film & tv` also shows `fixture-soundtrack-film`; "everything" count equals the number of cards. -- [ ] **Step 2:** `bun test test/site/build.test.ts` → FAIL. -- [ ] **Step 3: Implement** as in Interfaces; `toEntries(personal, interests)` derives `also` from the `interests` names. Posts: `interests: [interest]`, `also: []`. Live cards: `data-interests={interest}` when set. -- [ ] **Step 4:** `bun test` PASS; `bun run typecheck` clean. -- [ ] **Step 5:** Commit `feat(site): filter the wall by every interest an item has`. +- [x] **Step 1: Failing tests.** In build.test `'wall renders one card per personal entry…'`: expect `data-interests="${it.interests.join(' ')}"` and `expect(html).not.toContain('data-interest=')`. New test `'a two-interest item counts under both chips'`: the chips island props in `off-the-clock/index.html` give film-tv and music counts that include `fixture-soundtrack-film`, and the card's meta contains `film & tv` then `music`. e2e `'chips filter the wall by interest'`: read `dataset.interests`; every shown card's list includes `music`; then `film & tv` also shows `fixture-soundtrack-film`; "everything" count equals the number of cards. +- [x] **Step 2:** `bun test test/site/build.test.ts` → FAIL. +- [x] **Step 3: Implement** as in Interfaces; `toEntries(personal, interests)` derives `also` from the `interests` names. Posts: `interests: [interest]`, `also: []`. Live cards: `data-interests={interest}` when set. +- [x] **Step 4:** `bun test` PASS; `bun run typecheck` clean. +- [x] **Step 5:** Commit `feat(site): filter the wall by every interest an item has`. ### Task 3: Credit line on comics and songs; a single-cover comic shows the whole cover (mockup H) diff --git a/e2e/helpers.ts b/e2e/helpers.ts index d87e9af..6241f62 100644 --- a/e2e/helpers.ts +++ b/e2e/helpers.ts @@ -13,6 +13,7 @@ export const P = { draft: 'draft-unfinished-thing', }; export const I = { + soundtrackFilm: 'fixture-soundtrack-film', // [film-tv, music], spotify media url song: 'example-song', // youtube link, no ai (a "share") byHand: 'own-drawing', unknown: 'fixture-life', diff --git a/e2e/personal.spec.ts b/e2e/personal.spec.ts index adce592..533c239 100644 --- a/e2e/personal.spec.ts +++ b/e2e/personal.spec.ts @@ -11,14 +11,23 @@ test('chips filter the wall by interest', async ({ page }) => { await live(page); const cards = page.locator('[data-wall-card]'); const all = await cards.count(); + const shownIds = () => page.$$eval('[data-wall-card]', (cs) => cs.filter((c) => c.getClientRects().length > 0) + .map((c) => ({ id: (c as HTMLElement).dataset.id, interests: ((c as HTMLElement).dataset.interests ?? '').split(' ') }))); await page.getByRole('button', { name: /^music/ }).click(); - const shown = await page.$$eval('[data-wall-card]', (cs) => cs.filter((c) => c.getClientRects().length > 0).map((c) => (c as HTMLElement).dataset.interest)); - expect(shown.length).toBeGreaterThan(0); - expect(shown.length).toBeLessThan(all); - expect(new Set(shown)).toEqual(new Set(['music'])); + const music = await shownIds(); + expect(music.length).toBeGreaterThan(0); + expect(music.length).toBeLessThan(all); + for (const c of music) expect(c.interests).toContain('music'); + expect(music.map((c) => c.id)).toContain(I.soundtrackFilm); + // A two-interest card shows under both of its chips. + await page.getByRole('button', { name: /^film & tv/ }).click(); + expect((await shownIds()).map((c) => c.id)).toContain(I.soundtrackFilm); await page.getByRole('button', { name: /^everything/ }).click(); - const back = await page.$$eval('[data-wall-card]', (cs) => cs.filter((c) => c.getClientRects().length > 0).length); - expect(back).toBeGreaterThanOrEqual(shown.length + 1); + const back = await shownIds(); + expect(back.length).toBeGreaterThanOrEqual(music.length + 1); + // ...and is counted once under "everything". + const everything = await page.getByRole('button', { name: /^everything/ }).locator('sup').textContent(); + expect(Number(everything)).toBe(back.length); }); test('opening a card updates the URL; Esc closes it', async ({ page }) => { diff --git a/fixtures/content/items/fixture-soundtrack-film.md b/fixtures/content/items/fixture-soundtrack-film.md new file mode 100644 index 0000000..80e4ea5 --- /dev/null +++ b/fixtures/content/items/fixture-soundtrack-film.md @@ -0,0 +1,11 @@ +--- +title: Fixture Soundtrack Film +date: 2025-07-25 +kind: film +interest: [film-tv, music] +media: + - { file: fixture-pixel.png, alt: Fixture poster } + - { file: fixture-3.svg, alt: Fixture soundtrack cover } + - { url: 'https://open.spotify.com/album/fixture0000', alt: Fixture Soundtrack } +--- +A synthetic film that is also a soundtrack. diff --git a/src/site/components/personal/Card.astro b/src/site/components/personal/Card.astro index 9263160..51db19a 100644 --- a/src/site/components/personal/Card.astro +++ b/src/site/components/personal/Card.astro @@ -23,7 +23,7 @@ const ai = mode === 'wall' && entry.ai !== null ? entry.ai : undefined;