mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-31 01:16:01 +02:00
test: session deleted toast (#8754)
This commit is contained in:
parent
2014d367f8
commit
5a2663a451
76
frontend/src/component/user/PasswordAuth.test.tsx
Normal file
76
frontend/src/component/user/PasswordAuth.test.tsx
Normal file
@ -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(
|
||||
<>
|
||||
<ToastRenderer />
|
||||
<PasswordAuth
|
||||
authDetails={
|
||||
{ path: '/api/admin/auth' } as IAuthEndpointDetailsResponse
|
||||
}
|
||||
redirect={''}
|
||||
/>
|
||||
</>,
|
||||
);
|
||||
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(
|
||||
<>
|
||||
<ToastRenderer />
|
||||
<HostedAuth
|
||||
authDetails={
|
||||
{ path: '/api/admin/auth' } as IAuthEndpointDetailsResponse
|
||||
}
|
||||
redirect={''}
|
||||
/>
|
||||
</>,
|
||||
);
|
||||
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');
|
||||
});
|
Loading…
Reference in New Issue
Block a user