Files
git.stella-ops.org/src/Web/StellaOps.Web/src/tests/unknowns/unknowns-route-handoffs.spec.ts

139 lines
4.9 KiB
TypeScript

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute, provideRouter } from '@angular/router';
import { of } from 'rxjs';
import { UnknownsClient } from '../../app/core/api/unknowns.client';
import { DeterminizationReviewComponent } from '../../app/features/unknowns-tracking/determinization-review.component';
import { GreyQueueDashboardComponent } from '../../app/features/unknowns-tracking/grey-queue-dashboard.component';
describe('unknowns route handoffs', () => {
it('keeps grey queue review links inside canonical security unknowns routes', async () => {
const unknownsClient = {
getPolicyUnknownsSummary: jasmine.createSpy('getPolicyUnknownsSummary').and.returnValue(
of({ hot: 1, warm: 0, cold: 0, resolved: 0, total: 1 }),
),
listPolicyUnknowns: jasmine.createSpy('listPolicyUnknowns').and.returnValue(
of({
items: [
{
id: 'unknown-grey-1',
packageId: 'openssl',
packageVersion: '3.0.14',
band: 'hot',
score: 94,
uncertaintyFactor: 0.2,
exploitPressure: 0.5,
firstSeenAt: '2026-03-08T07:00:00Z',
lastEvaluatedAt: '2026-03-08T07:30:00Z',
reasonCode: 'policy.unknown',
reasonCodeShort: 'Unknown',
observationState: 'ManualReviewRequired',
conflictInfo: {
hasConflict: true,
severity: 0.71,
suggestedPath: 'Manual review',
conflicts: [
{
signal1: 'vex:a',
signal2: 'vex:b',
type: 'issuer-conflict',
description: 'Issuer disagreement requires review.',
severity: 0.71,
},
],
},
},
],
totalCount: 1,
}),
),
};
await TestBed.configureTestingModule({
imports: [GreyQueueDashboardComponent],
providers: [
provideRouter([]),
{ provide: UnknownsClient, useValue: unknownsClient as unknown as UnknownsClient },
],
}).compileComponents();
const fixture = TestBed.createComponent(GreyQueueDashboardComponent);
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const links = Array.from(fixture.nativeElement.querySelectorAll('a')) as HTMLAnchorElement[];
const hrefs = links.map((link) => link.getAttribute('href'));
expect(hrefs).toContain('/security/unknowns');
expect(hrefs).toContain('/security/unknowns/unknown-grey-1/determinization');
});
it('keeps determinization breadcrumbs and return links inside canonical security unknowns routes', async () => {
const unknownsClient = {
getPolicyUnknownDetail: jasmine.createSpy('getPolicyUnknownDetail').and.returnValue(
of({
unknown: {
id: 'unknown-grey-1',
packageId: 'openssl',
packageVersion: '3.0.14',
band: 'hot',
score: 94,
uncertaintyFactor: 0.2,
exploitPressure: 0.5,
firstSeenAt: '2026-03-08T07:00:00Z',
lastEvaluatedAt: '2026-03-08T07:30:00Z',
reasonCode: 'policy.unknown',
reasonCodeShort: 'Unknown',
observationState: 'ManualReviewRequired',
conflictInfo: {
hasConflict: true,
severity: 0.71,
suggestedPath: 'Manual review',
conflicts: [
{
signal1: 'vex:a',
signal2: 'vex:b',
type: 'issuer-conflict',
description: 'Issuer disagreement requires review.',
severity: 0.71,
},
],
},
},
}),
),
triageUnknown: jasmine.createSpy('triageUnknown'),
};
await TestBed.configureTestingModule({
imports: [DeterminizationReviewComponent],
providers: [
provideRouter([]),
{ provide: UnknownsClient, useValue: unknownsClient as unknown as UnknownsClient },
{
provide: ActivatedRoute,
useValue: {
snapshot: {
paramMap: {
get: (key: string) => (key === 'unknownId' ? 'unknown-grey-1' : null),
},
},
},
},
],
}).compileComponents();
const fixture = TestBed.createComponent(DeterminizationReviewComponent);
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
const links = Array.from(fixture.nativeElement.querySelectorAll('a')) as HTMLAnchorElement[];
const hrefs = links.map((link) => link.getAttribute('href'));
expect(hrefs).toContain('/security/unknowns');
expect(hrefs).toContain('/security/unknowns/unknown-grey-1');
});
});