You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor tests for robustness and address PR feedback
This commit implements significant refactoring in
`src/utils/__tests__/model-name-convert.test.mjs` to ensure robust
test isolation when dealing with modified mock data. It also addresses
the latest round of feedback from PR #864.
Key changes:
- **Test Isolation in `model-name-convert.test.mjs`:**
- I refactored test cases within `describe('modelNameToDesc', ...)`,
`describe('isInApiModeGroup', ...)`, and the
`describe('partial match scenarios', ...)` (under
`describe('isUsingModelName', ...)`) that require modified global
mocks (`actualMockModels`, `actualMockModelGroups`).
- These tests now use `jest.isolateModulesAsync()` in conjunction with
`jest.doMock()` and dynamic `await import()` to provide test-specific
mock states. This prevents mock state leakage between tests and
improves test reliability.
- I addressed previous issues with `async` test functions and syntax
errors inadvertently introduced.
- **Addressed Specific PR Feedback (coderabbit.ai & Copilot):**
- `.eslintrc.json`: I updated the file override pattern from
`"*.test.mjs"` to `"**/*.test.mjs"` to ensure ESLint's Jest
environment applies to all test files, regardless of depth.
- `src/utils/ends-with-question-mark.mjs`: I clarified the comment for
the reversed/inverted question mark (`⸮`).
- `src/utils/__tests__/model-name-convert.test.mjs`:
- I replaced `delete actualMockModelGroups.testGroup` with an
assignment to `undefined` (this was mostly a verification as
previous changes had addressed similar issues, but the specific
instance was re-checked and the refactor to isolated mocks
further mitigates direct global mock modification).
- I clarified the comment for the `toHaveLength` assertion in
`getApiModesFromConfig` tests to detail the count logic.
- I added more explicit test cases and explanatory comments for
the partial match logic in `isUsingModelName` tests.
All linting checks now pass (`npm run lint`).
All 157 unit tests in 9 suites pass (`npm test`).
Code coverage for `src/utils/model-name-convert.mjs` is now
excellent (Statements: 100%, Branches: 98.63%, Functions: 100%, Lines: 100%).
0 commit comments