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" />
|
|
|
|
|
|
|
|
import { SynapseInstance } from "../../plugins/synapsedocker";
|
|
|
|
import type { UserCredentials } from "../../support/login";
|
|
|
|
|
|
|
|
describe("Device manager", () => {
|
|
|
|
let synapse: SynapseInstance | undefined;
|
|
|
|
let user: UserCredentials | undefined;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.enableLabsFeature("feature_new_device_manager");
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.startSynapse("default").then((data) => {
|
2022-10-13 09:27:48 +02:00
|
|
|
synapse = data;
|
|
|
|
|
2022-12-12 12:24:14 +01:00
|
|
|
cy.initTestUser(synapse, "Alice")
|
|
|
|
.then((credentials) => {
|
|
|
|
user = credentials;
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
// create some extra sessions to manage
|
|
|
|
return cy.loginUser(synapse, user.username, user.password);
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
return cy.loginUser(synapse, user.username, user.password);
|
|
|
|
});
|
2022-10-13 09:27:48 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
cy.stopSynapse(synapse!);
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
|
cy.get(".mx_DeviceDetailHeading h3").should("have.text", sessionName);
|
|
|
|
// 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
|
|
|
});
|
|
|
|
});
|