X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy%2Fpolicy-instance%2Fpolicy-instance.component.spec.ts;h=4a5004687a66e481cd96b3f37128ec044537abb1;hb=6ba703836025c9da612254888b9d5641a402e403;hp=f39592f3f2ca1702f5452e5ac43127e1dd1b4669;hpb=e92e4347fa7897f0b8a53f177857373129d203e5;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy/policy-instance/policy-instance.component.spec.ts b/webapp-frontend/src/app/policy/policy-instance/policy-instance.component.spec.ts index f39592f..4a50046 100644 --- a/webapp-frontend/src/app/policy/policy-instance/policy-instance.component.spec.ts +++ b/webapp-frontend/src/app/policy/policy-instance/policy-instance.component.spec.ts @@ -39,11 +39,11 @@ import { PolicyInstances, PolicyStatus, PolicyTypeSchema, -} from "@app/interfaces/policy.types"; -import { PolicyService } from "@app/services/policy/policy.service"; -import { ConfirmDialogService } from "@app/services/ui/confirm-dialog.service"; -import { NotificationService } from "@app/services/ui/notification.service"; -import { UiService } from "@app/services/ui/ui.service"; +} from "@interfaces/policy.types"; +import { PolicyService } from "@services/policy/policy.service"; +import { ConfirmDialogService } from "@services/ui/confirm-dialog.service"; +import { NotificationService } from "@services/ui/notification.service"; +import { UiService } from "@services/ui/ui.service"; import { ToastrModule } from "ngx-toastr"; import { Observable, of } from "rxjs"; import { PolicyInstanceDialogComponent } from "../policy-instance-dialog/policy-instance-dialog.component"; @@ -186,27 +186,24 @@ describe("PolicyInstanceComponent", () => { }); it("should contain number of instances heading and value, create and refresh buttons, and policies table", async () => { - const instancesHeading = hostFixture.debugElement.nativeElement.querySelector( - "div" - ); + const instancesHeading = + hostFixture.debugElement.nativeElement.querySelector("div"); expect(instancesHeading.innerText).toContain("Number of instances: 2"); const createButton: MatButtonHarness = await loader.getHarness( MatButtonHarness.with({ selector: "#createButton" }) ); expect(createButton).toBeTruthy(); - const createIcon = hostFixture.debugElement.nativeElement.querySelector( - "#createIcon" - ); + const createIcon = + hostFixture.debugElement.nativeElement.querySelector("#createIcon"); expect(createIcon.innerText).toContain("add_box"); const refreshButton: MatButtonHarness = await loader.getHarness( MatButtonHarness.with({ selector: "#refreshButton" }) ); expect(refreshButton).toBeTruthy(); - const refreshIcon = hostFixture.debugElement.nativeElement.querySelector( - "#refreshIcon" - ); + const refreshIcon = + hostFixture.debugElement.nativeElement.querySelector("#refreshIcon"); expect(refreshIcon.innerText).toContain("refresh"); const policiesTable = await loader.getHarness( @@ -309,7 +306,7 @@ describe("PolicyInstanceComponent", () => { const lastModifiedCell = (await firstRow.getCells())[3]; (await lastModifiedCell.host()).click(); - // Totally unnecessary call just to make the bloody framework count the number of calls to the spy correctly! + // Totally unnecessary call just to make the framework count the number of calls to the spy correctly! await policiesTable.getRows(); expect(componentUnderTest.modifyInstance).toHaveBeenCalledTimes(4); @@ -494,24 +491,22 @@ describe("PolicyInstanceComponent", () => { it("should not sort when click in filter inputs", async () => { spyOn(componentUnderTest, "stopSort").and.callThrough(); - const idFilterInputDiv = hostFixture.debugElement.nativeElement.querySelector( - "#idSortStop" - ); + const idFilterInputDiv = + hostFixture.debugElement.nativeElement.querySelector("#idSortStop"); idFilterInputDiv.click(); - const targetFilterInputDiv = hostFixture.debugElement.nativeElement.querySelector( - "#targetSortStop" - ); + const targetFilterInputDiv = + hostFixture.debugElement.nativeElement.querySelector("#targetSortStop"); targetFilterInputDiv.click(); - const ownerFilterInputDiv = hostFixture.debugElement.nativeElement.querySelector( - "#ownerSortStop" - ); + const ownerFilterInputDiv = + hostFixture.debugElement.nativeElement.querySelector("#ownerSortStop"); ownerFilterInputDiv.click(); - const lastModifiedFilterInputDiv = hostFixture.debugElement.nativeElement.querySelector( - "#lastModifiedSortStop" - ); + const lastModifiedFilterInputDiv = + hostFixture.debugElement.nativeElement.querySelector( + "#lastModifiedSortStop" + ); lastModifiedFilterInputDiv.click(); expect(componentUnderTest.stopSort).toHaveBeenCalledTimes(4); @@ -521,6 +516,38 @@ describe("PolicyInstanceComponent", () => { expect(eventSpy.stopPropagation).toHaveBeenCalled(); }); + describe("#truncate data", () => { + fit("should verify that data is correctly truncated when needed", async () => { + policyServiceSpy.getPolicyInstancesByType.and.returnValue( + of(policyInstances) + ); + policyServiceSpy.getPolicyInstance.and.callFake(function ( + policyId: string + ) { + return of(policyIdToInstanceMap[policyId]); + }); + policyServiceSpy.getPolicyStatus.and.callFake(function ( + policyId: string + ) { + return of(policyIdToStatusMap[policyId]); + }); + compileAndGetComponents(); + componentUnderTest.slice = 1; + componentUnderTest.ngOnInit(); + + const policiesTable = await loader.getHarness( + MatTableHarness.with({ selector: "#policiesTable" }) + ); + const policyRows = await policiesTable.getRows(); + expect(policyRows.length).toEqual(1); + policyRows[0].getCellTextByColumnName().then((values) => { + expect(expectedPolicy1Row).toEqual(jasmine.objectContaining(values)); + }); + + expect(componentUnderTest.truncated).toBeTruthy(); + }); + }); + describe("#sorting", () => { it("should verify sort functionality on the table", async () => { const sort = await loader.getHarness(MatSortHarness);