[No QA] Cleanup unsafe type assertions in tests - #97288
Open
KJ21-ENG wants to merge 1 commit into
Open
Conversation
KJ21-ENG
force-pushed
the
seatbelt/94739-tests-20260728-5
branch
from
July 31, 2026 09:26
294c75c to
599991e
Compare
KJ21-ENG
marked this pull request as ready for review
July 31, 2026 14:27
|
@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] |
Contributor
Reviewer Checklist
|
ikevin127
approved these changes
Aug 2, 2026
ikevin127
left a comment
Contributor
There was a problem hiding this comment.
🟢 LGTM
Notes (no change requested)
createMock<T>is the same pre-existing,PartialDeep<T>-checked shared helper vetted on #97284: wrong fields/types are still caught at each call site. Confirmed it is imported in every file that uses it, includingModifiedExpenseMessageTest.ts(pre-existing import at line 18, so the diff not showing the import is expected, not a compile break).LoadTestMiddlewareTest.ts:TestHelper.setupGlobalFetchMock()is a real typed helper returningMockFetch, and switching to nativeFormData.get()/has()(dropping the localformBodyToObjectandFetchMockCalltype) is cleaner and cast-free.handleReplaceFullscreenUnderRHP.test.ts: nicely done,[...] satisfies PartialState<...>['routes']instead ofas,ROUTES.WORKSPACE_INITIAL.getRoute('NEW')instead of'/workspaces/NEW' as Route, and thestackRouter.getRehydratedStateguard (if (partialState.stale !== false) throw) doubles as the union-narrowing that lets it return without a cast.LogTest.ts: the newisLogLine/isLogInfoParametersguards are test-local, but they validate deserialized JSON (a log packet) where no production guard exists, andLogInfoParametersis derived fromParameters<typeof Log.info>[2], not duplicated. They replace an unsafeJSON.parse(...) as LogLine[]with real runtime validation, so they earn their place.NetworkTest.tsx/usePendingConciergeResponse.test.ts:jest.SpiedFunction<typeof X>+jest.spyOnreplacejest.fn()+as jest.Mock, and the removed localLogInfoCalltype is now covered by the typed spy. Good ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
This test-only cleanup removes 60
@typescript-eslint/no-unsafe-type-assertionviolations from the ten requested test files while preserving their test behavior. No application UI, production logic, CSS, assets, messaging behavior, generic components, Storybook stories, or deeplink behavior changed.Fixed Issues
$ #94739
PROPOSAL: #94739 (comment)
Count change
Current baseline source:
config/eslint/eslint.seatbelt.tsvat exact rebuild basecb505a9c1064af2d0c910e6fa841305c5b640df5, SHA-25681ca0465651537862a00f0886d26cead5ffeaea388772ca565bb0f28737e7e30.@typescript-eslint/no-unsafe-type-assertion.Before:
tests/ui/SelectCountryStepTest.tsx: 6 violations.tests/unit/AddExistingExpenseSearchTest.ts: 6 violations.tests/unit/EmojiReactionsTest.ts: 6 violations.tests/unit/LoadTestMiddlewareTest.ts: 6 violations.tests/unit/LogTest.ts: 6 violations.tests/unit/ModifiedExpenseMessageTest.ts: 6 violations.tests/unit/Navigation/createRootStackNavigator/handleReplaceFullscreenUnderRHP.test.ts: 6 violations.tests/unit/NetworkTest.tsx: 6 violations.tests/unit/hooks/useConfirmationValidation.test.ts: 6 violations.tests/unit/hooks/usePendingConciergeResponse.test.ts: 6 violations.After:
tests/ui/SelectCountryStepTest.tsx: 0 violations.tests/unit/AddExistingExpenseSearchTest.ts: 0 violations.tests/unit/EmojiReactionsTest.ts: 0 violations.tests/unit/LoadTestMiddlewareTest.ts: 0 violations.tests/unit/LogTest.ts: 0 violations.tests/unit/ModifiedExpenseMessageTest.ts: 0 violations.tests/unit/Navigation/createRootStackNavigator/handleReplaceFullscreenUnderRHP.test.ts: 0 violations.tests/unit/NetworkTest.tsx: 0 violations.tests/unit/hooks/useConfirmationValidation.test.ts: 0 violations.tests/unit/hooks/usePendingConciergeResponse.test.ts: 0 violations.Net reduction:
TSV evidence:
config/eslint/eslint.seatbelt.tsv; its content matches the recorded exact-base digest above.Tests
git diff --checkpassed; generated TSV restoration and exact changed-path validation also passed.src/components/AddressSearch/index.tsx:420; no authorized-path diagnostic was reported.30619982299: typecheck, lint, format, React Compiler, and Jest.Manual JS-console verification: N/A — this is test-only cleanup with no application runtime change.
Offline tests
N/A — this is test-only type cleanup; no network, offline, or synchronization behavior changed.
QA Steps
N/A — this is test-only cleanup with no staging or production behavior change. The title starts with
[No QA].Verify that no errors appear in the JS console: N/A — no application runtime code changed.
PR Author Checklist
For checklist items that are not applicable to this test-only cleanup, checked means the item was considered and determined not applicable.
### 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
Android: Native — N/A; no UI or visual behavior changed.
Android: mWeb Chrome — N/A; no UI or visual behavior changed.
iOS: Native — N/A; no UI or visual behavior changed.
iOS: mWeb Safari — N/A; no UI or visual behavior changed.
MacOS: Chrome / Safari — N/A; no UI or visual behavior changed.
Changed files (10)
tests/ui/SelectCountryStepTest.tsxtests/unit/AddExistingExpenseSearchTest.tstests/unit/EmojiReactionsTest.tstests/unit/LoadTestMiddlewareTest.tstests/unit/LogTest.tstests/unit/ModifiedExpenseMessageTest.tstests/unit/Navigation/createRootStackNavigator/handleReplaceFullscreenUnderRHP.test.tstests/unit/NetworkTest.tsxtests/unit/hooks/useConfirmationValidation.test.tstests/unit/hooks/usePendingConciergeResponse.test.ts