mirror of
https://github.com/element-hq/element-web
synced 2024-11-26 03:05:51 +03:00
Prevent Cypress typechecking react-sdk components without strict mode (#12053)
* Prevent Cypress typechecking react-sdk components without strict mode This prevented us from switching to `forwardRef` in a bunch of places due to it behaving different with & without strict mode. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update global.d.ts --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
088710811d
commit
f8d87f0ddc
2 changed files with 9 additions and 106 deletions
22
cypress/global.d.ts
vendored
22
cypress/global.d.ts
vendored
|
@ -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<void>;
|
||||
};
|
||||
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 };
|
||||
|
|
|
@ -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<typeof SettingsStore | undefined>; // XXX: Importing SettingsStore causes a bunch of type lint errors
|
||||
getSettingsStore(): Chainable<ApplicationWindow["mxSettingsStore"] | undefined>;
|
||||
/**
|
||||
* Open the top left user menu, returning a handle to the resulting context menu.
|
||||
*/
|
||||
|
@ -48,17 +48,6 @@ declare global {
|
|||
*/
|
||||
openUserSettings(tab?: string): Chainable<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* Open room creation dialog.
|
||||
*/
|
||||
openCreateRoomDialog(): Chainable<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* 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<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* 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<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* 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<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* 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<JQuery<HTMLElement>>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<T>(settingName: string, roomId?: string, excludeDefault?: boolean): Chainable<T>;
|
||||
|
||||
/**
|
||||
* Opens the spotlight dialog
|
||||
*/
|
||||
|
@ -135,29 +96,19 @@ declare global {
|
|||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add("getSettingsStore", (): Chainable<typeof SettingsStore> => {
|
||||
Cypress.Commands.add("getSettingsStore", (): Chainable<ApplicationWindow["mxSettingsStore"]> => {
|
||||
return cy.window({ log: false }).then((win) => win.mxSettingsStore);
|
||||
});
|
||||
|
||||
Cypress.Commands.add(
|
||||
"setSettingValue",
|
||||
(name: string, roomId: string, level: SettingLevel, value: any): Chainable<void> => {
|
||||
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",
|
||||
<T = any>(name: string, roomId?: string, excludeDefault?: boolean): Chainable<T> => {
|
||||
return cy.getSettingsStore().then((store: typeof SettingsStore) => {
|
||||
return store.getValue(name, roomId, excludeDefault);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Cypress.Commands.add("openUserMenu", (): Chainable<JQuery<HTMLElement>> => {
|
||||
cy.findByRole("button", { name: "User menu" }).click();
|
||||
return cy.get(".mx_ContextualMenu");
|
||||
|
@ -174,24 +125,6 @@ Cypress.Commands.add("openUserSettings", (tab?: string): Chainable<JQuery<HTMLEl
|
|||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add("openCreateRoomDialog", (): Chainable<JQuery<HTMLElement>> => {
|
||||
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<JQuery<HTMLElement>> => {
|
||||
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<JQuery<HTMLElement>> => {
|
||||
return cy.get(".mx_TabbedView_tabLabels").within(() => {
|
||||
cy.contains(".mx_TabbedView_tabLabel", tab).click();
|
||||
|
@ -202,24 +135,6 @@ Cypress.Commands.add("closeDialog", (): Chainable<JQuery<HTMLElement>> => {
|
|||
return cy.findByRole("button", { name: "Close dialog" }).click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add("joinBeta", (name: string): Chainable<JQuery<HTMLElement>> => {
|
||||
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<JQuery<HTMLElement>> => {
|
||||
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<Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery<HTMLElement>> => {
|
||||
|
|
Loading…
Reference in a new issue