Migrate settings/* from Cypress to Playwright (#11949)

* Migrate location.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate location.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate appearance-user-settings-tab.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate device-management.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate general-room-settings-tab.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate general-user-settings-tab.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate preferences-user-settings-tab.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Migrate security-user-settings-tab.spec.ts from Cypress to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add screenshots

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add screenshot

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Deflake

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update screenshots

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Update screenshots

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Move settings into subclass

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2023-11-29 13:50:13 +00:00 committed by GitHub
parent 8b7f49e74e
commit 1b3f473c10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 861 additions and 961 deletions

View file

@ -1,304 +0,0 @@
/*
Copyright 2023 Suguru Hirahara
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
import { SettingLevel } from "../../../src/settings/SettingLevel";
describe("Appearance user settings tab", () => {
let homeserver: HomeserverInstance;
beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Hanako");
});
});
afterEach(() => {
cy.stopHomeserver(homeserver);
});
it("should be rendered properly", () => {
cy.openUserSettings("Appearance");
cy.findByTestId("mx_AppearanceUserSettingsTab").within(() => {
cy.get("h2").should("have.text", "Customise your appearance").should("be.visible");
});
cy.findByTestId("mx_AppearanceUserSettingsTab").percySnapshotElement(
"User settings tab - Appearance (advanced options collapsed)",
{
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
},
);
// Click "Show advanced" link button
cy.findByRole("button", { name: "Show advanced" }).click();
// Assert that "Hide advanced" link button is rendered
cy.findByRole("button", { name: "Hide advanced" }).should("exist");
cy.findByTestId("mx_AppearanceUserSettingsTab").percySnapshotElement(
"User settings tab - Appearance (advanced options expanded)",
{
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
},
);
});
it("should support switching layouts", () => {
// Create and view a room first
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room");
cy.openUserSettings("Appearance");
cy.get(".mx_LayoutSwitcher_RadioButtons").within(() => {
// Assert that the layout selected by default is "Modern"
cy.get(".mx_LayoutSwitcher_RadioButton_selected .mx_StyledRadioButton_enabled").within(() => {
cy.findByLabelText("Modern").should("exist");
});
});
// Assert that the room layout is set to group (modern) layout
cy.get(".mx_RoomView_body[data-layout='group']").should("exist");
cy.get(".mx_LayoutSwitcher_RadioButtons").within(() => {
// Select the first layout
cy.get(".mx_LayoutSwitcher_RadioButton").first().click();
// Assert that the layout selected is "IRC (Experimental)"
cy.get(".mx_LayoutSwitcher_RadioButton_selected .mx_StyledRadioButton_enabled").within(() => {
cy.findByLabelText("IRC (Experimental)").should("exist");
});
});
// Assert that the room layout is set to IRC layout
cy.get(".mx_RoomView_body[data-layout='irc']").should("exist");
cy.get(".mx_LayoutSwitcher_RadioButtons").within(() => {
// Select the last layout
cy.get(".mx_LayoutSwitcher_RadioButton").last().click();
// Assert that the layout selected is "Message bubbles"
cy.get(".mx_LayoutSwitcher_RadioButton_selected .mx_StyledRadioButton_enabled").within(() => {
cy.findByLabelText("Message bubbles").should("exist");
});
});
// Assert that the room layout is set to bubble layout
cy.get(".mx_RoomView_body[data-layout='bubble']").should("exist");
});
it("should support changing font size by clicking the font slider", () => {
cy.openUserSettings("Appearance");
cy.findByTestId("mx_AppearanceUserSettingsTab").within(() => {
cy.get(".mx_FontScalingPanel_fontSlider").within(() => {
cy.findByLabelText("Font size").should("exist");
});
cy.get(".mx_FontScalingPanel_fontSlider").within(() => {
// Click the left position of the slider
cy.get("input").realClick({ position: "left" });
const MIN_FONT_SIZE = 11;
// Assert that the smallest font size is selected
cy.get(`input[value='${MIN_FONT_SIZE}']`).should("exist");
cy.get("output .mx_Slider_selection_label").findByText(MIN_FONT_SIZE);
});
cy.get(".mx_FontScalingPanel_fontSlider").percySnapshotElement("Font size slider - smallest (13)", {
widths: [486], // actual size (content-box, including inline padding)
});
cy.get(".mx_FontScalingPanel_fontSlider").within(() => {
// Click the right position of the slider
cy.get("input").realClick({ position: "right" });
const MAX_FONT_SIZE = 21;
// Assert that the largest font size is selected
cy.get(`input[value='${MAX_FONT_SIZE}']`).should("exist");
cy.get("output .mx_Slider_selection_label").findByText(MAX_FONT_SIZE);
});
cy.get(".mx_FontScalingPanel_fontSlider").percySnapshotElement("Font size slider - largest (21)", {
widths: [486],
});
});
});
it("should disable font size slider when custom font size is used", () => {
cy.openUserSettings("Appearance");
cy.findByTestId("mx_FontScalingPanel").within(() => {
cy.findByLabelText("Use custom size").click({ force: true }); // force click as checkbox size is zero
// Assert that the font slider is disabled
cy.get(".mx_FontScalingPanel_fontSlider input[disabled]").should("exist");
});
});
it("should support enabling compact group (modern) layout", () => {
// Create and view a room first
cy.createRoom({ name: "Test Room" }).viewRoomByName("Test Room");
cy.openUserSettings("Appearance");
// Click "Show advanced" link button
cy.findByRole("button", { name: "Show advanced" }).click();
// force click as checkbox size is zero
cy.findByLabelText("Use a more compact 'Modern' layout").click({ force: true });
// Assert that the room layout is set to compact group (modern) layout
cy.get("#matrixchat .mx_MatrixChat_wrapper.mx_MatrixChat_useCompactLayout").should("exist");
});
it("should disable compact group (modern) layout option on IRC layout and bubble layout", () => {
const checkDisabled = () => {
cy.findByLabelText("Use a more compact 'Modern' layout").should("be.disabled");
};
cy.openUserSettings("Appearance");
// Click "Show advanced" link button
cy.findByRole("button", { name: "Show advanced" }).click();
// Enable IRC layout
cy.get(".mx_LayoutSwitcher_RadioButtons").within(() => {
// Select the first layout
cy.get(".mx_LayoutSwitcher_RadioButton").first().click();
// Assert that the layout selected is "IRC (Experimental)"
cy.get(".mx_LayoutSwitcher_RadioButton_selected .mx_StyledRadioButton_enabled").within(() => {
cy.findByLabelText("IRC (Experimental)").should("exist");
});
});
checkDisabled();
// Enable bubble layout
cy.get(".mx_LayoutSwitcher_RadioButtons").within(() => {
// Select the first layout
cy.get(".mx_LayoutSwitcher_RadioButton").last().click();
// Assert that the layout selected is "IRC (Experimental)"
cy.get(".mx_LayoutSwitcher_RadioButton_selected .mx_StyledRadioButton_enabled").within(() => {
cy.findByLabelText("Message bubbles").should("exist");
});
});
checkDisabled();
});
it("should support enabling system font", () => {
cy.openUserSettings("Appearance");
// Click "Show advanced" link button
cy.findByRole("button", { name: "Show advanced" }).click();
// force click as checkbox size is zero
cy.findByLabelText("Use bundled emoji font").click({ force: true });
cy.findByLabelText("Use a system font").click({ force: true });
// Assert that the font-family value was removed
cy.get("body").should("have.css", "font-family", '""');
});
describe("Theme Choice Panel", () => {
beforeEach(() => {
// Disable the default theme for consistency in case ThemeWatcher automatically chooses it
cy.setSettingValue("use_system_theme", null, SettingLevel.DEVICE, false);
});
it("should be rendered with the light theme selected", () => {
cy.openUserSettings("Appearance")
.findByTestId("mx_ThemeChoicePanel")
.within(() => {
cy.findByTestId("checkbox-use-system-theme").within(() => {
cy.findByText("Match system theme").should("be.visible");
// Assert that 'Match system theme' is not checked
// Note that mx_Checkbox_checkmark exists and is hidden by CSS if it is not checked
cy.get(".mx_Checkbox_checkmark").should("not.be.visible");
});
cy.findByTestId("theme-choice-panel-selectors").within(() => {
cy.get(".mx_ThemeSelector_light").should("exist");
cy.get(".mx_ThemeSelector_dark").should("exist");
// Assert that the light theme is selected
cy.get(".mx_ThemeSelector_light.mx_StyledRadioButton_enabled").should("exist");
// Assert that the buttons for the light and dark theme are not enabled
cy.get(".mx_ThemeSelector_light.mx_StyledRadioButton_disabled").should("not.exist");
cy.get(".mx_ThemeSelector_dark.mx_StyledRadioButton_disabled").should("not.exist");
});
// Assert that the checkbox for the high contrast theme is rendered
cy.findByLabelText("Use high contrast").should("exist");
});
});
it(
"should disable the labels for themes and the checkbox for the high contrast theme if the checkbox for " +
"the system theme is clicked",
() => {
cy.openUserSettings("Appearance")
.findByTestId("mx_ThemeChoicePanel")
.findByLabelText("Match system theme")
.click({ force: true }); // force click because the size of the checkbox is zero
cy.findByTestId("mx_ThemeChoicePanel").within(() => {
// Assert that the labels for the light theme and dark theme are disabled
cy.get(".mx_ThemeSelector_light.mx_StyledRadioButton_disabled").should("exist");
cy.get(".mx_ThemeSelector_dark.mx_StyledRadioButton_disabled").should("exist");
// Assert that there does not exist a label for an enabled theme
cy.get("label.mx_StyledRadioButton_enabled").should("not.exist");
// Assert that the checkbox and label to enable the the high contrast theme should not exist
cy.findByLabelText("Use high contrast").should("not.exist");
});
},
);
it(
"should not render the checkbox and the label for the high contrast theme " +
"if the dark theme is selected",
() => {
cy.openUserSettings("Appearance");
// Assert that the checkbox and the label to enable the high contrast theme should exist
cy.findByLabelText("Use high contrast").should("exist");
// Enable the dark theme
cy.get(".mx_ThemeSelector_dark").click();
// Assert that the checkbox and the label should not exist
cy.findByLabelText("Use high contrast").should("not.exist");
},
);
});
});

View file

@ -1,140 +0,0 @@
/*
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
import type { UserCredentials } from "../../support/login";
describe("Device manager", () => {
let homeserver: HomeserverInstance | undefined;
let user: UserCredentials | undefined;
beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Alice")
.then((credentials) => {
user = credentials;
})
.then(() => {
// create some extra sessions to manage
return cy.loginUser(homeserver, user.username, user.password);
})
.then(() => {
return cy.loginUser(homeserver, user.username, user.password);
});
});
});
afterEach(() => {
cy.stopHomeserver(homeserver!);
});
it("should display sessions", () => {
cy.openUserSettings("Sessions");
cy.findByText("Current session").should("exist");
cy.findByTestId("current-session-section").within(() => {
cy.findByText("Unverified session").should("exist");
// current session details opened
cy.findByRole("button", { name: "Show details" }).click();
cy.findByText("Session details").should("exist");
// close current session details
cy.findByRole("button", { name: "Hide details" }).click();
cy.findByText("Session details").should("not.exist");
});
cy.findByTestId("security-recommendations-section").within(() => {
cy.findByText("Security recommendations").should("exist");
cy.findByRole("button", { name: "View all (3)" }).click();
});
/**
* Other sessions section
*/
cy.findByText("Other sessions").should("exist");
// filter applied after clicking through from security recommendations
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 });
});
});
// sign out from list selection action buttons
cy.findByRole("button", { name: "Sign out" }).click();
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
cy.findByRole("button", { name: "Sign out" }).click();
});
// list updated after sign out
cy.get(".mx_FilteredDeviceList_list").find(".mx_FilteredDeviceList_listItem").should("have.length", 1);
// security recommendation count updated
cy.findByRole("button", { name: "View all (1)" });
const sessionName = `Alice's device`;
// open the first session
cy.get(".mx_FilteredDeviceList_list .mx_FilteredDeviceList_listItem")
.first()
.within(() => {
cy.findByRole("button", { name: "Show details" }).click();
cy.findByText("Session details").should("exist");
cy.findByRole("button", { name: "Rename" }).click();
cy.findByTestId("device-rename-input").type(sessionName);
cy.findByRole("button", { name: "Save" }).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 h4").within(() => {
cy.findByText(sessionName);
});
// and main list item
cy.get(".mx_DeviceTile h4").within(() => {
cy.findByText(sessionName);
});
// sign out using the device details sign out
cy.findByRole("button", { name: "Sign out of this session" }).click();
});
// confirm the signout
cy.get(".mx_Dialog .mx_QuestionDialog").within(() => {
cy.findByRole("button", { name: "Sign out" }).click();
});
// no other sessions or security recommendations sections when only one session
cy.findByText("Other sessions").should("not.exist");
cy.findByTestId("security-recommendations-section").should("not.exist");
});
});

