Ma77Ball opened a new issue, #5470:
URL: https://github.com/apache/texera/issues/5470

   ### Task Summary
   
   `DatasetVersionSelectorComponent`
   
(`frontend/src/app/workspace/component/dataset-version-selector/dataset-version-selector.component.ts`)
   has no `*.spec.ts` file. It is a Formly `FieldType` whose only method,
   `onClickOpenDatasetSelectionModal()`, opens an ng-zorro modal and, when the 
modal closes
   with a value, writes that value into `formControl`. Its single dependency is
   `NzModalService`, which is easy to stub.
   
   ### What to do (step by step)
   
   1. Create the spec next to the component, with the Apache license header.
   2. Stub `NzModalService.create` to return an object with an
      `afterClose` observable you control (use `rxjs` `of(...)`).
   3. Because the component extends `FieldType`, set `component.field` and
      `component.formControl` (a `FormControl`) before calling the method.
   4. Call `onClickOpenDatasetSelectionModal()` and assert behavior.
   5. Run `yarn test -- dataset-version-selector`, then `yarn lint`.
   
   ### Cover
   
   - `should create`.
   - `onClickOpenDatasetSelectionModal()` calls `modalService.create` once.
   - When `afterClose` emits a truthy path, `formControl.setValue` is called 
with that path.
   - When `afterClose` emits a falsy value, `formControl` is left unchanged.
   
   ### Suggested providers / mocks
   
   ```ts
   import { of } from "rxjs";
   import { FormControl } from "@angular/forms";
   import { NzModalService } from "ng-zorro-antd/modal";
   
   const modalServiceSpy = {
     create: vi.fn().mockReturnValue({ afterClose: of("/selected/path") }),
   };
   providers: [{ provide: NzModalService, useValue: modalServiceSpy }]
   // in the test, before calling the method:
   component.field = {} as any;
   (component as any).formControl = new FormControl("");
   ```
   
   > Sibling component `DatasetFileSelectorComponent` is nearly identical; the 
same test
   > shape applies (see its own draft).
   
   
   
   ### Task Type
   
   - [ ] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [x] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to