test: align three tests with Michael's cluster order, optional app read and Data Hub donut props

This commit is contained in:
Binh 2026-10-12 11:57:01 +02:00
parent 1f26cf0af6
commit 0aac6fdb44
3 changed files with 9 additions and 4 deletions

View File

@ -91,7 +91,8 @@ describe('Work facet Context Cluster', () => {
const index = contextClusterIndex(syntheticContext());
const facet = selectWorkFacets(sheet, { ...options, contextClusters: index }).find(item => item.id === CONTEXT_CLUSTER_FACET_ID)!;
expect(facet.label).toBe('Context Cluster');
expect(facet.values.map(value => value.value)).toEqual(['credential-relay-exposure', 'kerberos-delegation-abuse']);
// Published heatmap positions govern the order (Michael, 2026-10-11).
expect(facet.values.map(value => value.value)).toEqual(['kerberos-delegation-abuse', 'credential-relay-exposure']);
const count = (id: string) => facet.values.find(value => value.value === id)!.count;
expect(count('credential-relay-exposure')).toBe(2);
expect(count('kerberos-delegation-abuse')).toBe(1);
@ -224,7 +225,7 @@ describe('Work facet Context Cluster in the filter bar', () => {
mockApp({});
await act(async () => { root.render(<SearchFilterBar/>); await new Promise(resolve => setTimeout(resolve, 0)); });
const select = () => host.querySelector<HTMLSelectElement>('select[aria-label="Context Cluster"]')!;
expect([...select().options].map(option => option.value)).toEqual(['', 'credential-relay-exposure', 'kerberos-delegation-abuse']);
expect([...select().options].map(option => option.value)).toEqual(['', 'kerberos-delegation-abuse', 'credential-relay-exposure']);
await act(async () => { select().value = 'credential-relay-exposure'; select().dispatchEvent(new Event('change', { bubbles: true })); });
expect(setFacetFilter).toHaveBeenLastCalledWith(CONTEXT_CLUSTER_FACET_ID, { values: ['credential-relay-exposure'] });
mockApp({ [CONTEXT_CLUSTER_FACET_ID]: { values: ['credential-relay-exposure'] } });

View File

@ -86,7 +86,7 @@ describe('Datahub centered reference rack layout', () => {
expect(componentStyles).not.toContain('@keyframes donut-accent-build');
expect(overview).toContain('datahub-reference-controls donut-metric-rack');
expect(overview).toContain('DonutMetricCard className="datahub-reference-knob" label="Results All" value={resultMetrics.all} percentage={resultMetrics.all !== null ? 100 : 0} tone="all"');
expect(overview).toContain('DonutMetricCard className="datahub-reference-knob" label="Results All" value={resultMetrics.all} percentage={resultMetrics.all !== null ? 100 : 0} percentageBasisLabel="Of all records" tone="all"');
expect(overview).toContain('DonutMetricCard className="datahub-reference-knob" label="Deviation"');
expect(overview).toContain('DonutMetricCard className="datahub-reference-knob" label="Passed"');
expect(overview).toContain('DonutMetricCard className="datahub-reference-knob" label="Not Applicable"');

View File

@ -10,7 +10,11 @@ import { clearStoredMitreMatrix, MITRE_MATRIX_CHANGED_EVENT, saveStoredMitreMatr
import { useFilteredRecords } from '../../src/features/search-filter/use-filtered-records';
import { makeSheet } from '../../src/importers/sheet-factory';
vi.mock('../../src/app/AppProvider', () => ({ useApp: vi.fn() }));
vi.mock('../../src/app/AppProvider', () => {
const useApp = vi.fn();
// The Context cluster index reads the app optionally; it sees the same mocked app.
return { useApp, useOptionalApp: () => useApp() };
});
vi.mock('../../src/features/search-filter/use-filtered-records', () => ({ useFilteredRecords: vi.fn() }));
vi.mock('../../src/features/search-filter/SearchFilterBar', () => ({ SearchFilterBar: () => null, SearchTextControl: () => null }));
vi.mock('../../src/features/view-bookmarks/ViewBookmarks', () => ({ ViewBookmarks: () => null }));