Task Summary
DatasetFileSelectorComponent (frontend/src/app/workspace/component/dataset-file-selector/dataset-file-selector.component.ts) has no *.spec.ts file. It is a Formly FieldType whose only method, onClickOpenFileSelectionModal(), opens an ng-zorro modal and writes the chosen path back into formControl when the modal closes with a value. It injects NzModalService, WorkflowActionService, and GuiConfigService.
What to do (step by step)
- Create the spec next to the component, with the Apache license header.
- Stub the three injected services. Only
NzModalService.create needs real behavior (return { afterClose: of("/path") }); the others can be empty vi.fn() stubs unless the method reads from them, in which case provide the minimal fields it uses.
- Because the component extends
FieldType, set component.field and component.formControl (a FormControl) before calling the method.
- Assert behavior, run
yarn test -- dataset-file-selector, then yarn lint.
Cover
should create.
onClickOpenFileSelectionModal() calls modalService.create once.
- When
afterClose emits a truthy path, formControl.setValue is called with it.
- When
afterClose emits a falsy value, formControl is unchanged.
Suggested providers / mocks
import { of } from "rxjs";
import { FormControl } from "@angular/forms";
import { NzModalService } from "ng-zorro-antd/modal";
import { WorkflowActionService } from "src/app/workspace/service/workflow-graph/model/workflow-action.service";
import { GuiConfigService } from "src/app/common/service/gui-config.service";
const modalServiceSpy = { create: vi.fn().mockReturnValue({ afterClose: of("/path") }) };
providers: [
{ provide: NzModalService, useValue: modalServiceSpy },
{ provide: WorkflowActionService, useValue: {} },
{ provide: GuiConfigService, useValue: {} },
]
This mirrors DatasetVersionSelectorComponent. Read the method body to confirm which
service fields it actually reads and keep the stubs minimal.
Task Type
Task Summary
DatasetFileSelectorComponent(frontend/src/app/workspace/component/dataset-file-selector/dataset-file-selector.component.ts) has no*.spec.tsfile. It is a FormlyFieldTypewhose only method,onClickOpenFileSelectionModal(), opens an ng-zorro modal and writes the chosen path back intoformControlwhen the modal closes with a value. It injectsNzModalService,WorkflowActionService, andGuiConfigService.What to do (step by step)
NzModalService.createneeds real behavior (return{ afterClose: of("/path") }); the others can be emptyvi.fn()stubs unless the method reads from them, in which case provide the minimal fields it uses.FieldType, setcomponent.fieldandcomponent.formControl(aFormControl) before calling the method.yarn test -- dataset-file-selector, thenyarn lint.Cover
should create.onClickOpenFileSelectionModal()callsmodalService.createonce.afterCloseemits a truthy path,formControl.setValueis called with it.afterCloseemits a falsy value,formControlis unchanged.Suggested providers / mocks
Task Type