diff --git a/cypress/global.d.ts b/cypress/global.d.ts index f8caad1f89..330b66f6db 100644 --- a/cypress/global.d.ts +++ b/cypress/global.d.ts @@ -14,9 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -import "../src/@types/global"; -import "../src/@types/svg"; -import "../src/@types/raw-loader"; // eslint-disable-next-line no-restricted-imports import "matrix-js-sdk/src/@types/global"; import type { @@ -31,20 +28,19 @@ import type { RoomMemberEvent, ICreateClientOpts, } from "matrix-js-sdk/src/matrix"; -import type { MatrixDispatcher } from "../src/dispatcher/dispatcher"; -import type PerformanceMonitor from "../src/performance"; -import type SettingsStore from "../src/settings/SettingsStore"; +import type { SettingLevel } from "../src/settings/SettingLevel"; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { interface ApplicationWindow { - mxSettingsStore: typeof SettingsStore; + // XXX: Importing SettingsStore causes a bunch of type lint errors + mxSettingsStore: { + setValue(settingName: string, roomId: string | null, level: SettingLevel, value: any): Promise; + }; mxMatrixClientPeg: { matrixClient?: MatrixClient; }; - mxDispatcher: MatrixDispatcher; - mxPerformanceMonitor: PerformanceMonitor; beforeReload?: boolean; // for detecting reloads // Partial type for the matrix-js-sdk module, exported by browser-matrix matrixcs: { @@ -61,14 +57,6 @@ declare global { }; } } - - interface Window { - // to appease the MatrixDispatcher import - mxDispatcher: MatrixDispatcher; - // to appease the PerformanceMonitor import - mxPerformanceMonitor: PerformanceMonitor; - mxPerformanceEntryNames: any; - } } export { MatrixClient }; diff --git a/cypress/support/settings.ts b/cypress/support/settings.ts index 51767cc0bd..0bd29297d3 100644 --- a/cypress/support/settings.ts +++ b/cypress/support/settings.ts @@ -22,7 +22,7 @@ import Timeoutable = Cypress.Timeoutable; import Withinable = Cypress.Withinable; import Shadow = Cypress.Shadow; import type { SettingLevel } from "../../src/settings/SettingLevel"; -import type SettingsStore from "../../src/settings/SettingsStore"; +import ApplicationWindow = Cypress.ApplicationWindow; export enum Filter { People = "people", @@ -36,7 +36,7 @@ declare global { /** * Returns the SettingsStore */ - getSettingsStore(): Chainable; // XXX: Importing SettingsStore causes a bunch of type lint errors + getSettingsStore(): Chainable; /** * Open the top left user menu, returning a handle to the resulting context menu. */ @@ -48,17 +48,6 @@ declare global { */ openUserSettings(tab?: string): Chainable>; - /** - * Open room creation dialog. - */ - openCreateRoomDialog(): Chainable>; - - /** - * Open room settings (via room header menu), returning a handle to the resulting dialog. - * @param tab the name of the tab to switch to after opening, optional. - */ - openRoomSettings(tab?: string): Chainable>; - /** * Switch settings tab to the one by the given name, ideally call this in the context of the dialog. * @param tab the name of the tab to switch to. @@ -70,20 +59,6 @@ declare global { */ closeDialog(): Chainable>; - /** - * Join the given beta, the `Labs` tab must already be opened, - * ideally call this in the context of the dialog. - * @param name the name of the beta to join. - */ - joinBeta(name: string): Chainable>; - - /** - * Leave the given beta, the `Labs` tab must already be opened, - * ideally call this in the context of the dialog. - * @param name the name of the beta to leave. - */ - leaveBeta(name: string): Chainable>; - /** * Sets the value for a setting. The room ID is optional if the * setting is not being set for a particular room, otherwise it @@ -98,20 +73,6 @@ declare global { */ setSettingValue(settingName: string, roomId: string, level: SettingLevel, value: any): Chainable; - /** - * Gets the value of a setting. The room ID is optional if the - * setting is not to be applied to any particular room, otherwise it - * should be supplied. - * @param {string} settingName The name of the setting to read the - * value of. - * @param {String} roomId The room ID to read the setting value in, - * may be null. - * @param {boolean} excludeDefault True to disable using the default - * value. - * @return {*} The value, or null if not found - */ - getSettingValue(settingName: string, roomId?: string, excludeDefault?: boolean): Chainable; - /** * Opens the spotlight dialog */ @@ -135,29 +96,19 @@ declare global { } } -Cypress.Commands.add("getSettingsStore", (): Chainable => { +Cypress.Commands.add("getSettingsStore", (): Chainable => { return cy.window({ log: false }).then((win) => win.mxSettingsStore); }); Cypress.Commands.add( "setSettingValue", (name: string, roomId: string, level: SettingLevel, value: any): Chainable => { - return cy.getSettingsStore().then((store: typeof SettingsStore) => { + return cy.getSettingsStore().then((store: ApplicationWindow["mxSettingsStore"]) => { return cy.wrap(store.setValue(name, roomId, level, value)); }); }, ); -// eslint-disable-next-line max-len -Cypress.Commands.add( - "getSettingValue", - (name: string, roomId?: string, excludeDefault?: boolean): Chainable => { - return cy.getSettingsStore().then((store: typeof SettingsStore) => { - return store.getValue(name, roomId, excludeDefault); - }); - }, -); - Cypress.Commands.add("openUserMenu", (): Chainable> => { cy.findByRole("button", { name: "User menu" }).click(); return cy.get(".mx_ContextualMenu"); @@ -174,24 +125,6 @@ Cypress.Commands.add("openUserSettings", (tab?: string): Chainable> => { - cy.findByRole("button", { name: "Add room" }).click(); - cy.findByRole("menuitem", { name: "New room" }).click(); - return cy.get(".mx_CreateRoomDialog"); -}); - -Cypress.Commands.add("openRoomSettings", (tab?: string): Chainable> => { - cy.findByRole("button", { name: "Room options" }).click(); - cy.get(".mx_RoomTile_contextMenu").within(() => { - cy.findByRole("menuitem", { name: "Settings" }).click(); - }); - return cy.get(".mx_RoomSettingsDialog").within(() => { - if (tab) { - cy.switchTab(tab); - } - }); -}); - Cypress.Commands.add("switchTab", (tab: string): Chainable> => { return cy.get(".mx_TabbedView_tabLabels").within(() => { cy.contains(".mx_TabbedView_tabLabel", tab).click(); @@ -202,24 +135,6 @@ Cypress.Commands.add("closeDialog", (): Chainable> => { return cy.findByRole("button", { name: "Close dialog" }).click(); }); -Cypress.Commands.add("joinBeta", (name: string): Chainable> => { - return cy - .contains(".mx_BetaCard_title", name) - .closest(".mx_BetaCard") - .within(() => { - return cy.get(".mx_BetaCard_buttons").findByRole("button", { name: "Join the beta" }).click(); - }); -}); - -Cypress.Commands.add("leaveBeta", (name: string): Chainable> => { - return cy - .contains(".mx_BetaCard_title", name) - .closest(".mx_BetaCard") - .within(() => { - return cy.get(".mx_BetaCard_buttons").findByRole("button", { name: "Leave the beta" }).click(); - }); -}); - Cypress.Commands.add( "openSpotlightDialog", (options?: Partial): Chainable> => {