2022-10-13 10:27:48 +03: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 02:29:56 +03:00
|
|
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
2022-10-13 10:27:48 +03:00
|
|
|
import type { UserCredentials } from "../../support/login";
|
|
|
|
|
|
|
|
describe("Device manager", () => {
|
2023-01-11 02:29:56 +03:00
|
|
|
let homeserver: HomeserverInstance | undefined;
|
2022-10-13 10:27:48 +03:00
|
|
|
let user: UserCredentials | undefined;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.enableLabsFeature("feature_new_device_manager");
|
2023-01-11 02:29:56 +03:00
|
|
|
cy.startHomeserver("default").then((data) => {
|
|
|
|
homeserver = data;
|
2022-10-13 10:27:48 +03:00
|
|
|
|
2023-01-11 02:29:56 +03:00
|
|
|
cy.initTestUser(homeserver, "Alice")
|
2022-10-13 10:27:48 +03:00
|
|
|
.then((credentials) => {
|
|
|
|
user = credentials;
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
// create some extra sessions to manage
|
2023-01-11 02:29:56 +03:00
|
|
|
return cy.loginUser(homeserver, user.username, user.password);
|
2022-10-13 10:27:48 +03:00
|
|
|
})
|
|
|
|
.then(() => {
|
2023-01-11 02:29:56 +03:00
|
|
|
return cy.loginUser(homeserver, user.username, user.password);
|
2022-10-13 10:27:48 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2023-01-11 02:29:56 +03:00
|
|
|
cy.stopHomeserver(homeserver!);
|
2022-10-13 10:27:48 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should display sessions", () => {
|
|
|
|
cy.openUserSettings("Sessions");
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByText("Current session").should("exist");
|
2022-10-13 10:27:48 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByTestId("current-session-section").within(() => {
|
|
|
|
cy.findByText("Unverified session").should("exist");
|
2022-10-13 10:27:48 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
// current session details opened
|
|
|
|
cy.findByRole("button", { name: "Show details" }).click();
|
|
|
|
cy.findByText("Session details").should("exist");
|
2022-10-13 10:27:48 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
// close current session details
|
|
|
|
cy.findByRole("button", { name: "Hide details" }).click();
|
|
|
|
cy.findByText("Session details").should("not.exist");
|
|
|
|
});
|
2022-10-13 10:27:48 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByTestId("security-recommendations-section").within(() => {
|
|
|
|
cy.findByText("Security recommendations").should("exist");
|
|
|
|
cy.findByRole("button", { name: "View all (3)" }).click();
|
2022-10-13 10:27:48 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Other sessions section
|
|
|
|
*/
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByText("Other sessions").should("exist");
|
2022-10-13 10:27:48 +03:00
|
|
|
// filter applied after clicking through from security recommendations
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByLabelText("Filter devices").should("have.text", "Show: Unverified");
|
|
|
|
cy.get(".mx_FilteredDeviceList_list").within(() => {
|
|
|
|
cy.get(".mx_FilteredDeviceList_listItem").should("have.length", 3);
|
|
|
|
|
|
|
|
// select two sessions
|
|
|
|
cy.get(".mx_FilteredDeviceList_listItem")
|
|
|
|
.first()
|
|
|
|
.within(() => {
|
|
|
|
// force click as the input element itself is not visible (its size is zero)
|
|
|
|
cy.findByRole("checkbox").click({ force: true });
|
|
|
|
});
|
|
|
|
cy.get(".mx_FilteredDeviceList_listItem")
|
|
|
|
.last()
|
|
|
|
.within(() => {
|
|
|
|
// force click as the input element itself is not visible (its size is zero)
|
|
|
|
cy.findByRole("checkbox").click({ force: true });
|
|
|
|
});
|
|
|
|
});
|
2022-10-13 10:27:48 +03:00
|
|
|
// sign out from list selection action buttons
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByRole("button", { name: "Sign out" }).click();
|
|
|
|
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
|
|
|
|
cy.findByRole("button", { name: "Sign out" }).click();
|
|
|
|
});
|
2022-10-13 10:27:48 +03:00
|
|
|
// list updated after sign out
|
|
|
|
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 1);
|
|
|
|
// security recommendation count updated
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByRole("button", { name: "View all (1)" });
|
2022-10-13 10:27:48 +03:00
|
|
|
|
|
|
|
const sessionName = `Alice's device`;
|
2022-10-14 14:43:20 +03:00
|
|
|
// open the first session
|
2022-10-13 10:27:48 +03:00
|
|
|
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem")
|
|
|
|
.first()
|
|
|
|
.within(() => {
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByRole("button", { name: "Show details" }).click();
|
2022-12-12 14:24:14 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByText("Session details").should("exist");
|
2022-12-12 14:24:14 +03:00
|
|
|
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByRole("button", { name: "Rename" }).click();
|
|
|
|
cy.findByTestId("device-rename-input").type(sessionName);
|
|
|
|
cy.findByRole("button", { name: "Save" }).click();
|
2022-10-13 10:27:48 +03:00
|
|
|
// 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 14:24:14 +03:00
|
|
|
|
2022-10-13 10:27:48 +03:00
|
|
|
// session name updated in details
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.get(".mx_DeviceDetailHeading h4").within(() => {
|
|
|
|
cy.findByText(sessionName);
|
|
|
|
});
|
2022-10-13 10:27:48 +03:00
|
|
|
// and main list item
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.get(".mx_DeviceTile h4").within(() => {
|
|
|
|
cy.findByText(sessionName);
|
|
|
|
});
|
2022-12-12 14:24:14 +03:00
|
|
|
|
2022-10-13 10:27:48 +03:00
|
|
|
// sign out using the device details sign out
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByRole("button", { name: "Sign out of this session" }).click();
|
2022-10-13 10:27:48 +03:00
|
|
|
});
|
2022-10-25 11:39:48 +03:00
|
|
|
// confirm the signout
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
|
|
|
|
cy.findByRole("button", { name: "Sign out" }).click();
|
|
|
|
});
|
2022-10-13 10:27:48 +03:00
|
|
|
|
|
|
|
// no other sessions or security recommendations sections when only one session
|
2023-04-12 18:58:28 +03:00
|
|
|
cy.findByText("Other sessions").should("not.exist");
|
|
|
|
cy.findByTestId("security-recommendations-section").should("not.exist");
|
2022-10-13 10:27:48 +03:00
|
|
|
});
|
|
|
|
});
|