[No QA] Remove unsafe type assertions from policy, workflow, navigation, and utility tests - #97317
[No QA] Remove unsafe type assertions from policy, workflow, navigation, and utility tests#97317KJ21-ENG wants to merge 4 commits into
Conversation
|
@ikevin127 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
|
| const mockTranslate: LocalizedTranslate = (path, ...parameters) => { | ||
| return parameters.length > 0 ? path : path; | ||
| }; |
There was a problem hiding this comment.
🟡 tests/unit/FileUtilsTest.ts:504 and tests/unit/hooks/useAutoCreateSubmitWorkspace.test.ts:34: the mockTranslate body is a no-op ternary that returns the same thing on both branches.
This reads like an unfinished thought (someone meant to interpolate parameters into the string, or it should just be path). A reviewer can't tell if it's intentional. Since parameters is a rest arg it doesn't trigger unused-var lint, so just:
const mockTranslate: LocalizedTranslate = (path) => path;Why it matters: dead conditional logic in a shared mock is exactly the kind of thing that gets copied into the next cleanup file (it already appears in two of the ten here). Kill it before it spreads ❌
ikevin127
left a comment
There was a problem hiding this comment.
🟢 LGTM - Only got 1 non-blocking comment ☝️
Explanation of Change
This test-only cleanup removes 137 redundant
@typescript-eslint/no-unsafe-type-assertionfindings from the ten authorized test files. It replaces them with production-derived types, typed mocks, and key-specific Onyx fixtures while preserving the existing test scenarios and runtime behavior. Intentional malformed custom-unit error fixtures retain their exact backend payload through a localized typed helper.Fixed Issues
$ #94739
PROPOSAL: #94739 (comment)
Count change
Current baseline source:
tests/actions/WorkflowTest.ts: 13 findingstests/navigation/getStateFromPathTests.ts: 14 findingstests/perf-test/useFilterFormValues.perf-test.tsx: 14 findingstests/unit/FileUtilsTest.ts: 13 findingstests/unit/PolicyUtilsTest.ts: 13 findingstests/unit/SearchEditMultipleUtilsTest.ts: 14 findingstests/unit/hooks/useAutoCreateSubmitWorkspace.test.ts: 13 findingstests/unit/navigateToWorkspacesPageTest.ts: 14 findingstests/unit/selectors/PolicyTest.ts: 15 findingstests/unit/usePolicyIndicatorChecksTest.ts: 14 findingsBefore:
@typescript-eslint/no-unsafe-type-assertionfindings across the ten target filesAfter:
@typescript-eslint/no-unsafe-type-assertionfindings in every target fileNet reduction:
TSV evidence:
config/eslint/eslint.seatbelt.tsvat base2c95456c78d65e54730dcde1f758292472ab59faprovides the baseline counts above. Final cleanup-count verification at exact headea332a6781c6813b874687ac0446634857edbb3ereported zero remaining findings for every target, and the tracked TSV was restored unchanged.Tests
useFilterFormValues.perf-test.tsxsuite passed: 1 suite and 11 tests, including Reassure verification.30431382868passed typecheck, lint, format, React Compiler, and Jest for exact headea332a6781c6813b874687ac0446634857edbb3e.Offline tests
Not applicable: this is a test-only type-safety cleanup and changes no product runtime or network behavior.
QA Steps
No QA required for this test-only cleanup; the title starts with
[No QA]and no staging or production manual QA was performed.PR Author Checklist
Checklist note: every item below is checked to record that it was considered. Platform, staging or production, offline, screenshot or video, high-traffic, and product-component testing are N/A for this test-only cleanup; no manual platform or product testing is claimed. The automated evidence is listed in
### Tests.### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
N/A — no UI changes; no screenshots or videos were produced.
Changed files (10)
tests/actions/WorkflowTest.tstests/navigation/getStateFromPathTests.tstests/perf-test/useFilterFormValues.perf-test.tsxtests/unit/FileUtilsTest.tstests/unit/PolicyUtilsTest.tstests/unit/SearchEditMultipleUtilsTest.tstests/unit/hooks/useAutoCreateSubmitWorkspace.test.tstests/unit/navigateToWorkspacesPageTest.tstests/unit/selectors/PolicyTest.tstests/unit/usePolicyIndicatorChecksTest.ts