Skip to content

Commit 9ec17cd

Browse files
authored
chore(ui-react-native): SetupTOTP small fixes (#3048)
1 parent 839ceb3 commit 9ec17cd

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

packages/react-native/src/Authenticator/Defaults/SetupTOTP/SetupTOTP.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const {
2525
getConfirmingText,
2626
getConfirmText,
2727
getSetupTOTPText,
28+
getSetupTOTPInstructionsText,
2829
} = authenticatorTextUtil;
2930

3031
const SetupTOTP: DefaultSetupTOTPComponent = ({
@@ -67,9 +68,14 @@ const SetupTOTP: DefaultSetupTOTPComponent = ({
6768
const secondaryButtonText = getBackToSignInText();
6869

6970
const body = secretKey ? (
70-
<Label selectable style={styles.secretKeyText}>
71-
{secretKey}
72-
</Label>
71+
<>
72+
<Label style={styles.secretKeyText}>
73+
{getSetupTOTPInstructionsText()}
74+
</Label>
75+
<Label selectable style={styles.secretKeyText}>
76+
{secretKey}
77+
</Label>
78+
</>
7379
) : null;
7480

7581
const buttons = useMemo(

packages/react-native/src/Authenticator/Defaults/SetupTOTP/__tests__/SetupTOTP.spec.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const {
3737
getConfirmingText,
3838
getConfirmText,
3939
getSetupTOTPText,
40+
getSetupTOTPInstructionsText,
4041
} = authenticatorTextUtil;
4142

4243
const SECRET_KEY = 'secretKey';
@@ -96,13 +97,14 @@ describe('SetupTOTP', () => {
9697
});
9798

9899
it('handles secret code generation as expected', async () => {
99-
const { queryByText, rerender } = render(
100+
const { getByText, queryByText, rerender } = render(
100101
<SetupTOTP {...props} getTotpSecretCode={mockGetTotpSecretCode} />
101102
);
102103
await waitFor(async () => {
103104
expect(mockGetTotpSecretCode).toHaveBeenCalledTimes(1);
105+
expect(getByText(getSetupTOTPInstructionsText())).toBeDefined();
104106
expect(queryByText(SECRET_KEY)).toBeDefined();
105-
expect(queryByText(SECRET_KEY)?.props.selectable).toBe(true);
107+
expect(getByText(SECRET_KEY).props.selectable).toBe(true);
106108
expect(errorSpy).not.toHaveBeenCalled();
107109

108110
rerender(

packages/react-native/src/Authenticator/Defaults/SetupTOTP/styles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export interface SetupTOTPStyle {
55
}
66

77
export const styles: SetupTOTPStyle = StyleSheet.create({
8-
secretKeyText: { flexWrap: 'wrap', paddingVertical: 4 },
8+
// TODO: replace with tokens
9+
secretKeyText: { flexWrap: 'wrap', paddingVertical: 4, marginHorizontal: 8 },
910
});

packages/ui/src/helpers/authenticator/textUtil.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export const authenticatorTextUtil = {
133133

134134
/** SetupTOTP */
135135
getSetupTOTPText: () => translate(DefaultTexts.SETUP_TOTP),
136+
// TODO: add defaultText for below
137+
getSetupTOTPInstructionsText: () =>
138+
translate(
139+
'Copy and paste the secret key below into an authenticator app and then enter the code in the text field below.'
140+
),
136141
// TODO: add defaultText for "COPIED"
137142
getCopiedText: () => translate('COPIED'),
138143

0 commit comments

Comments
 (0)