element-web/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx

1707 lines
68 KiB
TypeScript
Raw Normal View History

/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
2022-12-12 11:24:14 +00:00
import React from "react";
import { act, fireEvent, render, RenderResult, screen } from "@testing-library/react";
2022-12-12 11:24:14 +00:00
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
import { logger } from "matrix-js-sdk/src/logger";
import { CryptoApi, DeviceVerificationStatus, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
import { defer, sleep } from "matrix-js-sdk/src/utils";
import {
ClientEvent,
Device,
IMyDevice,
LOCAL_NOTIFICATION_SETTINGS_PREFIX,
MatrixEvent,
PUSHER_DEVICE_ID,
PUSHER_ENABLED,
IAuthData,
GET_LOGIN_TOKEN_CAPABILITY,
MatrixError,
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
MatrixClient,
2022-12-12 11:24:14 +00:00
} from "matrix-js-sdk/src/matrix";
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
import { mocked, MockedObject } from "jest-mock";
import {
clearAllModals,
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
flushPromises,
getMockClientWithEventEmitter,
mkPusher,
mockClientMethodsServer,
mockClientMethodsUser,
mockPlatformPeg,
2022-12-12 11:24:14 +00:00
} from "../../../../../test-utils";
import SessionManagerTab from "../../../../../../src/components/views/settings/tabs/user/SessionManagerTab";
2022-12-12 11:24:14 +00:00
import Modal from "../../../../../../src/Modal";
import LogoutDialog from "../../../../../../src/components/views/dialogs/LogoutDialog";
import { DeviceSecurityVariation, ExtendedDevice } from "../../../../../../src/components/views/settings/devices/types";
import { INACTIVE_DEVICE_AGE_MS } from "../../../../../../src/components/views/settings/devices/filter";
import SettingsStore from "../../../../../../src/settings/SettingsStore";
import { getClientInformationEventType } from "../../../../../../src/utils/device/clientInformation";
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
import { SDKContext, SdkContextClass } from "../../../../../../src/contexts/SDKContext";
import { OidcClientStore } from "../../../../../../src/stores/oidc/OidcClientStore";
mockPlatformPeg();
// to restore later
const realWindowLocation = window.location;
function deviceToDeviceObj(userId: string, device: IMyDevice, opts: Partial<Device> = {}): Device {
const deviceOpts: Pick<Device, "deviceId" | "userId" | "algorithms" | "keys"> & Partial<Device> = {
deviceId: device.device_id,
userId,
algorithms: [],
displayName: device.display_name,
keys: new Map(),
...opts,
};
return new Device(deviceOpts);
}
2022-12-12 11:24:14 +00:00
describe("<SessionManagerTab />", () => {
const aliceId = "@alice:server.org";
const deviceId = "alices_device";
const alicesDevice = {
device_id: deviceId,
2022-12-12 11:24:14 +00:00
display_name: "Alices device",
};
const alicesDeviceObj = deviceToDeviceObj(aliceId, alicesDevice);
const alicesMobileDevice = {
2022-12-12 11:24:14 +00:00
device_id: "alices_mobile_device",
last_seen_ts: Date.now(),
};
const alicesMobileDeviceObj = deviceToDeviceObj(aliceId, alicesMobileDevice);
const alicesOlderMobileDevice = {
2022-12-12 11:24:14 +00:00
device_id: "alices_older_mobile_device",
last_seen_ts: Date.now() - 600000,
};
const alicesInactiveDevice = {
2022-12-12 11:24:14 +00:00
device_id: "alices_older_inactive_mobile_device",
last_seen_ts: Date.now() - (INACTIVE_DEVICE_AGE_MS + 1000),
};
const alicesDehydratedDevice = {
device_id: "alices_dehydrated_device",
last_seen_ts: Date.now(),
};
const alicesDehydratedDeviceObj = deviceToDeviceObj(aliceId, alicesDehydratedDevice, { dehydrated: true });
const alicesOtherDehydratedDevice = {
device_id: "alices_other_dehydrated_device",
last_seen_ts: Date.now(),
};
const alicesOtherDehydratedDeviceObj = deviceToDeviceObj(aliceId, alicesOtherDehydratedDevice, {
dehydrated: true,
});
2023-03-28 10:23:16 +00:00
const mockVerificationRequest = {
cancel: jest.fn(),
on: jest.fn(),
} as unknown as VerificationRequest;
const mockCrypto = mocked({
getDeviceVerificationStatus: jest.fn(),
getUserDeviceInfo: jest.fn(),
requestDeviceVerification: jest.fn().mockResolvedValue(mockVerificationRequest),
} as unknown as CryptoApi);
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
let mockClient!: MockedObject<MatrixClient>;
let sdkContext: SdkContextClass;
const defaultProps = {};
2022-12-12 11:24:14 +00:00
const getComponent = (props = {}): React.ReactElement => (
2024-04-15 13:54:37 +00:00
<SDKContext.Provider value={sdkContext}>
<SessionManagerTab {...defaultProps} {...props} />
</SDKContext.Provider>
2022-12-12 11:24:14 +00:00
);
const toggleDeviceDetails = (
2022-12-12 11:24:14 +00:00
getByTestId: ReturnType<typeof render>["getByTestId"],
deviceId: ExtendedDevice["device_id"],
isOpen?: boolean,
): void => {
// open device detail
const tile = getByTestId(`device-tile-${deviceId}`);
2022-12-12 11:24:14 +00:00
const label = isOpen ? "Hide details" : "Show details";
const toggle = tile.querySelector(`[aria-label="${label}"]`) as Element;
fireEvent.click(toggle);
};
const toggleDeviceSelection = (
2022-12-12 11:24:14 +00:00
getByTestId: ReturnType<typeof render>["getByTestId"],
deviceId: ExtendedDevice["device_id"],
): void => {
const checkbox = getByTestId(`device-tile-checkbox-${deviceId}`);
fireEvent.click(checkbox);
};
const getDeviceTile = (
2022-12-12 11:24:14 +00:00
getByTestId: ReturnType<typeof render>["getByTestId"],
deviceId: ExtendedDevice["device_id"],
): HTMLElement => {
return getByTestId(`device-tile-${deviceId}`);
};
2022-12-12 11:24:14 +00:00
const setFilter = async (container: HTMLElement, option: DeviceSecurityVariation | string) =>
await act(async () => {
const dropdown = container.querySelector('[aria-label="Filter devices"]');
2022-12-12 11:24:14 +00:00
fireEvent.click(dropdown as Element);
// tick to let dropdown render
await flushPromises();
2022-12-12 11:24:14 +00:00
fireEvent.click(container.querySelector(`#device-list-filter__${option}`) as Element);
});
const isDeviceSelected = (
2022-12-12 11:24:14 +00:00
getByTestId: ReturnType<typeof render>["getByTestId"],
deviceId: ExtendedDevice["device_id"],
): boolean => !!(getByTestId(`device-tile-checkbox-${deviceId}`) as HTMLInputElement).checked;
2022-12-12 11:24:14 +00:00
const isSelectAllChecked = (getByTestId: ReturnType<typeof render>["getByTestId"]): boolean =>
!!(getByTestId("device-select-all-checkbox") as HTMLInputElement).checked;
const confirmSignout = async (
2022-12-12 11:24:14 +00:00
getByTestId: ReturnType<typeof render>["getByTestId"],
confirm = true,
): Promise<void> => {
// modal has sleeps in rendering process :(
await screen.findByRole("dialog");
2022-12-12 11:24:14 +00:00
const buttonId = confirm ? "dialog-primary-button" : "dialog-cancel-button";
fireEvent.click(getByTestId(buttonId));
// flush the confirmation promise
await flushPromises();
};
beforeEach(async () => {
mockClient = getMockClientWithEventEmitter({
...mockClientMethodsUser(aliceId),
...mockClientMethodsServer(),
getCrypto: jest.fn().mockReturnValue(mockCrypto),
getDevices: jest.fn(),
getStoredDevice: jest.fn(),
getDeviceId: jest.fn().mockReturnValue(deviceId),
deleteMultipleDevices: jest.fn(),
generateClientSecret: jest.fn(),
setDeviceDetails: jest.fn(),
getAccountData: jest.fn(),
deleteAccountData: jest.fn(),
doesServerSupportUnstableFeature: jest.fn().mockResolvedValue(true),
getPushers: jest.fn(),
setPusher: jest.fn(),
setLocalNotificationSettings: jest.fn(),
});
jest.clearAllMocks();
2022-12-12 11:24:14 +00:00
jest.spyOn(logger, "error").mockRestore();
mockClient.getStoredDevice.mockImplementation((_userId, id) => {
2022-12-12 11:24:14 +00:00
const device = [alicesDevice, alicesMobileDevice].find((device) => device.device_id === id);
return device ? new DeviceInfo(device.device_id) : null;
});
mockCrypto.getDeviceVerificationStatus.mockReset().mockResolvedValue(new DeviceVerificationStatus({}));
2022-12-12 11:24:14 +00:00
mockClient.getDevices.mockReset().mockResolvedValue({ devices: [alicesDevice, alicesMobileDevice] });
2022-12-12 11:24:14 +00:00
mockClient.getPushers.mockReset().mockResolvedValue({
pushers: [
mkPusher({
[PUSHER_DEVICE_ID.name]: alicesMobileDevice.device_id,
[PUSHER_ENABLED.name]: true,
2022-12-12 11:24:14 +00:00
}),
],
});
// @ts-ignore mock
2023-03-28 10:23:16 +00:00
mockClient.store = { accountData: new Map() };
2022-12-12 11:24:14 +00:00
mockClient.getAccountData.mockReset().mockImplementation((eventType) => {
if (eventType.startsWith(LOCAL_NOTIFICATION_SETTINGS_PREFIX.name)) {
return new MatrixEvent({
type: eventType,
content: {
is_silenced: false,
},
});
}
});
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
sdkContext = new SdkContextClass();
sdkContext.client = mockClient;
// @ts-ignore allow delete of non-optional prop
delete window.location;
// @ts-ignore ugly mocking
window.location = {
href: "https://localhost/",
origin: "https://localhost/",
};
// sometimes a verification modal is in modal state when these tests run
// make sure the coast is clear
await clearAllModals();
});
afterAll(() => {
window.location = realWindowLocation;
});
2022-12-12 11:24:14 +00:00
it("renders spinner while devices load", () => {
const { container } = render(getComponent());
2022-12-12 11:24:14 +00:00
expect(container.getElementsByClassName("mx_Spinner").length).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("removes spinner when device fetch fails", async () => {
// eat the expected error log
2022-12-12 11:24:14 +00:00
jest.spyOn(logger, "error").mockImplementation(() => {});
mockClient.getDevices.mockRejectedValue({ httpStatus: 404 });
const { container } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("sets device verification status correctly", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
2022-12-12 11:24:14 +00:00
// alices device is trusted
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
2022-12-12 11:24:14 +00:00
}
// alices mobile device is not
if (deviceId === alicesMobileDevice.device_id) {
return new DeviceVerificationStatus({});
2022-12-12 11:24:14 +00:00
}
// alicesOlderMobileDevice does not support encryption
return null;
2022-12-12 11:24:14 +00:00
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledTimes(3);
expect(
2022-12-12 11:24:14 +00:00
getByTestId(`device-tile-${alicesDevice.device_id}`).querySelector('[aria-label="Verified"]'),
).toBeTruthy();
expect(
2022-12-12 11:24:14 +00:00
getByTestId(`device-tile-${alicesMobileDevice.device_id}`).querySelector('[aria-label="Unverified"]'),
).toBeTruthy();
// sessions that dont support encryption use unverified badge
expect(
2022-12-12 11:24:14 +00:00
getByTestId(`device-tile-${alicesOlderMobileDevice.device_id}`).querySelector('[aria-label="Unverified"]'),
).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("extends device with client information when available", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
mockClient.getAccountData.mockImplementation((eventType: string) => {
const content = {
2022-12-12 11:24:14 +00:00
name: "Element Web",
version: "1.2.3",
url: "test.com",
};
return new MatrixEvent({
type: eventType,
content,
});
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
// twice for each device
expect(mockClient.getAccountData).toHaveBeenCalledTimes(4);
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
// application metadata section rendered
2022-12-12 11:24:14 +00:00
expect(getByTestId("device-detail-metadata-application")).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("renders devices without available client information without error", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const { getByTestId, queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
// application metadata section not rendered
2022-12-12 11:24:14 +00:00
expect(queryByTestId("device-detail-metadata-application")).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("does not render other sessions section when user has only one device", async () => {
mockClient.getDevices.mockResolvedValue({ devices: [alicesDevice] });
const { queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(queryByTestId("other-sessions-section")).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("renders other sessions section when user has more than one device", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesOlderMobileDevice, alicesMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(getByTestId("other-sessions-section")).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("goes to filtered list from security recommendations", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const { getByTestId, container } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("unverified-devices-cta"));
// our session manager waits a tick for rerender
await flushPromises();
// unverified filter is set
2022-12-12 11:24:14 +00:00
expect(container.querySelector(".mx_FilteredDeviceListHeader")).toMatchSnapshot();
});
2022-12-12 11:24:14 +00:00
describe("current session section", () => {
it("disables current session context menu while devices are loading", () => {
const { getByTestId } = render(getComponent());
2022-12-12 11:24:14 +00:00
expect(getByTestId("current-session-menu").getAttribute("aria-disabled")).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("disables current session context menu when there is no current device", async () => {
mockClient.getDevices.mockResolvedValue({ devices: [] });
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(getByTestId("current-session-menu").getAttribute("aria-disabled")).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("renders current session section with an unverified session", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(getByTestId("current-session-section")).toMatchSnapshot();
});
2022-12-12 11:24:14 +00:00
it("opens encryption setup dialog when verifiying current session", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const { getByTestId } = render(getComponent());
2022-12-12 11:24:14 +00:00
const modalSpy = jest.spyOn(Modal, "createDialog");
await act(async () => {
await flushPromises();
});
// click verify button from current session section
fireEvent.click(getByTestId(`verification-status-button-${alicesDevice.device_id}`));
expect(modalSpy).toHaveBeenCalled();
});
2022-12-12 11:24:14 +00:00
it("renders current session section with a verified session", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
mockClient.getStoredDevice.mockImplementation(() => new DeviceInfo(alicesDevice.device_id));
mockCrypto.getDeviceVerificationStatus.mockResolvedValue(
new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true }),
);
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
expect(getByTestId("current-session-section")).toMatchSnapshot();
});
it("expands current session details", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
fireEvent.click(getByTestId("current-session-toggle-details"));
expect(getByTestId(`device-detail-${alicesDevice.device_id}`)).toBeTruthy();
// only one security card rendered
expect(getByTestId("current-session-section").querySelectorAll(".mx_DeviceSecurityCard").length).toEqual(1);
});
});
2022-12-12 11:24:14 +00:00
describe("device detail expansion", () => {
it("renders no devices expanded by default", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesOlderMobileDevice, alicesMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
const otherSessionsSection = getByTestId("other-sessions-section");
// no expanded device details
2022-12-12 11:24:14 +00:00
expect(otherSessionsSection.getElementsByClassName("mx_DeviceDetails").length).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("toggles device expansion on click", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesOlderMobileDevice, alicesMobileDevice],
});
const { getByTestId, queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesOlderMobileDevice.device_id);
// device details are expanded
expect(getByTestId(`device-detail-${alicesOlderMobileDevice.device_id}`)).toBeTruthy();
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
// both device details are expanded
expect(getByTestId(`device-detail-${alicesOlderMobileDevice.device_id}`)).toBeTruthy();
expect(getByTestId(`device-detail-${alicesMobileDevice.device_id}`)).toBeTruthy();
// toggle closed
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id, true);
// alicesMobileDevice was toggled off
expect(queryByTestId(`device-detail-${alicesMobileDevice.device_id}`)).toBeFalsy();
// alicesOlderMobileDevice stayed open
expect(getByTestId(`device-detail-${alicesOlderMobileDevice.device_id}`)).toBeTruthy();
});
});
2022-12-12 11:24:14 +00:00
describe("Device verification", () => {
it("does not render device verification cta when current session is not verified", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesOlderMobileDevice, alicesMobileDevice],
});
const { getByTestId, queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesOlderMobileDevice.device_id);
// verify device button is not rendered
expect(queryByTestId(`verification-status-button-${alicesOlderMobileDevice.device_id}`)).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("renders device verification cta on other sessions when current session is verified", async () => {
const modalSpy = jest.spyOn(Modal, "createDialog");
// make the current device verified
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
2022-12-12 11:24:14 +00:00
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
2022-12-12 11:24:14 +00:00
}
return new DeviceVerificationStatus({});
2022-12-12 11:24:14 +00:00
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
// click verify button from current session section
fireEvent.click(getByTestId(`verification-status-button-${alicesMobileDevice.device_id}`));
expect(mockCrypto.requestDeviceVerification).toHaveBeenCalledWith(aliceId, alicesMobileDevice.device_id);
expect(modalSpy).toHaveBeenCalled();
});
2022-12-12 11:24:14 +00:00
it("does not allow device verification on session that do not support encryption", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
2022-12-12 11:24:14 +00:00
// current session verified = able to verify other sessions
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
2022-12-12 11:24:14 +00:00
}
// but alicesMobileDevice doesn't support encryption
return null;
2022-12-12 11:24:14 +00:00
});
2022-12-12 11:24:14 +00:00
const { getByTestId, queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
// no verify button
expect(queryByTestId(`verification-status-button-${alicesMobileDevice.device_id}`)).toBeFalsy();
expect(
2022-12-12 11:24:14 +00:00
getByTestId(`device-detail-${alicesMobileDevice.device_id}`).getElementsByClassName(
"mx_DeviceSecurityCard",
),
).toMatchSnapshot();
});
2022-12-12 11:24:14 +00:00
it("refreshes devices after verifying other device", async () => {
const modalSpy = jest.spyOn(Modal, "createDialog");
// make the current device verified
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
2022-12-12 11:24:14 +00:00
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
2022-12-12 11:24:14 +00:00
}
return new DeviceVerificationStatus({});
2022-12-12 11:24:14 +00:00
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
// reset mock counter before triggering verification
mockClient.getDevices.mockClear();
// click verify button from current session section
fireEvent.click(getByTestId(`verification-status-button-${alicesMobileDevice.device_id}`));
const { onFinished: modalOnFinished } = modalSpy.mock.calls[0][1] as any;
// simulate modal completing process
await modalOnFinished();
// cancelled in case it was a failure exit from modal
expect(mockVerificationRequest.cancel).toHaveBeenCalled();
// devices refreshed
expect(mockClient.getDevices).toHaveBeenCalled();
});
});
describe("device dehydration", () => {
it("Hides a verified dehydrated device", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
const devicesMap = new Map<string, Device>([
[alicesDeviceObj.deviceId, alicesDeviceObj],
[alicesMobileDeviceObj.deviceId, alicesMobileDeviceObj],
[alicesDehydratedDeviceObj.deviceId, alicesDehydratedDeviceObj],
]);
const userDeviceMap = new Map<string, Map<string, Device>>([[aliceId, devicesMap]]);
mockCrypto.getUserDeviceInfo.mockResolvedValue(userDeviceMap);
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
// alices device is trusted
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// the dehydrated device is trusted
if (deviceId === alicesDehydratedDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// alices mobile device is not
if (deviceId === alicesMobileDevice.device_id) {
return new DeviceVerificationStatus({});
}
return null;
});
const { queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
expect(queryByTestId(`device-tile-${alicesDevice.device_id}`)).toBeTruthy();
expect(queryByTestId(`device-tile-${alicesMobileDevice.device_id}`)).toBeTruthy();
// the dehydrated device should be hidden
expect(queryByTestId(`device-tile-${alicesDehydratedDevice.device_id}`)).toBeFalsy();
});
it("Shows an unverified dehydrated device", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
const devicesMap = new Map<string, Device>([
[alicesDeviceObj.deviceId, alicesDeviceObj],
[alicesMobileDeviceObj.deviceId, alicesMobileDeviceObj],
[alicesDehydratedDeviceObj.deviceId, alicesDehydratedDeviceObj],
]);
const userDeviceMap = new Map<string, Map<string, Device>>([[aliceId, devicesMap]]);
mockCrypto.getUserDeviceInfo.mockResolvedValue(userDeviceMap);
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
// alices device is trusted
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// the dehydrated device is not
if (deviceId === alicesDehydratedDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: false, localVerified: false });
}
// alices mobile device is not
if (deviceId === alicesMobileDevice.device_id) {
return new DeviceVerificationStatus({});
}
return null;
});
const { queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
expect(queryByTestId(`device-tile-${alicesDevice.device_id}`)).toBeTruthy();
expect(queryByTestId(`device-tile-${alicesMobileDevice.device_id}`)).toBeTruthy();
// the dehydrated device should be shown since it is unverified
expect(queryByTestId(`device-tile-${alicesDehydratedDevice.device_id}`)).toBeTruthy();
});
it("Shows the dehydrated devices if there are multiple", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice, alicesOtherDehydratedDevice],
});
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
const devicesMap = new Map<string, Device>([
[alicesDeviceObj.deviceId, alicesDeviceObj],
[alicesMobileDeviceObj.deviceId, alicesMobileDeviceObj],
[alicesDehydratedDeviceObj.deviceId, alicesDehydratedDeviceObj],
[alicesOtherDehydratedDeviceObj.deviceId, alicesOtherDehydratedDeviceObj],
]);
const userDeviceMap = new Map<string, Map<string, Device>>([[aliceId, devicesMap]]);
mockCrypto.getUserDeviceInfo.mockResolvedValue(userDeviceMap);
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
// alices device is trusted
if (deviceId === alicesDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// one dehydrated device is trusted
if (deviceId === alicesDehydratedDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// the other is not
if (deviceId === alicesOtherDehydratedDevice.device_id) {
return new DeviceVerificationStatus({ crossSigningVerified: false, localVerified: false });
}
// alices mobile device is not
if (deviceId === alicesMobileDevice.device_id) {
return new DeviceVerificationStatus({});
}
return null;
});
const { queryByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
expect(queryByTestId(`device-tile-${alicesDevice.device_id}`)).toBeTruthy();
expect(queryByTestId(`device-tile-${alicesMobileDevice.device_id}`)).toBeTruthy();
// both the dehydrated devices should be shown, since there are multiple
expect(queryByTestId(`device-tile-${alicesDehydratedDevice.device_id}`)).toBeTruthy();
expect(queryByTestId(`device-tile-${alicesOtherDehydratedDevice.device_id}`)).toBeTruthy();
});
});
2022-12-12 11:24:14 +00:00
describe("Sign out", () => {
it("Signs out of current device", async () => {
const modalSpy = jest.spyOn(Modal, "createDialog");
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
2022-12-12 11:24:14 +00:00
const signOutButton = getByTestId("device-detail-sign-out-cta");
expect(signOutButton).toMatchSnapshot();
fireEvent.click(signOutButton);
// logout dialog opened
expect(modalSpy).toHaveBeenCalledWith(LogoutDialog, {}, undefined, false, true);
});
2022-12-12 11:24:14 +00:00
it("Signs out of current device from kebab menu", async () => {
const modalSpy = jest.spyOn(Modal, "createDialog");
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("current-session-menu"));
fireEvent.click(getByLabelText("Sign out"));
// logout dialog opened
expect(modalSpy).toHaveBeenCalledWith(LogoutDialog, {}, undefined, false, true);
});
2022-12-12 11:24:14 +00:00
it("does not render sign out other devices option when only one device", async () => {
2023-03-28 10:23:16 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice],
});
const { getByTestId, queryByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("current-session-menu"));
expect(queryByLabelText("Sign out of all other sessions")).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("signs out of all other devices from current session context menu", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("current-session-menu"));
fireEvent.click(getByLabelText("Sign out of all other sessions (2)"));
await confirmSignout(getByTestId);
// other devices deleted, excluding current device
2022-12-12 11:24:14 +00:00
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
[alicesMobileDevice.device_id, alicesOlderMobileDevice.device_id],
undefined,
);
});
it("removes account data events for devices after sign out", async () => {
const mobileDeviceClientInfo = new MatrixEvent({
type: getClientInformationEventType(alicesMobileDevice.device_id),
content: {
name: "test",
},
});
// @ts-ignore setup mock
mockClient.store = {
// @ts-ignore setup mock
2023-03-28 10:23:16 +00:00
accountData: new Map([[mobileDeviceClientInfo.getType(), mobileDeviceClientInfo]]),
};
mockClient.getDevices
.mockResolvedValueOnce({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
})
.mockResolvedValueOnce({
// refreshed devices after sign out
devices: [alicesDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
expect(mockClient.deleteAccountData).not.toHaveBeenCalled();
fireEvent.click(getByTestId("current-session-menu"));
fireEvent.click(getByLabelText("Sign out of all other sessions (2)"));
await confirmSignout(getByTestId);
// only called once for signed out device with account data event
expect(mockClient.deleteAccountData).toHaveBeenCalledTimes(1);
expect(mockClient.deleteAccountData).toHaveBeenCalledWith(mobileDeviceClientInfo.getType());
});
2022-12-12 11:24:14 +00:00
describe("other devices", () => {
const interactiveAuthError = new MatrixError(
{
flows: [{ stages: ["m.login.password"] }],
},
401,
);
beforeEach(() => {
mockClient.deleteMultipleDevices.mockReset();
});
2022-12-12 11:24:14 +00:00
it("deletes a device when interactive auth is not required", async () => {
mockClient.deleteMultipleDevices.mockResolvedValue({});
mockClient.getDevices
2023-03-28 10:23:16 +00:00
.mockResolvedValueOnce({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
})
// pretend it was really deleted on refresh
2023-03-28 10:23:16 +00:00
.mockResolvedValueOnce({
devices: [alicesDevice, alicesOlderMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
const deviceDetails = getByTestId(`device-detail-${alicesMobileDevice.device_id}`);
const signOutButton = deviceDetails.querySelector(
'[data-testid="device-detail-sign-out-cta"]',
) as Element;
fireEvent.click(signOutButton);
await confirmSignout(getByTestId);
// sign out button is disabled with spinner
2022-12-12 11:24:14 +00:00
expect(
(deviceDetails.querySelector('[data-testid="device-detail-sign-out-cta"]') as Element).getAttribute(
"aria-disabled",
),
).toEqual("true");
// delete called
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
2022-12-12 11:24:14 +00:00
[alicesMobileDevice.device_id],
undefined,
);
await flushPromises();
// devices refreshed
expect(mockClient.getDevices).toHaveBeenCalled();
});
2023-03-01 15:23:35 +00:00
it("does not delete a device when interactive auth is not required", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
const deviceDetails = getByTestId(`device-detail-${alicesMobileDevice.device_id}`);
const signOutButton = deviceDetails.querySelector(
'[data-testid="device-detail-sign-out-cta"]',
) as Element;
fireEvent.click(signOutButton);
await confirmSignout(getByTestId, false);
// doesnt enter loading state
2022-12-12 11:24:14 +00:00
expect(
(deviceDetails.querySelector('[data-testid="device-detail-sign-out-cta"]') as Element).getAttribute(
"aria-disabled",
),
).toEqual(null);
// delete not called
expect(mockClient.deleteMultipleDevices).not.toHaveBeenCalled();
});
2022-12-12 11:24:14 +00:00
it("deletes a device when interactive auth is required", async () => {
mockClient.deleteMultipleDevices
// require auth
.mockRejectedValueOnce(interactiveAuthError)
// then succeed
.mockResolvedValueOnce({});
mockClient.getDevices
2023-03-28 10:23:16 +00:00
.mockResolvedValueOnce({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
})
// pretend it was really deleted on refresh
2023-03-28 10:23:16 +00:00
.mockResolvedValueOnce({
devices: [alicesDevice, alicesOlderMobileDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
// reset mock count after initial load
mockClient.getDevices.mockClear();
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
const deviceDetails = getByTestId(`device-detail-${alicesMobileDevice.device_id}`);
const signOutButton = deviceDetails.querySelector(
'[data-testid="device-detail-sign-out-cta"]',
) as Element;
fireEvent.click(signOutButton);
await confirmSignout(getByTestId);
await flushPromises();
// modal rendering has some weird sleeps
await screen.findByRole("dialog");
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
2022-12-12 11:24:14 +00:00
[alicesMobileDevice.device_id],
undefined,
);
2022-12-12 11:24:14 +00:00
const modal = document.getElementsByClassName("mx_Dialog");
expect(modal.length).toBeTruthy();
// fill password and submit for interactive auth
act(() => {
2023-03-28 10:23:16 +00:00
fireEvent.change(getByLabelText("Password"), {
target: { value: "topsecret" },
});
2022-12-12 11:24:14 +00:00
fireEvent.submit(getByLabelText("Password"));
});
await flushPromises();
// called again with auth
2022-12-12 11:24:14 +00:00
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith([alicesMobileDevice.device_id], {
identifier: {
type: "m.id.user",
user: aliceId,
},
password: "",
type: "m.login.password",
});
// devices refreshed
expect(mockClient.getDevices).toHaveBeenCalled();
});
2022-12-12 11:24:14 +00:00
it("clears loading state when device deletion is cancelled during interactive auth", async () => {
mockClient.deleteMultipleDevices
// require auth
.mockRejectedValueOnce(interactiveAuthError)
// then succeed
.mockResolvedValueOnce({});
2022-12-12 11:24:14 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
const deviceDetails = getByTestId(`device-detail-${alicesMobileDevice.device_id}`);
const signOutButton = deviceDetails.querySelector(
'[data-testid="device-detail-sign-out-cta"]',
) as Element;
fireEvent.click(signOutButton);
await confirmSignout(getByTestId);
// button is loading
2022-12-12 11:24:14 +00:00
expect(
(deviceDetails.querySelector('[data-testid="device-detail-sign-out-cta"]') as Element).getAttribute(
"aria-disabled",
),
).toEqual("true");
await flushPromises();
2022-09-16 12:00:01 +00:00
// Modal rendering has some weird sleeps.
// Resetting ourselves twice in the main loop gives modal the chance to settle.
await sleep(0);
await sleep(0);
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
2022-12-12 11:24:14 +00:00
[alicesMobileDevice.device_id],
undefined,
);
2022-12-12 11:24:14 +00:00
const modal = document.getElementsByClassName("mx_Dialog");
expect(modal.length).toBeTruthy();
// cancel iau by closing modal
act(() => {
2022-12-12 11:24:14 +00:00
fireEvent.click(getByLabelText("Close dialog"));
});
await flushPromises();
// not called again
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledTimes(1);
// devices not refreshed (not called since initial fetch)
expect(mockClient.getDevices).toHaveBeenCalledTimes(1);
// loading state cleared
2022-12-12 11:24:14 +00:00
expect(
(deviceDetails.querySelector('[data-testid="device-detail-sign-out-cta"]') as Element).getAttribute(
"aria-disabled",
),
).toEqual(null);
});
2022-12-12 11:24:14 +00:00
it("deletes multiple devices", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice, alicesInactiveDevice],
});
// get a handle for resolving the delete call
// because promise flushing after the confirm modal is resolving this too
// and we want to test the loading state here
const resolveDeleteRequest = defer<IAuthData>();
mockClient.deleteMultipleDevices.mockImplementation(() => {
return resolveDeleteRequest.promise;
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
toggleDeviceSelection(getByTestId, alicesOlderMobileDevice.device_id);
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("sign-out-selection-cta"));
await confirmSignout(getByTestId);
// buttons disabled in list header
2022-12-12 11:24:14 +00:00
expect(getByTestId("sign-out-selection-cta").getAttribute("aria-disabled")).toBeTruthy();
expect(getByTestId("cancel-selection-cta").getAttribute("aria-disabled")).toBeTruthy();
// spinner rendered in list header
2022-12-12 11:24:14 +00:00
expect(getByTestId("sign-out-selection-cta").querySelector(".mx_Spinner")).toBeTruthy();
// spinners on signing out devices
2022-12-12 11:24:14 +00:00
expect(
getDeviceTile(getByTestId, alicesMobileDevice.device_id).querySelector(".mx_Spinner"),
).toBeTruthy();
expect(
getDeviceTile(getByTestId, alicesOlderMobileDevice.device_id).querySelector(".mx_Spinner"),
).toBeTruthy();
// no spinner for device that is not signing out
2022-12-12 11:24:14 +00:00
expect(
getDeviceTile(getByTestId, alicesInactiveDevice.device_id).querySelector(".mx_Spinner"),
).toBeFalsy();
// delete called with both ids
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
2022-12-12 11:24:14 +00:00
[alicesMobileDevice.device_id, alicesOlderMobileDevice.device_id],
undefined,
);
resolveDeleteRequest.resolve({});
});
it("signs out of all other devices from other sessions context menu", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
const { getByTestId, getByLabelText } = render(getComponent());
await act(async () => {
await flushPromises();
});
fireEvent.click(getByTestId("other-sessions-menu"));
fireEvent.click(getByLabelText("Sign out of 2 sessions"));
await confirmSignout(getByTestId);
// other devices deleted, excluding current device
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
[alicesMobileDevice.device_id, alicesOlderMobileDevice.device_id],
undefined,
);
});
});
describe("for an OIDC-aware server", () => {
beforeEach(() => {
OIDC: use delegated auth account URL from `OidcClientStore` (#11723) * test persistCredentials without a pickle key * test setLoggedIn with pickle key * lint * type error * extract token persisting code into function, persist refresh token * store has_refresh_token too * pass refreshToken from oidcAuthGrant into credentials * rest restore session with pickle key * retreive stored refresh token and add to credentials * extract token decryption into function * remove TODO * very messy poc * utils to persist clientId and issuer after oidc authentication * add dep oidc-client-ts * persist issuer and clientId after successful oidc auth * add OidcClientStore * comments and tidy * expose getters for stored refresh and access tokens in Lifecycle * revoke tokens with oidc provider * test logout action in MatrixChat * comments * prettier * test OidcClientStore.revokeTokens * put pickle key destruction back * comment pedantry * working refresh without persistence * extract token persistence functions to utils * add sugar * implement TokenRefresher class with persistence * tidying * persist idTokenClaims * persist idTokenClaims * tests * remove unused cde * create token refresher during doSetLoggedIn * tidying * also tidying * OidcClientStore.initClient use stored issuer when client well known unavailable * test Lifecycle.logout * update Lifecycle test replaceUsingCreds calls * fix test * add sdkContext to UserSettingsDialog * use sdkContext and oidcClientStore in session manager * use sdkContext and OidcClientStore in generalusersettingstab * tidy * test tokenrefresher creation in login flow * test token refresher * Update src/utils/oidc/TokenRefresher.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * use literal value for m.authentication Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * improve comments * fix test mock, comment * typo * add sdkContext to SoftLogout, pass oidcClientStore to logout * fullstops * comments * fussy comment formatting --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2023-10-15 23:03:25 +00:00
// just do an ugly mock here to avoid mocking initialisation
const mockOidcClientStore = {
accountManagementEndpoint: "https://issuer.org/account",
} as unknown as OidcClientStore;
jest.spyOn(sdkContext, "oidcClientStore", "get").mockReturnValue(mockOidcClientStore);
});
// signing out the current device works as usual
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 flushPromises();
});
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
const signOutButton = getByTestId("device-detail-sign-out-cta");
expect(signOutButton).toMatchSnapshot();
fireEvent.click(signOutButton);
// logout dialog opened
expect(modalSpy).toHaveBeenCalledWith(LogoutDialog, {}, undefined, false, true);
});
it("does not allow signing out of all other devices from current session context menu", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
fireEvent.click(getByTestId("current-session-menu"));
expect(screen.queryByLabelText("Sign out of all other sessions (2)")).not.toBeInTheDocument();
});
describe("other devices", () => {
it("opens delegated auth provider to sign out a single device", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
// reset call count
mockClient.getDevices.mockClear();
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
const deviceDetails = getByTestId(`device-detail-${alicesMobileDevice.device_id}`);
const signOutButton = deviceDetails.querySelector(
'[data-testid="device-detail-sign-out-cta"]',
) as Element;
fireEvent.click(signOutButton);
await screen.findByRole("dialog");
expect(
screen.getByText(
"You will be redirected to your server's authentication provider to complete sign out.",
),
).toBeInTheDocument();
// correct link to auth provider
expect(screen.getByText("Continue")).toHaveAttribute(
"href",
`https://issuer.org/account?action=session_end&device_id=${alicesMobileDevice.device_id}`,
);
// go to the link
fireEvent.click(screen.getByText("Continue"));
await flushPromises();
// come back from the link and close the modal
fireEvent.click(screen.getByText("Close"));
await flushPromises();
// devices were refreshed
expect(mockClient.getDevices).toHaveBeenCalled();
});
it("does not allow removing multiple devices at once", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice, alicesInactiveDevice],
});
render(getComponent());
await act(async () => {
await flushPromises();
});
// sessions don't have checkboxes
expect(
screen.queryByTestId(`device-tile-checkbox-${alicesMobileDevice.device_id}`),
).not.toBeInTheDocument();
// no select all
expect(screen.queryByLabelText("Select all")).not.toBeInTheDocument();
});
it("does not allow signing out of all other devices from other sessions context menu", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
render(getComponent());
await act(async () => {
await flushPromises();
});
// no context menu because 'sign out all' is the only option
// and it is not allowed when server is oidc-aware
expect(screen.queryByTestId("other-sessions-menu")).not.toBeInTheDocument();
});
});
});
});
2022-12-12 11:24:14 +00:00
describe("Rename sessions", () => {
const updateDeviceName = async (
2022-12-12 11:24:14 +00:00
getByTestId: RenderResult["getByTestId"],
device: IMyDevice,
newDeviceName: string,
) => {
toggleDeviceDetails(getByTestId, device.device_id);
// start editing
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-heading-rename-cta"));
2022-12-12 11:24:14 +00:00
const input = getByTestId("device-rename-input");
fireEvent.change(input, { target: { value: newDeviceName } });
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-rename-submit-cta"));
await flushPromises();
await flushPromises();
};
2022-12-12 11:24:14 +00:00
it("renames current session", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
const newDeviceName = "new device name";
await updateDeviceName(getByTestId, alicesDevice, newDeviceName);
2022-12-12 11:24:14 +00:00
expect(mockClient.setDeviceDetails).toHaveBeenCalledWith(alicesDevice.device_id, {
display_name: newDeviceName,
});
// devices refreshed
expect(mockClient.getDevices).toHaveBeenCalledTimes(2);
});
2022-12-12 11:24:14 +00:00
it("renames other session", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
const newDeviceName = "new device name";
await updateDeviceName(getByTestId, alicesMobileDevice, newDeviceName);
2022-12-12 11:24:14 +00:00
expect(mockClient.setDeviceDetails).toHaveBeenCalledWith(alicesMobileDevice.device_id, {
display_name: newDeviceName,
});
// devices refreshed
expect(mockClient.getDevices).toHaveBeenCalledTimes(2);
});
2022-12-12 11:24:14 +00:00
it("does not rename session or refresh devices is session name is unchanged", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
await updateDeviceName(getByTestId, alicesDevice, alicesDevice.display_name);
expect(mockClient.setDeviceDetails).not.toHaveBeenCalled();
// only called once on initial load
expect(mockClient.getDevices).toHaveBeenCalledTimes(1);
});
2022-12-12 11:24:14 +00:00
it("saves an empty session display name successfully", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
await updateDeviceName(getByTestId, alicesDevice, "");
2023-03-28 10:23:16 +00:00
expect(mockClient.setDeviceDetails).toHaveBeenCalledWith(alicesDevice.device_id, {
display_name: "",
});
});
2022-12-12 11:24:14 +00:00
it("displays an error when session display name fails to save", async () => {
const logSpy = jest.spyOn(logger, "error");
const error = new Error("oups");
mockClient.setDeviceDetails.mockRejectedValue(error);
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
const newDeviceName = "new device name";
await updateDeviceName(getByTestId, alicesDevice, newDeviceName);
await flushPromises();
expect(logSpy).toHaveBeenCalledWith("Error setting device name", error);
// error displayed
2022-12-12 11:24:14 +00:00
expect(getByTestId("device-rename-error")).toBeTruthy();
});
});
2022-12-12 11:24:14 +00:00
describe("Multiple selection", () => {
beforeEach(() => {
2022-12-12 11:24:14 +00:00
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
});
});
2022-12-12 11:24:14 +00:00
it("toggles session selection", async () => {
const { getByTestId, getByText } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
toggleDeviceSelection(getByTestId, alicesOlderMobileDevice.device_id);
// header displayed correctly
2022-12-12 11:24:14 +00:00
expect(getByText("2 sessions selected")).toBeTruthy();
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeTruthy();
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeTruthy();
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
// unselected
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeFalsy();
// still selected
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("cancel button clears selection", async () => {
const { getByTestId, getByText } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
toggleDeviceSelection(getByTestId, alicesOlderMobileDevice.device_id);
// header displayed correctly
2022-12-12 11:24:14 +00:00
expect(getByText("2 sessions selected")).toBeTruthy();
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("cancel-selection-cta"));
// unselected
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeFalsy();
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
it("changing the filter clears selection", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeTruthy();
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("unverified-devices-cta"));
// our session manager waits a tick for rerender
await flushPromises();
// unselected
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeFalsy();
});
2022-12-12 11:24:14 +00:00
describe("toggling select all", () => {
it("selects all sessions when there is not existing selection", async () => {
const { getByTestId, getByText } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-select-all-checkbox"));
// header displayed correctly
2022-12-12 11:24:14 +00:00
expect(getByText("2 sessions selected")).toBeTruthy();
expect(isSelectAllChecked(getByTestId)).toBeTruthy();
// devices selected
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeTruthy();
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("selects all sessions when some sessions are already selected", async () => {
const { getByTestId, getByText } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceSelection(getByTestId, alicesMobileDevice.device_id);
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-select-all-checkbox"));
// header displayed correctly
2022-12-12 11:24:14 +00:00
expect(getByText("2 sessions selected")).toBeTruthy();
expect(isSelectAllChecked(getByTestId)).toBeTruthy();
// devices selected
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeTruthy();
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("deselects all sessions when all sessions are selected", async () => {
const { getByTestId, getByText } = render(getComponent());
await act(async () => {
await flushPromises();
});
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-select-all-checkbox"));
// header displayed correctly
2022-12-12 11:24:14 +00:00
expect(getByText("2 sessions selected")).toBeTruthy();
expect(isSelectAllChecked(getByTestId)).toBeTruthy();
// devices selected
expect(isDeviceSelected(getByTestId, alicesMobileDevice.device_id)).toBeTruthy();
expect(isDeviceSelected(getByTestId, alicesOlderMobileDevice.device_id)).toBeTruthy();
});
2022-12-12 11:24:14 +00:00
it("selects only sessions that are part of the active filter", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesInactiveDevice],
});
const { getByTestId, container } = render(getComponent());
await act(async () => {
await flushPromises();
});
// filter for inactive sessions
await setFilter(container, DeviceSecurityVariation.Inactive);
// select all inactive sessions
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("device-select-all-checkbox"));
expect(isSelectAllChecked(getByTestId)).toBeTruthy();
// sign out of all selected sessions
2022-12-12 11:24:14 +00:00
fireEvent.click(getByTestId("sign-out-selection-cta"));
await confirmSignout(getByTestId);
// only called with session from active filter
expect(mockClient.deleteMultipleDevices).toHaveBeenCalledWith(
2022-12-12 11:24:14 +00:00
[alicesInactiveDevice.device_id],
undefined,
);
});
});
});
it("lets you change the pusher state", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesMobileDevice.device_id);
// device details are expanded
expect(getByTestId(`device-detail-${alicesMobileDevice.device_id}`)).toBeTruthy();
2022-12-12 11:24:14 +00:00
expect(getByTestId("device-detail-push-notification")).toBeTruthy();
2022-12-12 11:24:14 +00:00
const checkbox = getByTestId("device-detail-push-notification-checkbox");
expect(checkbox).toBeTruthy();
fireEvent.click(checkbox);
expect(mockClient.setPusher).toHaveBeenCalled();
});
it("lets you change the local notification settings state", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
// device details are expanded
expect(getByTestId(`device-detail-${alicesDevice.device_id}`)).toBeTruthy();
2022-12-12 11:24:14 +00:00
expect(getByTestId("device-detail-push-notification")).toBeTruthy();
2022-12-12 11:24:14 +00:00
const checkbox = getByTestId("device-detail-push-notification-checkbox");
expect(checkbox).toBeTruthy();
fireEvent.click(checkbox);
2022-12-12 11:24:14 +00:00
expect(mockClient.setLocalNotificationSettings).toHaveBeenCalledWith(alicesDevice.device_id, {
is_silenced: true,
});
});
it("updates the UI when another session changes the local notifications", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {
await flushPromises();
});
toggleDeviceDetails(getByTestId, alicesDevice.device_id);
// device details are expanded
expect(getByTestId(`device-detail-${alicesDevice.device_id}`)).toBeTruthy();
2022-12-12 11:24:14 +00:00
expect(getByTestId("device-detail-push-notification")).toBeTruthy();
2022-12-12 11:24:14 +00:00
const checkbox = getByTestId("device-detail-push-notification-checkbox");
expect(checkbox).toBeTruthy();
2022-12-12 11:24:14 +00:00
expect(checkbox.getAttribute("aria-checked")).toEqual("true");
const evt = new MatrixEvent({
type: LOCAL_NOTIFICATION_SETTINGS_PREFIX.name + "." + alicesDevice.device_id,
content: {
is_silenced: true,
},
});
await act(async () => {
mockClient.emit(ClientEvent.AccountData, evt);
});
2022-12-12 11:24:14 +00:00
expect(checkbox.getAttribute("aria-checked")).toEqual("false");
});
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
2022-12-12 11:24:14 +00:00
describe("QR code login", () => {
const settingsValueSpy = jest.spyOn(SettingsStore, "getValue");
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
beforeEach(() => {
settingsValueSpy.mockClear().mockReturnValue(false);
// enable server support for qr login
mockClient.getVersions.mockResolvedValue({
versions: [],
unstable_features: {
2022-12-12 11:24:14 +00:00
"org.matrix.msc3886": true,
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
},
});
mockClient.getCapabilities.mockResolvedValue({
[GET_LOGIN_TOKEN_CAPABILITY.name]: {
enabled: true,
},
});
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
});
it("renders qr code login section", async () => {
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
const { getByText } = render(getComponent());
// wait for versions call to settle
await flushPromises();
expect(getByText("Link new device")).toBeTruthy();
expect(getByText("Show QR code")).toBeTruthy();
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
});
2022-12-12 11:24:14 +00:00
it("enters qr code login section when show QR code button clicked", async () => {
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
const { getByText, getByTestId } = render(getComponent());
// wait for versions call to settle
await flushPromises();
2022-12-12 11:24:14 +00:00
fireEvent.click(getByText("Show QR code"));
Test display of qr code login section (#9456) * Support for login + E2EE set up with QR * Whitespace * Padding * Refactor of fetch * Whitespace * CSS whitespace * Add link to MSC3906 * Handle incorrect typing in MatrixClientPeg.get() * Use unstable class name * fix: use unstable class name * Use default fetch client instead * Update to revised function name * Refactor device manager panel and make it work with new sessions manager * Lint fix * Add missing interstitials and update wording * Linting * i18n * Lint * Use sensible sdk config name for fallback server * Improve error handling for QR code generation * Refactor feature availability logic * Hide device manager panel if no options available * Put sign in with QR behind lab setting * Reduce scope of PR to just showing code on existing device * i18n updates * Handle null features * Testing for LoginWithQRSection * Refactor to handle UIA * Imports * Reduce diff complexity * Remove unnecessary change * Remove unused styles * Support UIA * Tidy up * i18n * Remove additional unused parts of flow * Add extra instruction when showing QR code * Add getVersions to server mocks * Use proper colours for theme support * Test cases * Lint * Remove obsolete snapshot * Don't override error if already set * Remove unused var * Update src/components/views/settings/devices/LoginWithQRSection.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/auth/LoginWithQR.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update res/css/views/auth/_LoginWithQR.pcss Co-authored-by: Kerry <kerrya@element.io> * Use spacing variables * Remove debug * Style + docs * preventDefault * Names of tests * Fixes for js-sdk refactor * Update snapshots to match test names * Refactor labs config to make deployment simpler * i18n * Unused imports * Typo * Stateless component * Whitespace * Use context not MatrixClientPeg * Add missing context * Type updates to match js-sdk * Wrap click handlers in useCallback * Update src/components/views/settings/DevicesPanel.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Wait for DOM update instead of timeout * Add missing snapshot update from last commit * Remove void keyword in favour of then() clauses * test main paths in LoginWithQR * test coverage for display of qr code section * remove unused test props Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-10-19 15:11:42 +00:00
expect(getByTestId("login-with-qr")).toBeTruthy();
});
});
});