Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,24 @@ describe('AuditPreviewComponent', () => {
it('should create', () => {
expect(component).toBeTruthy();
});

it('should report no report for a chain audit without a successful reporting sub-event', () => {
fixture.componentRef.setInput('audit', {
type: 'TRACEABILITY_CHAIN_AUDIT',
events: [{ type: 'STP_PREPARE_TRACEABILITY_CHAIN_AUDIT', outcome: 'KO', outDetail: 'STP_PREPARE_TRACEABILITY_CHAIN_AUDIT.KO' }],
});
fixture.detectChanges();

expect(component.hasReport()).toBe(false);
});

it('should report a report for a chain audit with a successful reporting sub-event, even when the audit is KO', () => {
fixture.componentRef.setInput('audit', {
type: 'TRACEABILITY_CHAIN_AUDIT',
events: [{ type: 'TRACEABILITY_CHAIN_AUDIT_REPORTING', outcome: 'OK', outDetail: 'TRACEABILITY_CHAIN_AUDIT_REPORTING.OK' }],
});
Comment thread
Salimdev marked this conversation as resolved.
fixture.detectChanges();

expect(component.hasReport()).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ export class AuditPreviewComponent implements OnInit {

accessContractId: string;
hasReport: Signal<boolean> = computed(() => {
if (this.audit().type === 'EVIDENCE_AUDIT') {
const audit = this.audit();
if (audit.type === 'EVIDENCE_AUDIT') {
// Evidence audit may not have a report if "data" has "No report generated" in it.
return !this.audit().events.some((e) => /No report generated/i.test(e.data));
return !audit.events.some((e) => /No report generated/i.test(e.data));
}
if (audit.type === AuditOperation.TRACEABILITY_CHAIN_AUDIT) {
// Chain audit report only exists once the reporting sub-step has completed successfully.
return audit.events.some((e) => /REPORTING$/i.test(e.type) && e.outcome === 'OK');
}
return true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export class LogbookDownloadService extends SearchService<IEvent> {
// Evidence audit may not have a report if "data" has "No report generated" in it.
return !event.events.some((e) => /No report generated/i.test(e.data));
}
if (['TRACEABILITY_CHAIN_AUDIT'].includes(event.type)) {
// Chain audit report only exists once the reporting sub-step has completed successfully.
return event.events.some((e) => /REPORTING$/i.test(e.type) && e.outcome === 'OK');
}
return true;
}
}
Loading