Skip to content

Commit

Permalink
fix ui test failure (#20441)
Browse files Browse the repository at this point in the history
Signed-off-by: xuelichao <[email protected]>
  • Loading branch information
xuelichao authored May 20, 2024
1 parent 840d408 commit be839e6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/portal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "harbor",
"version": "2.10.0",
"version": "2.11.0",
"description": "Harbor UI with Clarity",
"angular-cli": {},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import { AccessoryType } from '../artifact';
describe('ResultSbomComponent (inline template)', () => {
let component: ResultSbomComponent;
let fixture: ComponentFixture<ResultSbomComponent>;
let mockData: SBOMOverview = {
scan_status: SBOM_SCAN_STATUS.SUCCESS,
end_time: new Date().toUTCString(),
};
const mockedSbomDigest =
'sha256:052240e8190b7057439d2bee1dffb9b37c8800e5c1af349f667635ae1debf8f3';
const mockScanner = {
name: 'Trivy',
vendor: 'vm',
version: 'v1.2',
};
let mockData: SBOMOverview = {
scan_status: SBOM_SCAN_STATUS.SUCCESS,
end_time: new Date().toUTCString(),
};
const mockedSbomOverview = {
report_id: '12345',
scan_status: 'Error',
Expand All @@ -34,14 +34,20 @@ describe('ResultSbomComponent (inline template)', () => {
report_id: '12346',
scan_status: 'Pending',
};
const mockedAccessories = [
{
type: AccessoryType.SBOM,
digest: mockedSbomDigest,
},
];
const FakedScanService = {
scanArtifact: () => of({}),
stopScanArtifact: () => of({}),
};
const FakedArtifactService = {
getArtifact: () =>
of({
accessories: null,
accessories: mockedAccessories,
addition_links: {
build_history: {
absolute: false,
Expand Down Expand Up @@ -83,6 +89,7 @@ describe('ResultSbomComponent (inline template)', () => {
'sha256:8cca43ea666e0e7990c2433e3b185313e6ba303cc7a3124bb767823c79fb74a6',
scan_status: 'Success',
start_time: '2024-04-02T01:50:57.176Z',
scanner: mockScanner,
},
size: 3957,
tags: null,
Expand Down Expand Up @@ -119,6 +126,7 @@ describe('ResultSbomComponent (inline template)', () => {
component.artifactDigest = mockedSbomDigest;
component.sbomDigest = mockedSbomDigest;
component.sbomOverview = mockData;
component.accessories = mockedAccessories;
fixture.detectChanges();
});

Expand Down Expand Up @@ -166,19 +174,18 @@ describe('ResultSbomComponent (inline template)', () => {

it('should show summary bar chart if status is COMPLETED', () => {
component.sbomOverview.scan_status = SBOM_SCAN_STATUS.SUCCESS;
component.artifactDigest = mockedSbomDigest;
component.sbomDigest = mockedSbomDigest;
component.accessories = [
{
type: AccessoryType.SBOM,
digest: mockedSbomDigest,
},
];
fixture.detectChanges();

component.accessories = mockedAccessories;
fixture.whenStable().then(() => {
fixture.detectChanges();
let el: HTMLElement = fixture.nativeElement.querySelector('a');
const el: HTMLElement =
fixture.nativeElement.querySelector('.tip-block');
expect(el).not.toBeNull();
const textContent = el.textContent;
expect(component.sbomOverview.scan_status).toBe(
SBOM_SCAN_STATUS.SUCCESS
);
expect(textContent).toBe('SBOM Detail');
});
});
it('Test ResultSbomComponent getScanner', () => {
Expand Down

0 comments on commit be839e6

Please sign in to comment.