Failing tests written against Dev-A's published org SW message contract (org_list_configs / org_switch / org_list_items / org_get_item / org_list_collections), plus compile-clean stubs. vitest: 6 fail / 3 pass — the 3 passes are A-independent (currentContext default + org reflect, personal "+ new" kept); the 6 fails are exactly the org behaviors HELD until Dev-A merges to main. Integration (flip-on at Dev-A merge): - org-context messageForList/messageForGet org branches (org_list_items/org_get_item) - org-switcher org_list_configs fetch + org_switch dispatch + list reload + offline banner - item-list org initial-load-on-render (org_list_items) + hide "+ new" in org context - collection facet populate from org_list_collections + click-to-filter Scaffold contents: - shared/org-context.ts (+__tests__): currentContext complete; messageFor* personal-only (HOLD) - shared/popup-state.ts: optional orgContext / orgOffline fields (non-breaking; A-typed orgConfigs/orgCollections join at integration) - popup/components/org-switcher.ts (+__tests__): select shell only (HOLD switch + Task 5 banner) - popup/components/__tests__/item-list.test.ts: org load + read-only (+ new hidden) assertions - vault/vault-sidebar.ts renderCollectionFacet (+__tests__): empty container (HOLD) Read-only this plan: write affordances stay hidden (Dev-C adds them). No org-message-type references in src — branch stays compile-clean; build:all type-check is the integration gate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W3b8DA2mXmLWkd4zDbHXHg
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
// renderCollectionFacet reads getState().orgCollections (shared/state). vault-sidebar
|
|
// pulls in vault-context/vault-status/glyphs transitively; none have import-time
|
|
// side effects, so importing it under happy-dom is safe.
|
|
vi.mock('../../shared/state', () => ({
|
|
getState: vi.fn(() => ({ orgContext: 'personal', orgCollections: [] })),
|
|
setState: vi.fn(),
|
|
sendMessage: vi.fn(),
|
|
navigate: vi.fn(),
|
|
escapeHtml: (s: string) => s,
|
|
popOutToTab: vi.fn(),
|
|
isInTab: () => false,
|
|
openVaultTab: vi.fn(),
|
|
}));
|
|
|
|
import { renderCollectionFacet } from '../vault-sidebar';
|
|
import { getState } from '../../shared/state';
|
|
|
|
const mockGetState = getState as ReturnType<typeof vi.fn>;
|
|
|
|
describe('vault collection facet (org context)', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
document.body.innerHTML = '<div id="facet"></div>';
|
|
});
|
|
|
|
// Task 4 — a collection nav parallel to the type-category nav, populated from
|
|
// org_list_collections, shown only in org context.
|
|
it('renders a collection facet from org_list_collections', () => {
|
|
mockGetState.mockReturnValue({
|
|
orgContext: 'org-1',
|
|
orgCollections: [{ slug: 'prod-infra', display_name: 'Production Infra' }],
|
|
});
|
|
const el = document.getElementById('facet')!;
|
|
|
|
renderCollectionFacet(el);
|
|
|
|
expect(el.textContent).toContain('Production Infra');
|
|
});
|
|
});
|