-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DIA-930): tidy-up login with OTP step [WIP] (#10954)
* adds textContentType for password managers * prevented users from switching code types for on_demand * add title to otp step * started writing tests * change sentence case to title case
- Loading branch information
Showing
5 changed files
with
148 additions
and
100 deletions.
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
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
src/app/Scenes/Onboarding/Auth2/scenes/__tests__/LoginOTPStep.test.tsx
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/app/Scenes/Onboarding/Auth2/scenes/__tests__/LoginOTPStep.tests.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 { fireEvent, screen } from "@testing-library/react-native" | ||
import { LoginOTPStep } from "app/Scenes/Onboarding/Auth2/scenes/LoginOTPStep" | ||
import { renderWithWrappers } from "app/utils/tests/renderWithWrappers" | ||
|
||
const mockUseAuthScreen = jest.fn() | ||
|
||
jest.mock("app/Scenes/Onboarding/Auth2/hooks/useAuthNavigation", () => ({ | ||
useAuthNavigation: jest.fn(), | ||
useAuthScreen: () => mockUseAuthScreen(), | ||
})) | ||
|
||
describe("LoginOTPStep", () => { | ||
beforeEach(() => { | ||
mockUseAuthScreen.mockReturnValue({ params: { otpMode: "standard" } }) | ||
}) | ||
|
||
it("renders correctly", () => { | ||
renderWithWrappers(<LoginOTPStep />) | ||
|
||
expect(screen.getByText("Authentication Code")).toBeDefined() | ||
expect(screen.getByText("Authentication code")).toBeDefined() | ||
}) | ||
|
||
it("allows the user to switch between authentication and recovery codes", () => { | ||
renderWithWrappers(<LoginOTPStep />) | ||
|
||
const recoveryCodeButton = screen.getByText("Enter recovery code instead") | ||
expect(recoveryCodeButton).toBeDefined() | ||
|
||
fireEvent.press(recoveryCodeButton) | ||
|
||
expect(screen.getByText("Recovery code")).toBeDefined() | ||
}) | ||
|
||
it("renders instructions when OTP mode is 'on_demand'", () => { | ||
mockUseAuthScreen.mockReturnValue({ params: { otpMode: "on_demand" } }) | ||
|
||
renderWithWrappers(<LoginOTPStep />) | ||
|
||
expect( | ||
screen.getByText( | ||
"Your safety and security are important to us. Please check your email for a one-time authentication code to complete your login." | ||
) | ||
).toBeDefined() | ||
}) | ||
}) |