Skip to content

[LWM] test(pay-card): assert view model hook return - #21432

Open
tonykhaov wants to merge 5 commits into
developfrom
test/pay-card-viewmodel-hook-return
Open

[LWM] test(pay-card): assert view model hook return#21432
tonykhaov wants to merge 5 commits into
developfrom
test/pay-card-viewmodel-hook-return

Conversation

@tonykhaov

@tonykhaov tonykhaov commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📝 Description

usePayTabViewModel builds the Card OAuth client config from env and the login callback from the PayTab route. That return was untested.

This PR adds a unit test that calls the hook with renderHook, mocks useRoute for redirect params, and uses real setEnv / getEnv so a debug-settings env change is picked up without remounting. The file is .ts.

🔗 Context

  • JIRA / GitHub issue: n/a
  • ADR (if any): n/a

Copilot AI lite review requested due to automatic review settings September 2, 2026 09:15
@live-github-bot live-github-bot Bot added the mobile Has changes in LLM label Sep 2, 2026
@live-github-bot live-github-bot Bot changed the title test(pay-card): render view model hook through a real route [LWM] test(pay-card): render view model hook through a real route Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Web Tools Build Status

Build Status Deployment
Web Tools Build ⏭️ Skipped

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is test-only, uses the repo’s existing hook test wrapper patterns, and maintains/clarifies the same behavioral assertions without introducing production code risk.

Pull request overview

This PR refactors the PayTab MVVM hook unit test to exercise usePayTabViewModel via renderHook within an actual React Navigation stack screen, avoiding useRoute mocking while keeping the test file as plain .ts.

Changes:

  • Replaced the .tsx probe-component test with a hook-focused test using renderHook and a real stack route wrapper (initialParams).
  • Kept coverage for default OAuth env config, env updates without remount, deep-link code, and missing params behavior.
  • Added a changeset entry for the mobile package describing the test change.
File summaries
File Description
apps/ledger-live-mobile/src/mvvm/features/PayTab/screens/PayTab/usePayTabViewModel.test.tsx Removed the prior component-probe based test implementation.
apps/ledger-live-mobile/src/mvvm/features/PayTab/screens/PayTab/usePayTabViewModel.test.ts New hook-based test that mounts usePayTabViewModel under a real navigation route via innerWrapper.
.changeset/calm-hooks-return.md Declares a patch changeset for the mobile package tied to this test refactor.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 2, 2026 09:25
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 7 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
desktop-main 2.5 MB - 0 -
desktop-preloader 7.1 KB - 0 -
desktop-renderer 82.4 MB - 0 -
desktop-webviewDappPreloader 0 B - 📉 -36.9 KB (-100.0%) -
desktop-webviewPreloader 0 B - 📉 -200.0 B (-100.0%) -
desktop-workers 36.8 KB - 0 -
mobile 129.5 MB - 0 -
📋 Detailed Reports (Click to expand)

📁 desktop-webviewDappPreloader

Path: rsdoctor/desktop-webviewDappPreloader/rsdoctor-data.json

📌 Baseline Commit: b2972d075d37281827e6c68d112e871d016c656b | PR: #21332

Metric Current Baseline Change
📊 Total Size 0 B 36.9 KB -36.9 KB (-100.0%)
🗜️ Gzip Size - - -
📄 JavaScript 0 B 36.9 KB -36.9 KB (-100.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: desktop-webviewDappPreloader Bundle Diff

📁 desktop-webviewPreloader

Path: rsdoctor/desktop-webviewPreloader/rsdoctor-data.json

📌 Baseline Commit: b2972d075d37281827e6c68d112e871d016c656b | PR: #21332

Metric Current Baseline Change
📊 Total Size 0 B 200.0 B -200.0 B (-100.0%)
🗜️ Gzip Size - - -
📄 JavaScript 0 B 200.0 B -200.0 B (-100.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: desktop-webviewPreloader Bundle Diff

Generated by Rsdoctor GitHub Action

@tonykhaov
tonykhaov marked this pull request as ready for review September 2, 2026 09:27
@tonykhaov
tonykhaov requested a review from a team as a code owner September 2, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The implemented test still mocks useRoute, which conflicts with the PR title/description and the changeset text, so the PR messaging and/or test approach needs to be reconciled.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 2, 2026 09:29
@tonykhaov tonykhaov changed the title [LWM] test(pay-card): render view model hook through a real route [LWM] test(pay-card): assert view model hook return Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new test still mocks useRoute, which contradicts the PR’s stated goal of exercising the hook through a real navigation route and leaves that integration untested.

Review details

Suppressed comments (1)

apps/ledger-live-mobile/src/mvvm/features/PayTab/screens/PayTab/usePayTabViewModel.test.ts:17

  • This test still mocks useRoute (and therefore does not exercise usePayTabViewModel inside a real React Navigation stack / real route params), which contradicts the PR description and leaves the route-param parsing behavior untested.

Consider removing the jest.mock("@react-navigation/native") override and instead wrapping renderHook in a minimal NavigationContainer + stack screen with initialParams (you can keep the file as .ts via createElement, as described).

const mockRoute: {
  params?: PayTabNavigatorParamList[typeof ScreenName.PayTab];
} = {
  params: undefined,
};

jest.mock("@react-navigation/native", () => ({
  ...jest.requireActual("@react-navigation/native"),
  useRoute: () => mockRoute,
}));
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mobile Has changes in LLM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants