+ describe("content when editing policy with type", () => {
+ const instanceJson = '{"qosObjectives": {"priorityLevel": 3100}}';
+ beforeEach(async () => {
+ const policyData = {
+ createSchema: typedSchema,
+ instanceId: "instanceId",
+ instanceJson: instanceJson,
+ name: "name",
+ ric: "ric1",
+ };
+ TestBed.overrideProvider(MAT_DIALOG_DATA, { useValue: policyData }); // Should be provided with a policy
+ ({ fixture, component, loader } = compileAndGetComponents(
+ fixture,
+ component,
+ loader
+ ));
+ });
+
+ it("should contain oran logo and instance info", async () => {
+ let ele = fixture.debugElement.nativeElement.querySelector("img");
+ expect(ele.src).toContain("assets/oran-logo.png");
+
+ ele = fixture.debugElement.nativeElement.querySelector("text");
+ expect(ele.childNodes[0].childNodes[0]).toBeFalsy(); // No create title
+
+ ele = fixture.debugElement.nativeElement.querySelector("#instanceInfo");
+ expect(ele).toBeTruthy();
+ expect(ele.innerText).toEqual("[ric1] Instance ID: instanceId");
+ });
+
+ it("should not contain ric select", async () => {
+ const ricSelector = fixture.debugElement.query(By.directive(RicSelectorComponent));
+ expect(ricSelector).toBeFalsy();
+ });
+
+ it("should contain typed json editor with instance JSON, schema and dark mode true", async () => {
+ const typedPolicyEditor: TypedPolicyEditorComponent = fixture.debugElement.query(By.directive(TypedPolicyEditorComponent)).componentInstance;
+ expect(typedPolicyEditor).toBeTruthy();
+ expect(unescapeQuotes(typedPolicyEditor.jsonObject)).toEqual(instanceJson);
+ expect(typedPolicyEditor.jsonSchemaObject).toEqual(typedSchema);
+ expect(typedPolicyEditor.darkMode).toBeTruthy();
+ });
+
+ it("should contain enabled Close and Submit buttons when all inputs are valid", async () => {
+ let closeButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#closeButton" })
+ );
+ expect(await closeButton.isDisabled()).toBeFalsy();
+ expect(await closeButton.getText()).toEqual("Close");
+
+ let submitButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#submitButton" })
+ );
+ expect(await submitButton.isDisabled()).toBeFalsy();
+ expect(await submitButton.getText()).toEqual("Submit");
+ });