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