2022-10-13 15:27:48 +08:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
2023-01-11 07:29:56 +08:00
|
|
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
2022-10-13 15:27:48 +08:00
|
|
|
import type { UserCredentials } from "../../support/login";
|
|
|
|
|
|
|
|
describe("Device manager", () => {
|
2023-01-11 07:29:56 +08:00
|
|
|
let homeserver: HomeserverInstance | undefined;
|
2022-10-13 15:27:48 +08:00
|
|
|
let user: UserCredentials | undefined;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.enableLabsFeature("feature_new_device_manager");
|
2023-01-11 07:29:56 +08:00
|
|
|
cy.startHomeserver("default").then((data) => {
|
|
|
|
homeserver = data;
|
2022-10-13 15:27:48 +08:00
|
|
|
|
2023-01-11 07:29:56 +08:00
|
|
|
cy.initTestUser(homeserver, "Alice")
|
2022-10-13 15:27:48 +08:00
|
|
|
.then((credentials) => {
|
|
|
|
user = credentials;
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
// create some extra sessions to manage
|
2023-01-11 07:29:56 +08:00
|
|
|
return cy.loginUser(homeserver, user.username, user.password);
|
2022-10-13 15:27:48 +08:00
|
|
|
})
|
|
|
|
.then(() => {
|
2023-01-11 07:29:56 +08:00
|
|
|
return cy.loginUser(homeserver, user.username, user.password);
|
2022-10-13 15:27:48 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2023-01-11 07:29:56 +08:00
|
|
|
cy.stopHomeserver(homeserver!);
|
2022-10-13 15:27:48 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should display sessions", () => {
|
|
|
|
cy.openUserSettings("Sessions");
|
|
|
|
cy.contains("Current session").should("exist");
|
|
|
|
|
|
|
|
cy.get('[data-testid="current-session-section"]').within(() => {
|
|
|
|
cy.contains("Unverified session").should("exist");
|
|
|
|
});
|
|
|
|
|
|
|
|
// current session details opened
|
|
|
|
cy.get('[data-testid="current-session-toggle-details"]').click();
|
|
|
|
cy.contains("Session details").should("exist");
|
|
|
|
|
|
|
|
// close current session details
|
|
|
|
cy.get('[data-testid="current-session-toggle-details"]').click();
|
|
|
|
cy.contains("Session details").should("not.exist");
|
|
|
|
|
|
|
|
cy.get('[data-testid="security-recommendations-section"]').within(() => {
|
|
|
|
cy.contains("Security recommendations").should("exist");
|
|
|
|
cy.get('[data-testid="unverified-devices-cta"]').should("have.text", "View all (3)").click();
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Other sessions section
|
|
|
|
*/
|
|
|
|
cy.contains("Other sessions").should("exist");
|
|
|
|
// filter applied after clicking through from security recommendations
|
|
|
|
cy.get('[aria-label="Filter devices"]').should("have.text", "Show: Unverified");
|
|
|
|
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 3);
|
|
|
|
|
|
|
|
// select two sessions
|
2022-10-14 19:43:20 +08:00
|
|
|
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem .mx_Checkbox").first().click();
|
|
|
|
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem .mx_Checkbox").last().click();
|
2022-10-13 15:27:48 +08:00
|
|
|
// sign out from list selection action buttons
|
|
|
|
cy.get('[data-testid="sign-out-selection-cta"]').click();
|
2022-10-25 16:39:48 +08:00
|
|
|
cy.get('[data-testid="dialog-primary-button"]').click();
|
2022-10-13 15:27:48 +08:00
|
|
|
// list updated after sign out
|
|
|
|
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 1);
|
|
|
|
// security recommendation count updated
|
|
|
|
cy.get('[data-testid="unverified-devices-cta"]').should("have.text", "View all (1)");
|
|
|
|
|
|
|
|
const sessionName = `Alice's device`;
|
2022-10-14 19:43:20 +08:00
|
|
|
// open the first session
|
2022-10-13 15:27:48 +08:00
|
|
|
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem")
|
|
|
|
.first()
|
|
|
|
.within(() => {
|
2022-11-21 03:24:56 +08:00
|
|
|
cy.get('[aria-label="Show details"]').click();
|
2022-12-12 19:24:14 +08:00
|
|
|
|
2022-10-13 15:27:48 +08:00
|
|
|
cy.contains("Session details").should("exist");
|
2022-12-12 19:24:14 +08:00
|
|
|
|
2022-10-13 15:27:48 +08:00
|
|
|
cy.get('[data-testid="device-heading-rename-cta"]').click();
|
|
|
|
cy.get('[data-testid="device-rename-input"]').type(sessionName);
|
|
|
|
cy.get('[data-testid="device-rename-submit-cta"]').click();
|
|
|
|
// there should be a spinner while device updates
|
|
|
|
cy.get(".mx_Spinner").should("exist");
|
|
|
|
// wait for spinner to complete
|
|
|
|
cy.get(".mx_Spinner").should("not.exist");
|
2022-12-12 19:24:14 +08:00
|
|
|
|
2022-10-13 15:27:48 +08:00
|
|
|
// session name updated in details
|
2022-12-20 09:17:05 +08:00
|
|
|
cy.get(".mx_DeviceDetailHeading h4").should("have.text", sessionName);
|
2022-10-13 15:27:48 +08:00
|
|
|
// and main list item
|
|
|
|
cy.get(".mx_DeviceTile h4").should("have.text", sessionName);
|
2022-12-12 19:24:14 +08:00
|
|
|
|
2022-10-13 15:27:48 +08:00
|
|
|
// sign out using the device details sign out
|
|
|
|
cy.get('[data-testid="device-detail-sign-out-cta"]').click();
|
|
|
|
});
|
2022-10-25 16:39:48 +08:00
|
|
|
// confirm the signout
|
|
|
|
cy.get('[data-testid="dialog-primary-button"]').click();
|
2022-10-13 15:27:48 +08:00
|
|
|
|
|
|
|
// no other sessions or security recommendations sections when only one session
|
|
|
|
cy.contains("Other sessions").should("not.exist");
|
|
|
|
cy.get('[data-testid="security-recommendations-section"]').should("not.exist");
|
|
|
|
});
|
|
|
|
});
|