-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT]: Add trustchain & createQRCodeHostInstance flow #7520
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Add trustchain & createQRCodeHostInstance flow |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
5 changes: 0 additions & 5 deletions
5
apps/ledger-live-mobile/src/newArch/features/Accounts/types/enum/addAccount.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...e-mobile/src/newArch/features/WalletSync/__integrations__/scanQRCode.integration.test.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
import { render, screen } from "@tests/test-renderer"; | ||
|
||
import { INITIAL_TEST, WalletSyncSettingsNavigator } from "./shared"; | ||
|
||
describe("scanQRCode", () => { | ||
it("Should open the QR code scene when 'scan a qr code' toggle is pressed", async () => { | ||
const { user } = render(<WalletSyncSettingsNavigator />, { | ||
overrideInitialState: INITIAL_TEST, | ||
}); | ||
await user.press(await screen.findByText(/ledger sync/i)); | ||
await user.press(await screen.findByText(/already created a key?/i)); | ||
await user.press(await screen.findByText(/scan a qr code/i)); | ||
await expect(await screen.findByText(/show qr/i)).toBeVisible(); | ||
}); | ||
}); |
This file contains 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
46 changes: 46 additions & 0 deletions
46
...c/newArch/features/WalletSync/__integrations__/synchronizeWithQrCode.integration.test.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import { render, screen, waitFor } from "@tests/test-renderer"; | ||
|
||
import { INITIAL_TEST, WalletSyncSettingsNavigator } from "./shared"; | ||
import getWalletSyncEnvironmentParams from "@ledgerhq/live-common/walletSync/getEnvironmentParams"; | ||
|
||
jest.mock("@ledgerhq/trustchain/qrcode/index", () => ({ | ||
createQRCodeHostInstance: () => ({ | ||
trustchainApiBaseUrl: getWalletSyncEnvironmentParams("STAGING").trustchainApiBaseUrl, | ||
onDisplayQRCode: jest.fn().mockImplementation(url => url), | ||
onDisplayDigits: jest.fn().mockImplementation(digits => digits), | ||
addMember: jest.fn(), | ||
}), | ||
})); | ||
|
||
describe("SynchronizeWithQrCode", () => { | ||
it("Should display the QR code when 'show qr' toggle is pressed and add a new member through the flow", async () => { | ||
const { user } = render(<WalletSyncSettingsNavigator />, { | ||
overrideInitialState: INITIAL_TEST, | ||
}); | ||
await user.press(await screen.findByText(/ledger sync/i)); | ||
await user.press(await screen.findByText(/already created a key?/i)); | ||
await user.press(await screen.findByText(/scan a qr code/i)); | ||
await user.press(await screen.findByText(/show qr/i)); | ||
expect(await screen.getByTestId("ws-qr-code-displayed")).toBeVisible(); | ||
|
||
//PinCode Page after scanning QRCode | ||
// Need to wait 3 seconds to simulate the time taken to scan the QR code | ||
setTimeout(async () => { | ||
await waitFor(() => { | ||
expect(screen.getByText("Enter the code")).toBeDefined(); | ||
}); | ||
}, 3000); | ||
|
||
//Succes Page after PinCode | ||
setTimeout(async () => { | ||
await waitFor(() => { | ||
expect( | ||
screen.getByText( | ||
"Changes in your accounts will now automatically appear across all apps and platforms.", | ||
), | ||
).toBeDefined(); | ||
}); | ||
}, 3000); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should prefer to do this after
createQRCodeHostInstance
's Promise terminates.NB: it can also fails, so maybe you can
.then( successHandling, errorHandling )
on it (depending if you need to handle the error or not, for instance the websocket can be closed due to network cut )There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i actually misunderstood the code.
I see that you use the hasCompleted in a later
then
, is it because thecatch
sometimes recover from an error? in that case maybe the then() should be moved before?actually you have guarantee that if promise succeed, it means the whole process was successful π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can try opening the QRCode screen on LLD, for example, and do nothing. After a while, you'll see the success screen appear, which means you're in the then