diff --git a/frontend/src/component/user/PasswordAuth.test.tsx b/frontend/src/component/user/PasswordAuth.test.tsx new file mode 100644 index 0000000000..bffdda6539 --- /dev/null +++ b/frontend/src/component/user/PasswordAuth.test.tsx @@ -0,0 +1,76 @@ +import { render } from 'utils/testRenderer'; +import { screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import ToastRenderer from 'component/common/ToastRenderer/ToastRenderer'; +import { testServerRoute, testServerSetup } from 'utils/testServer'; +import PasswordAuth from './PasswordAuth'; +import { LOGIN_BUTTON } from 'utils/testIds'; +import type { IAuthEndpointDetailsResponse } from '../../hooks/api/getters/useAuth/useAuthEndpoint'; +import HostedAuth from './HostedAuth'; + +const server = testServerSetup(); + +const setupApi = () => { + testServerRoute( + server, + '/api/admin/auth', + { + deletedSessions: 1, + activeSessions: 3, + }, + 'post', + 200, + ); +}; + +test('should show deleted stale sessions info for Password Auth', async () => { + setupApi(); + render( + <> + + + , + ); + const login = screen.getByLabelText('Username or email'); + await userEvent.type(login, 'user@getunleash.io'); + + const password = screen.getByLabelText('Password'); + await userEvent.type(password, 'password'); + + const button = screen.getByTestId(LOGIN_BUTTON); + + button.click(); + + await screen.findByText('Maximum Session Limit Reached'); +}); + +test('should show deleted stale sessions info for Hosted Auth', async () => { + setupApi(); + render( + <> + + + , + ); + const login = screen.getByLabelText('Username or email'); + await userEvent.type(login, 'user@getunleash.io'); + + const password = screen.getByLabelText('Password'); + await userEvent.type(password, 'password'); + + const button = screen.getByTestId(LOGIN_BUTTON); + + button.click(); + + await screen.findByText('Maximum Session Limit Reached'); +});