|
@@ -28,7 +28,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
it('should prompt for password when disabling 2FA', async () => {
|
|
|
// arrange
|
|
|
- server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: true, id: 12, username: 'test' } }));
|
|
|
+ server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: true, id: 12, username: 'test', locale: 'en' } }));
|
|
|
render(<OtpForm />);
|
|
|
const twoFactorAuthButton = screen.getByRole('switch', { name: /Enable two-factor authentication/i });
|
|
|
await waitFor(() => {
|
|
@@ -46,7 +46,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
it('should show show error toast if password is incorrect while enabling 2FA', async () => {
|
|
|
// arrange
|
|
|
- server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: false, id: 12, username: 'test' } }));
|
|
|
+ server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: false, id: 12, username: 'test', locale: 'en' } }));
|
|
|
server.use(getTRPCMockError({ path: ['auth', 'getTotpUri'], type: 'mutation', message: 'Invalid password' }));
|
|
|
render(<OtpForm />);
|
|
|
const twoFactorAuthButton = screen.getByRole('switch', { name: /Enable two-factor authentication/i });
|
|
@@ -63,7 +63,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Enable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Enable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -74,7 +74,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
it('should show show error toast if password is incorrect while disabling 2FA', async () => {
|
|
|
// arrange
|
|
|
- server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: true, id: 12, username: 'test' } }));
|
|
|
+ server.use(getTRPCMock({ path: ['auth', 'me'], response: { locale: 'en', totpEnabled: true, id: 12, username: 'test' } }));
|
|
|
server.use(getTRPCMockError({ path: ['auth', 'disableTotp'], type: 'mutation', message: 'Invalid password' }));
|
|
|
render(<OtpForm />);
|
|
|
|
|
@@ -92,7 +92,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Disable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Disable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -103,7 +103,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
it('should show success toast if password is correct while disabling 2FA', async () => {
|
|
|
// arrange
|
|
|
- server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: true, id: 12, username: 'test' } }));
|
|
|
+ server.use(getTRPCMock({ path: ['auth', 'me'], response: { locale: 'en', totpEnabled: true, id: 12, username: 'test' } }));
|
|
|
server.use(getTRPCMock({ path: ['auth', 'disableTotp'], type: 'mutation', response: true }));
|
|
|
|
|
|
render(<OtpForm />);
|
|
@@ -122,7 +122,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Disable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Disable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -147,7 +147,7 @@ describe('<OtpForm />', () => {
|
|
|
});
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Enable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Enable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -155,7 +155,7 @@ describe('<OtpForm />', () => {
|
|
|
expect(screen.getByText('Scan this QR code with your authenticator app.')).toBeInTheDocument();
|
|
|
});
|
|
|
expect(screen.getByRole('textbox', { name: 'secret key' })).toHaveValue('test');
|
|
|
- expect(screen.getByRole('button', { name: 'Enable 2FA' })).toBeDisabled();
|
|
|
+ expect(screen.getByRole('button', { name: 'Enable two-factor authentication' })).toBeDisabled();
|
|
|
});
|
|
|
|
|
|
it('should show error toast if submitted totp code is invalid', async () => {
|
|
@@ -177,7 +177,7 @@ describe('<OtpForm />', () => {
|
|
|
});
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Enable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Enable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
await waitFor(() => {
|
|
@@ -190,7 +190,7 @@ describe('<OtpForm />', () => {
|
|
|
fireEvent.change(inputEl, { target: { value: '1' } });
|
|
|
});
|
|
|
|
|
|
- const enable2FAButton = screen.getByRole('button', { name: 'Enable 2FA' });
|
|
|
+ const enable2FAButton = screen.getByRole('button', { name: 'Enable two-factor authentication' });
|
|
|
enable2FAButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -216,7 +216,7 @@ describe('<OtpForm />', () => {
|
|
|
});
|
|
|
const passwordInput = screen.getByRole('textbox', { name: 'password' });
|
|
|
fireEvent.change(passwordInput, { target: { value: 'test' } });
|
|
|
- const submitButton = screen.getByRole('button', { name: /Enable 2FA/i });
|
|
|
+ const submitButton = screen.getByRole('button', { name: /Enable two-factor authentication/i });
|
|
|
submitButton.click();
|
|
|
|
|
|
await waitFor(() => {
|
|
@@ -229,7 +229,7 @@ describe('<OtpForm />', () => {
|
|
|
fireEvent.change(inputEl, { target: { value: '1' } });
|
|
|
});
|
|
|
|
|
|
- const enable2FAButton = screen.getByRole('button', { name: 'Enable 2FA' });
|
|
|
+ const enable2FAButton = screen.getByRole('button', { name: 'Enable two-factor authentication' });
|
|
|
enable2FAButton.click();
|
|
|
|
|
|
// assert
|
|
@@ -262,7 +262,7 @@ describe('<OtpForm />', () => {
|
|
|
|
|
|
it('can close the disable modal by clicking on the esc key', async () => {
|
|
|
// arrange
|
|
|
- server.use(getTRPCMock({ path: ['auth', 'me'], response: { totpEnabled: true, username: '', id: 1 } }));
|
|
|
+ server.use(getTRPCMock({ path: ['auth', 'me'], response: { locale: 'en', totpEnabled: true, username: '', id: 1 } }));
|
|
|
render(<OtpForm />);
|
|
|
const twoFactorAuthButton = screen.getByRole('switch', { name: /Enable two-factor authentication/i });
|
|
|
await waitFor(() => {
|