Skip to content

Commit 98e8439

Browse files
authored
Merge pull request #18311 from mozilla/FXA-11048
fix(copy): Update fallback text/FTL to handle '1 code remaining'
2 parents 976588a + 7755b20 commit 98e8439

6 files changed

Lines changed: 34 additions & 8 deletions

File tree

packages/fxa-settings/src/components/Settings/SubRow/en.ftl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ tfa-row-backup-codes-title = Backup authentication codes
66
tfa-row-backup-codes-not-available = No codes available
77
# $numCodesRemaining - the number of backup authentication codes that have not yet been used (generally between 1 to 5)
88
# A different message is shown when no codes are available
9-
tfa-row-backup-codes-available = { $numCodesAvailable } codes remaining
9+
tfa-row-backup-codes-available-v2 = { $numCodesAvailable ->
10+
[one] { $numCodesAvailable } code remaining
11+
*[other] { $numCodesAvailable } codes remaining
12+
}
1013
# Shown to users who have backup authentication codes - this will allow them to generate new codes to replace the previous ones
1114
tfa-row-backup-codes-get-new-cta = Get new codes
1215
# Shown to users who have no backup authentication codes

packages/fxa-settings/src/components/Settings/SubRow/index.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ describe('BackupCodesSubRow', () => {
6262
expect(screen.getByText('Get new codes')).toBeInTheDocument();
6363
});
6464

65+
it('renders correctly when 1 code is available', () => {
66+
renderWithLocalizationProvider(
67+
<BackupCodesSubRow {...defaultProps} numCodesAvailable={1} />
68+
);
69+
expect(
70+
screen.getByText('Backup authentication codes')
71+
).toBeInTheDocument();
72+
expect(screen.getByText('1 code remaining')).toBeInTheDocument();
73+
});
74+
6575
it('renders description when showDescription is true', () => {
6676
renderWithLocalizationProvider(<BackupCodesSubRow {...defaultProps} />);
6777
expect(

packages/fxa-settings/src/components/Settings/SubRow/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ export const BackupCodesSubRow = ({
180180
<BackupCodesDisabledIcon className="-ms-1 -my-2 scale-50" />
181181
);
182182
const message = hasCodesRemaining ? (
183-
<FtlMsg id="tfa-row-backup-codes-available" vars={{ numCodesAvailable }}>
184-
<p>{`${numCodesAvailable} codes remaining`}</p>
183+
<FtlMsg id="tfa-row-backup-codes-available-v2" vars={{ numCodesAvailable }}>
184+
<p>{`${numCodesAvailable} code${
185+
numCodesAvailable === 1 ? '' : 's'
186+
} remaining`}</p>
185187
</FtlMsg>
186188
) : (
187189
<FtlMsg id="tfa-row-backup-codes-not-available">

packages/fxa-settings/src/pages/Signin/SigninRecoveryChoice/en.ftl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ signin-recovery-method-subheader = Choose a recovery method
77
signin-recovery-method-details = Let’s make sure it’s you using your recovery methods.
88
signin-recovery-method-phone = Recovery phone
99
signin-recovery-method-code-v2 = Backup authentication codes
10-
# Variable: $numberOfCodes (String) - The number of authentication codes the user has left, e.g. 4
11-
signin-recovery-method-code-info = { $numberOfCodes } codes remaining
10+
# Variable: $numBackupCodes (String) - The number of backup authentication codes the user has left, e.g., 4
11+
signin-recovery-method-code-info-v2 =
12+
{ $numBackupCodes ->
13+
[one] { $numBackupCodes } code remaining
14+
*[other] { $numBackupCodes } codes remaining
15+
}
1216
# Shown when a backend service fails and a code cannot be sent to the user's recovery phone.
1317
signin-recovery-method-send-code-error-heading = There was a problem sending a code to your recovery phone
1418
signin-recovery-method-send-code-error-description = Please try again later or use your backup authentication codes.

packages/fxa-settings/src/pages/Signin/SigninRecoveryChoice/index.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ describe('SigninRecoveryChoice', () => {
7474
expect(
7575
screen.getByLabelText(/Backup authentication codes/i)
7676
).toBeInTheDocument();
77+
expect(screen.getByText('4 codes remaining')).toBeInTheDocument();
78+
});
79+
80+
it('renders as expected with one backup authentication code', () => {
81+
renderSigninRecoveryChoice({ numBackupCodes: 1 });
82+
83+
expect(screen.getByText('1 code remaining')).toBeInTheDocument();
7784
});
7885

7986
it('calls handlePhoneChoice when Recovery phone option is selected', async () => {

packages/fxa-settings/src/pages/Signin/SigninRecoveryChoice/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ const SigninRecoveryChoice = ({
112112
'Backup authentication codes'
113113
),
114114
localizedChoiceInfo: ftlMsgResolver.getMsg(
115-
'signin-recovery-method-code-info',
116-
`${numBackupCodes} codes remaining`,
117-
{ numberOfCodes: numBackupCodes }
115+
'signin-recovery-method-code-info-v2',
116+
`${numBackupCodes} code${numBackupCodes === 1 ? '' : 's'} remaining`,
117+
{ numBackupCodes }
118118
),
119119
},
120120
];

0 commit comments

Comments
 (0)