Skip to content

Add unit tests for RowModalComponent (result-panel-modal) #5469

@Ma77Ball

Description

@Ma77Ball

Task Summary

RowModalComponent (frontend/src/app/workspace/component/result-panel/result-panel-modal.component.ts) has no *.spec.ts file. It is a ~70-line modal with a single lifecycle hook (ngOnChanges). It depends on NzModalRef, WorkflowResultService, and PanelResizeService, all of which are easy to stub.

What to do (step by step)

  1. Create the spec next to the component, with the Apache license header.
  2. Provide stubs for the three injected dependencies (see below).
  3. Assert creation, and that ngOnChanges() produces the expected state (inspect the method body to see which field it sets from workflowResultService / modal).
  4. Run yarn test -- result-panel-modal, then yarn lint.

Cover

  • should create.
  • ngOnChanges() populates the row data the modal displays. Read the method to see which service call it makes (it uses the modal's numeric config and WorkflowResultService), stub that call, then assert the resulting component field.

Suggested providers / mocks

const workflowResultServiceSpy = { /* add the method ngOnChanges calls, as vi.fn() */ };
const resizeServiceSpy = { /* add any method used, as vi.fn() */ };
providers: [
  { provide: NzModalRef, useValue: { getConfig: () => ({}), close: vi.fn() } },
  { provide: WorkflowResultService, useValue: workflowResultServiceSpy },
  { provide: PanelResizeService, useValue: resizeServiceSpy },
]

Open the component first and match the stub methods to exactly what ngOnChanges and the constructor touch, so the stubs stay minimal.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions