From 9150c0e0b70eb8d20a99f08a27bc539a59ede419 Mon Sep 17 00:00:00 2001 From: Neilk1021 Date: Mon, 8 Jun 2026 17:59:01 -0700 Subject: [PATCH 1/3] test: add unit tests for RowModalComponent (#5469) --- .../result-panel-modal.component.spec.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts diff --git a/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts new file mode 100644 index 00000000000..5d3fa682956 --- /dev/null +++ b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts @@ -0,0 +1,69 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { RowModalComponent } from "./result-panel-modal.component"; +import { PanelResizeService } from "../../service/workflow-result/panel-resize/panel-resize.service"; +import { WorkflowResultService } from "../../service/workflow-result/workflow-result.service"; +import { NZ_MODAL_DATA, NzModalRef } from "ng-zorro-antd/modal"; +import { of } from "rxjs"; +import { describe, beforeEach, it, expect, vi } from "vitest"; + +describe("RowModalComponent", () => { + let component: RowModalComponent; + let fixture: ComponentFixture; + + const mockTupleResult = { tuple: { id: "123", value: "test_data" } }; + const workflowResultServiceSpy = { + getPaginatedResultService: vi.fn().mockReturnValue({ + selectTuple: vi.fn().mockReturnValue(of(mockTupleResult)) + }) + }; + + const resizeServiceSpy = { + pageSize: 10 + }; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [RowModalComponent], + providers: [ + { provide: NZ_MODAL_DATA, useValue: { operatorId: "op-1", rowIndex: 3 } }, + { provide: NzModalRef, useValue: { getConfig: () => ({}), close: vi.fn() } }, + { provide: WorkflowResultService, useValue: workflowResultServiceSpy }, + { provide: PanelResizeService, useValue: resizeServiceSpy }, + ] + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(RowModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it("should create", () => { + expect(component).toBeTruthy(); + }); + + it("should populate row data on ngOnChanges", () => { + component.ngOnChanges(); + expect(component.currentDisplayRowData).toEqual(mockTupleResult.tuple); + }); +}); From 89f54a9de69ce37aa036ebf6c0a4b0646ae79baf Mon Sep 17 00:00:00 2001 From: Neilk1021 Date: Mon, 8 Jun 2026 22:59:07 -0700 Subject: [PATCH 2/3] style: fix linting and prettier formatting --- .../result-panel/result-panel-modal.component.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts index 5d3fa682956..8c1591619d0 100644 --- a/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts +++ b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts @@ -32,12 +32,12 @@ describe("RowModalComponent", () => { const mockTupleResult = { tuple: { id: "123", value: "test_data" } }; const workflowResultServiceSpy = { getPaginatedResultService: vi.fn().mockReturnValue({ - selectTuple: vi.fn().mockReturnValue(of(mockTupleResult)) - }) + selectTuple: vi.fn().mockReturnValue(of(mockTupleResult)), + }), }; const resizeServiceSpy = { - pageSize: 10 + pageSize: 10, }; beforeEach(async () => { @@ -48,7 +48,7 @@ describe("RowModalComponent", () => { { provide: NzModalRef, useValue: { getConfig: () => ({}), close: vi.fn() } }, { provide: WorkflowResultService, useValue: workflowResultServiceSpy }, { provide: PanelResizeService, useValue: resizeServiceSpy }, - ] + ], }).compileComponents(); }); From 133e091a8f168ad5ac32a0eb36e93e48854e3da2 Mon Sep 17 00:00:00 2001 From: Neilk1021 Date: Mon, 8 Jun 2026 23:31:49 -0700 Subject: [PATCH 3/3] style: remove UTF-8 BOM and redundant vitest imports --- .../result-panel/result-panel-modal.component.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts index 8c1591619d0..8d7e1cc8f99 100644 --- a/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts +++ b/frontend/src/app/workspace/component/result-panel/result-panel-modal.component.spec.ts @@ -1,4 +1,4 @@ -/** +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -23,7 +23,6 @@ import { PanelResizeService } from "../../service/workflow-result/panel-resize/p import { WorkflowResultService } from "../../service/workflow-result/workflow-result.service"; import { NZ_MODAL_DATA, NzModalRef } from "ng-zorro-antd/modal"; import { of } from "rxjs"; -import { describe, beforeEach, it, expect, vi } from "vitest"; describe("RowModalComponent", () => { let component: RowModalComponent;