tests: fix test relying on old hard coded english messages
This commit is contained in:
parent
9df81d7989
commit
acdf8a050a
4 changed files with 21 additions and 21 deletions
|
@ -229,7 +229,7 @@
|
|||
},
|
||||
"settings": {
|
||||
"tab-title": "Settings",
|
||||
"title": "General Settings",
|
||||
"title": "General settings",
|
||||
"subtitle": "This will update your settings.json file. Make sure you know what you are doing before updating these values.",
|
||||
"settings-updated": "Settings updated. Restart your instance to apply new settings.",
|
||||
"invalid-ip": "Invalid IP address",
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('<ChangePasswordForm />', () => {
|
|||
|
||||
// assert
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Password successfully changed')).toBeInTheDocument();
|
||||
expect(screen.getByText('Password changed successfully')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -135,7 +135,7 @@ describe('Test: restart', () => {
|
|||
await setConfig('demoMode', true);
|
||||
|
||||
// Act & Assert
|
||||
await expect(SystemService.restart()).rejects.toThrow('Cannot restart in demo mode');
|
||||
await expect(SystemService.restart()).rejects.toThrow('server-messages.errors.not-allowed-in-demo');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -161,7 +161,7 @@ describe('Test: update', () => {
|
|||
setConfig('version', '0.0.1');
|
||||
|
||||
// Act & Assert
|
||||
await expect(SystemService.update()).rejects.toThrow('Could not get latest version');
|
||||
await expect(SystemService.update()).rejects.toThrow('server-messages.errors.could-not-get-latest-version');
|
||||
});
|
||||
|
||||
it('Should throw if current version is higher than latest', async () => {
|
||||
|
@ -170,7 +170,7 @@ describe('Test: update', () => {
|
|||
TipiCache.set('latestVersion', '0.0.1');
|
||||
|
||||
// Act & Assert
|
||||
await expect(SystemService.update()).rejects.toThrow('Current version is newer than latest version');
|
||||
await expect(SystemService.update()).rejects.toThrow('server-messages.errors.current-version-is-latest');
|
||||
});
|
||||
|
||||
it('Should throw if current version is equal to latest', async () => {
|
||||
|
@ -179,7 +179,7 @@ describe('Test: update', () => {
|
|||
TipiCache.set('latestVersion', '0.0.1');
|
||||
|
||||
// Act & Assert
|
||||
await expect(SystemService.update()).rejects.toThrow('Current version is already up to date');
|
||||
await expect(SystemService.update()).rejects.toThrow('server-messages.errors.current-version-is-latest');
|
||||
});
|
||||
|
||||
it('Should throw an error if there is a major version difference', async () => {
|
||||
|
@ -188,6 +188,6 @@ describe('Test: update', () => {
|
|||
TipiCache.set('latestVersion', '1.0.0');
|
||||
|
||||
// Act & Assert
|
||||
await expect(SystemService.update()).rejects.toThrow('The major version has changed. Please update manually');
|
||||
await expect(SystemService.update()).rejects.toThrow('server-messages.errors.major-version-update');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue