Device manager - logout current session (PSG-743) (#9275)
* trigger verification of other devices * add sign out of current device section in device details * fix classname * lint * strict type fix * fix test * improve mocked VerifReq
This commit is contained in:
parent
41960b164b
commit
f20d86b7b8
13 changed files with 113 additions and 16 deletions
|
@ -30,6 +30,7 @@ import {
|
|||
mockClientMethodsUser,
|
||||
} from '../../../../../test-utils';
|
||||
import Modal from '../../../../../../src/Modal';
|
||||
import LogoutDialog from '../../../../../../src/components/views/dialogs/LogoutDialog';
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
|
@ -53,7 +54,7 @@ describe('<SessionManagerTab />', () => {
|
|||
const mockCrossSigningInfo = {
|
||||
checkDeviceTrust: jest.fn(),
|
||||
};
|
||||
const mockVerificationRequest = { cancel: jest.fn() } as unknown as VerificationRequest;
|
||||
const mockVerificationRequest = { cancel: jest.fn(), on: jest.fn() } as unknown as VerificationRequest;
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
...mockClientMethodsUser(aliceId),
|
||||
getStoredCrossSigningForUser: jest.fn().mockReturnValue(mockCrossSigningInfo),
|
||||
|
@ -374,4 +375,29 @@ describe('<SessionManagerTab />', () => {
|
|||
expect(mockClient.getDevices).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Sign out', () => {
|
||||
it('Signs out of current device', async () => {
|
||||
const modalSpy = jest.spyOn(Modal, 'createDialog');
|
||||
|
||||
mockClient.getDevices.mockResolvedValue({ devices: [alicesDevice] });
|
||||
const { getByTestId } = render(getComponent());
|
||||
|
||||
await act(async () => {
|
||||
await flushPromisesWithFakeTimers();
|
||||
});
|
||||
|
||||
// open device detail
|
||||
const tile1 = getByTestId(`device-tile-${alicesDevice.device_id}`);
|
||||
const toggle1 = tile1.querySelector('[aria-label="Toggle device details"]') as Element;
|
||||
fireEvent.click(toggle1);
|
||||
|
||||
const signOutButton = getByTestId('device-detail-sign-out-cta');
|
||||
expect(signOutButton).toMatchSnapshot();
|
||||
fireEvent.click(signOutButton);
|
||||
|
||||
// logout dialog opened
|
||||
expect(modalSpy).toHaveBeenCalledWith(LogoutDialog, {}, undefined, false, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue