feat(ext): org collection facet + collection filter in the vault sidebar
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W3b8DA2mXmLWkd4zDbHXHg
This commit is contained in:
@@ -15,9 +15,10 @@ vi.mock('../../shared/state', () => ({
|
||||
}));
|
||||
|
||||
import { renderCollectionFacet } from '../vault-sidebar';
|
||||
import { getState } from '../../shared/state';
|
||||
import { getState, setState } from '../../shared/state';
|
||||
|
||||
const mockGetState = getState as ReturnType<typeof vi.fn>;
|
||||
const mockSetState = setState as ReturnType<typeof vi.fn>;
|
||||
|
||||
describe('vault collection facet (org context)', () => {
|
||||
beforeEach(() => {
|
||||
@@ -38,4 +39,31 @@ describe('vault collection facet (org context)', () => {
|
||||
|
||||
expect(el.textContent).toContain('Production Infra');
|
||||
});
|
||||
|
||||
it('clicking a collection row calls setState with the collection filter', () => {
|
||||
mockGetState.mockReturnValue({
|
||||
orgContext: 'org-1',
|
||||
orgCollections: [{ slug: 'prod-infra', display_name: 'Production Infra' }],
|
||||
collectionFilter: undefined,
|
||||
});
|
||||
const el = document.getElementById('facet')!;
|
||||
renderCollectionFacet(el);
|
||||
|
||||
const btn = el.querySelector<HTMLButtonElement>('[data-slug="prod-infra"]')!;
|
||||
expect(btn).not.toBeNull();
|
||||
btn.click();
|
||||
|
||||
expect(mockSetState).toHaveBeenCalledWith({ collectionFilter: 'prod-infra' });
|
||||
});
|
||||
|
||||
it('renders nothing in personal context', () => {
|
||||
mockGetState.mockReturnValue({
|
||||
orgContext: 'personal',
|
||||
orgCollections: [],
|
||||
});
|
||||
const el = document.getElementById('facet')!;
|
||||
renderCollectionFacet(el);
|
||||
|
||||
expect(el.innerHTML).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user