View file

@ -1,97 +0,0 @@
/*
Copyright 2023 Suguru Hirahara
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
describe("General room settings tab", () => {
let homeserver: HomeserverInstance;
const roomName = "Test Room";
beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Hanako");
cy.createRoom({ name: roomName }).viewRoomByName(roomName);
});
});
afterEach(() => {
cy.stopHomeserver(homeserver);
});
it("should be rendered properly", () => {
cy.openRoomSettings("General");
// Assert that "Show less" details element is rendered
cy.findByText("Show less").should("exist");
cy.findByTestId("General").percySnapshotElement(
"Room settings tab - General (Local addresses details area expanded)",
{
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
},
);
// Click the "Show less" details element
cy.findByText("Show less").click();
// Assert that "Show more" details element is rendered instead of "Show more"
cy.findByText("Show less").should("not.exist");
cy.findByText("Show more").should("exist");
cy.findByTestId("General").percySnapshotElement(
"Room settings tab - General (Local addresses details area collapsed)",
{
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
},
);
});
it("long address should not cause dialog to overflow", () => {
cy.openRoomSettings("General");
// 1. Set the room-address to be a really long string
const longString =
"abcasdhjasjhdaj1jh1asdhasjdhajsdhjavhjksdnfjasdhfjh21jh3j12h3jashfcjbabbabasdbdasjh1j23hk1l2j3lamajshdjkltyiuwioeuqpirjdfmngsdnf8378234jskdfjkdfnbnsdfbasjbdjashdajshfgngnsdkfsdkkqwijeqiwjeiqhrkldfnaskldklasdn";
cy.get("#roomAliases").within(() => {
cy.get("input[label='Room address']").type(longString);
cy.contains("Add").click();
});
// 2. wait for the new setting to apply ...
cy.get("#canonicalAlias").should("have.value", `#${longString}:localhost`);
// 3. Check if the dialog overflows
cy.get(".mx_Dialog")
.invoke("outerWidth")
.then((dialogWidth) => {
cy.get("#canonicalAlias")
.invoke("outerWidth")
.then((fieldWidth) => {
// Assert that the width of the select element is less than that of .mx_Dialog div.
expect(fieldWidth).to.be.lessThan(dialogWidth);
});
});
});
});

View file

@ -1,238 +0,0 @@
/*
Copyright 2023 Suguru Hirahara
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
const USER_NAME = "Bob";
const USER_NAME_NEW = "Alice";
const IntegrationManager = "scalar.vector.im";
describe("General user settings tab", () => {
let homeserver: HomeserverInstance;
let userId: string;
beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, USER_NAME).then((user) => (userId = user.userId));
cy.tweakConfig({ default_country_code: "US" }); // For checking the international country calling code
});
cy.openUserSettings("General");
});
afterEach(() => {
cy.stopHomeserver(homeserver);
});
it("should be rendered properly", () => {
// Exclude userId from snapshots
const percyCSS = ".mx_ProfileSettings_profile_controls_userId { visibility: hidden !important; }";
cy.findByTestId("mx_GeneralUserSettingsTab").percySnapshotElement("User settings tab - General", {
percyCSS,
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
});
cy.findByTestId("mx_GeneralUserSettingsTab").within(() => {
// Assert that the top heading is rendered
cy.findByText("General").should("be.visible");
cy.get(".mx_ProfileSettings_profile")
.scrollIntoView()
.within(() => {
// Assert USER_NAME is rendered
cy.findByRole("textbox", { name: "Display Name" })
.get(`input[value='${USER_NAME}']`)
.should("be.visible");
// Assert that a userId is rendered
cy.get(".mx_ProfileSettings_profile_controls_userId").within(() => {
cy.findByText(userId).should("exist");
});
// Check avatar setting
cy.get(".mx_AvatarSetting_avatar")
.should("exist")
.realHover()
.get(".mx_AvatarSetting_avatar_hovering")
.within(() => {
// Hover effect
cy.get(".mx_AvatarSetting_hoverBg").should("exist");
cy.get(".mx_AvatarSetting_hover span").within(() => {
cy.findByText("Upload").should("exist");
});
});
});
// Wait until spinners disappear
cy.findByTestId("accountSection").within(() => {
cy.get(".mx_Spinner").should("not.exist");
});
cy.findByTestId("discoverySection").within(() => {
cy.get(".mx_Spinner").should("not.exist");
});
cy.findByTestId("accountSection").within(() => {
// Assert that input areas for changing a password exists
cy.get("form.mx_GeneralUserSettingsTab_section--account_changePassword")
.scrollIntoView()
.within(() => {
cy.findByLabelText("Current password").should("be.visible");
cy.findByLabelText("New Password").should("be.visible");
cy.findByLabelText("Confirm password").should("be.visible");
});
});
// Check email addresses area
cy.findByTestId("mx_AccountEmailAddresses")
.scrollIntoView()
.within(() => {
// Assert that an input area for a new email address is rendered
cy.findByRole("textbox", { name: "Email Address" }).should("be.visible");
// Assert the add button is visible
cy.findByRole("button", { name: "Add" }).should("be.visible");
});
// Check phone numbers area
cy.findByTestId("mx_AccountPhoneNumbers")
.scrollIntoView()
.within(() => {
// Assert that an input area for a new phone number is rendered
cy.findByRole("textbox", { name: "Phone Number" }).should("be.visible");
// Assert that the add button is rendered
cy.findByRole("button", { name: "Add" }).should("be.visible");
});
// Check language and region setting dropdown
cy.get(".mx_GeneralUserSettingsTab_section_languageInput")
.scrollIntoView()
.within(() => {
// Check the default value
cy.findByText("English").should("be.visible");
// Click the button to display the dropdown menu
cy.findByRole("button", { name: "Language Dropdown" }).click();
// Assert that the default option is rendered and highlighted
cy.findByRole("option", { name: /Albanian/ })
.should("be.visible")
.should("have.class", "mx_Dropdown_option_highlight");
cy.findByRole("option", { name: /Deutsch/ }).should("be.visible");
// Click again to close the dropdown
cy.findByRole("button", { name: "Language Dropdown" }).click();
// Assert that the default value is rendered again
cy.findByText("English").should("be.visible");
});
cy.get("form.mx_SetIdServer")
.scrollIntoView()
.within(() => {
// Assert that an input area for identity server exists
cy.findByRole("textbox", { name: "Enter a new identity server" }).should("be.visible");
});
cy.get(".mx_SetIntegrationManager")
.scrollIntoView()
.within(() => {
cy.contains(".mx_SetIntegrationManager_heading_manager", IntegrationManager).should("be.visible");
// Make sure integration manager's toggle switch is enabled
cy.get(".mx_ToggleSwitch_enabled").should("be.visible");
cy.get(".mx_SetIntegrationManager_heading_manager").should(
"have.text",
"Manage integrations(scalar.vector.im)",
);
});
// Assert the account deactivation button is displayed
cy.findByTestId("account-management-section")
.scrollIntoView()
.findByRole("button", { name: "Deactivate Account" })
.should("be.visible")
.should("have.class", "mx_AccessibleButton_kind_danger");
});
});
it("should support adding and removing a profile picture", () => {
cy.get(".mx_SettingsTab .mx_ProfileSettings").within(() => {
// Upload a picture
cy.get(".mx_ProfileSettings_avatarUpload").selectFile("cypress/fixtures/riot.png", { force: true });
// Find and click "Remove" link button
cy.get(".mx_ProfileSettings_profile").within(() => {
cy.findByRole("button", { name: "Remove" }).click();
});
// Assert that the link button disappeared
cy.get(".mx_AvatarSetting_avatar .mx_AccessibleButton_kind_link_sm").should("not.exist");
});
});
it("should set a country calling code based on default_country_code", () => {
// Check phone numbers area
cy.findByTestId("mx_AccountPhoneNumbers")
.scrollIntoView()
.within(() => {
// Assert that an input area for a new phone number is rendered
cy.findByRole("textbox", { name: "Phone Number" }).should("be.visible");
// Check a new phone number dropdown menu
cy.get(".mx_PhoneNumbers_country")
.scrollIntoView()
.within(() => {
// Assert that the country calling code of United States is visible
cy.findByText(/\+1/).should("be.visible");
// Click the button to display the dropdown menu
cy.findByRole("button", { name: "Country Dropdown" }).click();
// Assert that the option for calling code of United Kingdom is visible
cy.findByRole("option", { name: /United Kingdom/ }).should("be.visible");
// Click again to close the dropdown
cy.findByRole("button", { name: "Country Dropdown" }).click();
// Assert that the default value is rendered again
cy.findByText(/\+1/).should("be.visible");
});
cy.findByRole("button", { name: "Add" }).should("be.visible");
});
});
it("should support changing a display name", () => {
cy.get(".mx_SettingsTab .mx_ProfileSettings").within(() => {
// Change the diaplay name to USER_NAME_NEW
cy.findByRole("textbox", { name: "Display Name" }).type(`{selectAll}{del}${USER_NAME_NEW}{enter}`);
});
cy.closeDialog();
// Assert the avatar's initial characters are set
cy.get(".mx_UserMenu .mx_BaseAvatar").findByText("A").should("exist"); // Alice
cy.get(".mx_RoomView_wrapper .mx_BaseAvatar").findByText("A").should("exist"); // Alice
});
});

View file

@ -1,50 +0,0 @@
/*
Copyright 2023 Suguru Hirahara
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
describe("Preferences user settings tab", () => {
let homeserver: HomeserverInstance;
beforeEach(() => {
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Bob");
});
});
afterEach(() => {
cy.stopHomeserver(homeserver);
});
it("should be rendered properly", () => {
cy.openUserSettings("Preferences");
cy.findByTestId("mx_PreferencesUserSettingsTab").within(() => {
// Assert that the top heading is rendered
cy.contains("Preferences").should("be.visible");
});
cy.findByTestId("mx_PreferencesUserSettingsTab").percySnapshotElement("User settings tab - Preferences", {
// Emulate TabbedView's actual min and max widths
// 580: '.mx_UserSettingsDialog .mx_TabbedView' min-width
// 796: 1036 (mx_TabbedView_tabsOnLeft actual width) - 240 (mx_TabbedView_tabPanel margin-right)
widths: [580, 796],
});
});
});

View file

@ -1,72 +0,0 @@
/*
Copyright 2023 Suguru Hirahara
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 { HomeserverInstance } from "../../plugins/utils/homeserver";
describe("Security user settings tab", () => {
let homeserver: HomeserverInstance;
afterEach(() => {
cy.stopHomeserver(homeserver);
});
describe("with posthog enabled", () => {
beforeEach(() => {
// Enable posthog
cy.intercept("/config.json?cachebuster=*", (req) => {
req.continue((res) => {
res.send(200, {
...res.body,
posthog: {
project_api_key: "foo",
api_host: "bar",
},
privacy_policy_url: "example.tld", // Set privacy policy URL to enable privacyPolicyLink
});
});
});
cy.startHomeserver("default").then((data) => {
homeserver = data;
cy.initTestUser(homeserver, "Hanako");
});
// Hide "Notification" toast on Cypress Cloud
cy.contains(".mx_Toast_toast h2", "Notifications")
.should("exist")
.closest(".mx_Toast_toast")
.within(() => {
cy.findByRole("button", { name: "Dismiss" }).click();
});
cy.get(".mx_Toast_buttons").within(() => {
cy.findByRole("button", { name: "Yes" }).should("exist").click(); // Allow analytics
});
cy.openUserSettings("Security");
});
describe("AnalyticsLearnMoreDialog", () => {
it("should be rendered properly", () => {
cy.findByRole("button", { name: "Learn more" }).click();
cy.get(".mx_AnalyticsLearnMoreDialog_wrapper").percySnapshotElement("AnalyticsLearnMoreDialog");
});
});
});
});