[NoQA] test: add unit tests for NetSuite credential commands#85288
[NoQA] test: add unit tests for NetSuite credential commands#85288madmax330 merged 4 commits intoExpensify:mainfrom
Conversation
|
@ShridharGoel 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b475176a86
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // This is the regression scenario: first-time connection failed with bad tokens | ||
| // isAuthenticationError is true but connection is unverified, so we must NOT use updateNetSuiteTokens | ||
| const shouldUseUpdate = isAuthenticationError(policy, CONST.POLICY.CONNECTIONS.NAME.NETSUITE) && !isConnectionUnverified(policy, CONST.POLICY.CONNECTIONS.NAME.NETSUITE); |
There was a problem hiding this comment.
Test actual NetSuite command-selection implementation
This assertion computes shouldUseUpdate inside the test itself instead of executing the production selection path, so the suite can pass even when app behavior is wrong; for example, NetSuiteTokenInputForm still branches only on isAuthenticationError, which would call updateNetSuiteTokens for unverified connections (the regression case) while this test still passes. Please invoke the real submit logic (or a shared helper used by production code) and assert which command function is called.
Useful? React with 👍 / 👎.
…handling Follow-up to PR Expensify#85200. Adds tests covering: - connectPolicyToNetSuite sends the correct write command and parameters - updateNetSuiteTokens sends the correct write command and parameters - Both commands set optimistic sync progress data - Credential command selection logic: verified connections with auth errors use updateNetSuiteTokens, while unverified connections use connectPolicyToNetSuite (the regression fix from Expensify#85196) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…red helper Follow-up to PR Expensify#85200. Changes: - Extract shouldUseUpdateNetSuiteTokens helper into connections/index.ts, shared by both NetSuiteTokenInputForm and the test suite - Update NetSuiteTokenInputForm to use the shared helper - Add unit tests covering connectPolicyToNetSuite, updateNetSuiteTokens, and the shouldUseUpdateNetSuiteTokens command selection logic Fixes Expensify#85196 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b475176 to
c7c711f
Compare
|
TS check is failing |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…icy> OnyxEntry<T> is defined as T | undefined (not T | null), so the test was passing null which is not assignable to the parameter type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@ShridharGoel fixed failing TS checks |
|
@ShridharGoel missing your PR Reviewer Checklist |
|
Thanks for pointing that out |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
Can you add NoQA in the title? |
|
@ShridharGoel added |
|
🚧 @madmax330 has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/madmax330 in version: 9.3.40-0 🚀
|
|
🚀 Deployed to staging by https://github.com/madmax330 in version: 9.3.40-0 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀
|
Explanation of Change
Follow-up to PR #85200 (fix for #85196). This PR:
shouldUseUpdateNetSuiteTokenshelper inconnections/index.ts, used by bothNetSuiteTokenInputFormand the test suiteNetSuiteTokenInputFormto use the shared helper instead of inlining the logicTests cover:
connectPolicyToNetSuitesendsConnectPolicyToNetSuitewrite command with correct parameters and optimistic dataupdateNetSuiteTokenssendsUpdateNetSuiteTokenswrite command with correct parameters and optimistic datashouldUseUpdateNetSuiteTokensreturns the correct result for each scenario:false(use full init, the regression case)true(preserve config)falsefalseFixed Issues
$ #85196
Tests
npx jest tests/actions/connections/NetSuite.ts --no-coverageOffline tests
N/A - These are unit tests that run in Jest, not in the app.
QA Steps
[No QA] - Unit tests and a refactor to extract a shared helper. No user-facing behavior change.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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 - Unit tests and refactor only
Android: mWeb Chrome
N/A - Unit tests and refactor only
iOS: Native
N/A - Unit tests and refactor only
iOS: mWeb Safari
N/A - Unit tests and refactor only
MacOS: Chrome / Safari
N/A - Unit tests and refactor only