fix(slice5): validate raw metadata input + prune stale bulk selections
Code-review follow-ups: - Validate the raw submitted value before apply_values coerces it, in both the single-edit and bulk endpoints — a scalar set onto a tags field now rejects (422 / rejected) instead of silently char-splitting into a list. - Catalog prunes bulk selections to the currently-visible (filtered) entries after each list fetch, so the bulk bar can't act on rows the user has filtered out of view. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -90,6 +90,30 @@ describe('Catalog faceted pane', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('drops a selection when a filter change hides the row', async () => {
|
||||
getCollection.mockResolvedValue({
|
||||
fields: { priority: { type: 'enum', values: ['P0', 'P1'] } },
|
||||
viewer: { can_contribute: true }, entry_noun: 'RFC',
|
||||
})
|
||||
// Content-driven: unfiltered → row "a"; once the P0 facet is selected the
|
||||
// server response omits "a" (drives the prune). Robust to extra mount-time
|
||||
// fetches the collection effect triggers.
|
||||
listRFCs.mockImplementation((p, c, opts) => Promise.resolve({
|
||||
items: opts?.selections?.priority?.includes('P0')
|
||||
? [{ slug: 'b', title: 'B', state: 'active', tags: [], starred_by_me: false }]
|
||||
: [{ slug: 'a', title: 'A', state: 'active', tags: [], starred_by_me: false }],
|
||||
facets: { priority: { P0: 1 }, state: { active: 1 } },
|
||||
}))
|
||||
const { container } = renderCatalog()
|
||||
fireEvent.click(await screen.findByLabelText(/select A/i))
|
||||
expect(await screen.findByText(/1 selected/i)).toBeInTheDocument()
|
||||
// Toggle the P0 facet checkbox → re-fetch returns a list without "a".
|
||||
fireEvent.click(container.querySelector('.facet-group input[type="checkbox"]'))
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText(/1 selected/i)).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
it('does not offer row selection for a non-contributor', async () => {
|
||||
getCollection.mockResolvedValue({
|
||||
fields: { priority: { type: 'enum', values: ['P0'] } },
|
||||
|
||||
Reference in New Issue
Block a user