Browse the Directory by category, then subcategory, as Apple does (#118)

The Directory had one row of chips holding whatever each feed's category was, a category
(Technology) or a subcategory (Tech News, Video Games) side by side: a podcast's own
<itunes:category> is stored as its subcategory, and Jev's answers (#117) are often
subcategories too, so after the first forced scan the row held 22 chips. /api/directory now
gives each feed's Apple category and subcategory, worked out from Apple's list, and the
page shows the categories, then a picked one's subcategories on a line of their own. A
category that is not Apple's, one an admin typed, stands as a category of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-04 22:33:26 +00:00
parent 3e384f34f9
commit 02a46bb500
6 changed files with 58 additions and 11 deletions

View File

@@ -1177,7 +1177,16 @@ test('an admin can give a blog its Directory category', async ({ page }) => {
const listed = async id => (await page.evaluate(() => api('/api/directory'))).find(p => p.id === id);
await patch('picture-blog', 'Visual Arts');
expect(await listed('picture-blog')).toMatchObject({ podcast: false, category: 'Visual Arts' });
// Apple's subcategory, under its category, as the Directory browses them (#118).
expect(await listed('picture-blog')).toMatchObject({ podcast: false, category: 'Arts', subcategory: 'Visual Arts' });
// A subcategory's chips show once its category is picked, as Apple's directory does.
const chip = (row, name) => page.locator(`#dirbar .${row} button`, { hasText: new RegExp(`^${name}$`) });
await page.locator('#feedlist .place', { hasText: 'Directory' }).click();
await expect(chip('subs', 'Visual Arts')).toHaveCount(0);
await chip('chips', 'Arts').click();
await chip('subs', 'Visual Arts').click();
await expect(chip('subs', 'Visual Arts')).toHaveAttribute('aria-pressed', 'true');
await expect(page.locator('#popular .tile')).toHaveCount(1);
// A feed's own iTunes category wins over one given here.
await patch('test-show', 'Comedy');
expect((await listed('test-show')).category).toBe('Technology');