Repository navigation
[No QA] Remove unsafe type assertions from UI tests - #98440
Conversation
|
@ikevin127 Could you please take a look at this when you get a chance? Thanks! |
|
@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
|
ikevin127
left a comment
There was a problem hiding this comment.
🟢 LGTM
Clean. 15 UI-test files, ~1-2 assertions each, all replaced with the established patterns: jest.mocked(...) over as jest.MockedFunction<...>, jest.requireActual<T> over require(...) as T, and production-derived narrowing (React.isValidElement guards, typed jest.fn<Return, Params>, createMock<T>).
Three changes are more than mechanical and all check out:
ReportActionMessageEditLayoutTestcompletes theuseResponsiveLayoutfixtures with the two genuinely-required fields (behavior-neutral)TestToolMenuBiometricsTest/TimeExpenseConfirmationTestnarrow properly instead of casting mock callsTimePickerTestcorrectly aliasescreateMocktomockCreateMockso it can be referenced inside thejest.mockfactory
| render(<DynamicPaymentCardCurrencySelectorPage />); | ||
|
|
||
| const header = capturedCustomListHeader as React.ReactElement<{isSectionList?: boolean}>; | ||
| expect(header).toBeTruthy(); |
There was a problem hiding this comment.
It seems like we deleted this assertion and never put it back? Why? Can we bring it back?
|
🚀 Deployed to staging by https://github.com/blimpich in version: 9.4.54-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.54-4 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
This test-only cleanup removes 20
@typescript-eslint/no-unsafe-type-assertionfindings from 15 authorized UI-test files. It replaces unsafe assertions with production-derived types, typed Jest APIs, and narrow scenario-specific checks while preserving the existing test behavior.Fixed Issues
$ #94739
PROPOSAL: #94739 (comment)
Count change
Current baseline source:
config/eslint/eslint.seatbelt.tsvat basef1909a5f673ed082e821a2611f32b45a8c9447d5records the baseline for@typescript-eslint/no-unsafe-type-assertion.Before:
tests/ui/BaseListItemTest.tsx: 1tests/ui/BaseLoginFormTest.tsx: 1tests/ui/ComposerTest.tsx: 1tests/ui/DynamicPaymentCardCurrencySelectorPageTest.tsx: 1tests/ui/FloatingActionButtonTest.tsx: 1tests/ui/ReportActionMessageEditLayoutTest.tsx: 2tests/ui/TestToolMenuBiometricsTest.tsx: 2tests/ui/TimeExpenseConfirmationTest.tsx: 2tests/ui/UpgradeConfirmationTest.tsx: 2tests/ui/WeekListItemHeaderTest.tsx: 2tests/ui/components/CompactMenuContextTest.tsx: 1tests/ui/components/DisplayNames.test.tsx: 1tests/ui/components/IOURequestStepReportTest.tsx: 1tests/ui/components/ProductTrainingContextProvider.tsx: 1tests/ui/components/TimePickerTest.tsx: 1After:
Net reduction:
@typescript-eslint/no-unsafe-type-assertionfindings across the 15 target files.TSV evidence:
Tests
ab7d215ccec9832409a22fd0d5d0ea07d5b22fbbb46bb05c36eaed9d40cbea39passed cleanup counting, formatting, lint, focused Jest, changed-path checks, andgit diff --checkfor exact diffsha256:54455595a0742e30ba426ab53194cccbae4f12853854b951f073895ca7142e46.src/components/AddressSearch/index.tsxfsClassdiagnostic outside the authorized paths; it reported no authorized-path diagnostic.31611165874passed typecheck, lint, format, React Compiler, and Jest for signed commit7732156022ea32903b3220271d7606944a2471e8using immutable workflowseatbelt-ci-v1@0e497c4fa0cbf7e9d776701e9307afe34083a8d0.Offline tests
N/A — this is a test-only type-safety cleanup; it changes no application runtime or network behavior, and no manual offline test was performed.
QA Steps
N/A — this is a test-only cleanup and the title starts with
[No QA]; no staging or production manual QA was performed.PR Author Checklist
Each checklist item below is checked because it was considered. Platform, staging or production, offline, screenshot or video, high-traffic, console, and product-component testing are N/A for this test-only cleanup; 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 or visual behavior changed; no screenshots or videos were produced.
Changed files (15)
tests/ui/BaseListItemTest.tsxtests/ui/BaseLoginFormTest.tsxtests/ui/ComposerTest.tsxtests/ui/DynamicPaymentCardCurrencySelectorPageTest.tsxtests/ui/FloatingActionButtonTest.tsxtests/ui/ReportActionMessageEditLayoutTest.tsxtests/ui/TestToolMenuBiometricsTest.tsxtests/ui/TimeExpenseConfirmationTest.tsxtests/ui/UpgradeConfirmationTest.tsxtests/ui/WeekListItemHeaderTest.tsxtests/ui/components/CompactMenuContextTest.tsxtests/ui/components/DisplayNames.test.tsxtests/ui/components/IOURequestStepReportTest.tsxtests/ui/components/ProductTrainingContextProvider.tsxtests/ui/components/TimePickerTest.tsx