Make apps/web/playwright comply with strict mode (#34403)

* Make apps/web/playwright comply with strict mode

Otherwise it sometimes fails to compile matrix-js-sdk as strict mode & noImplicitAny both impact how overloads are asserted

* Iterate
This commit is contained in:
Michael Telatynski
2026-07-30 09:07:03 +00:00
committed by GitHub
parent 4a18eac927
commit 42253a7ae5
84 changed files with 413 additions and 388 deletions
@@ -19,7 +19,7 @@ test.describe("Device manager", () => {
test.beforeEach(async ({ homeserver, user }) => {
// create 3 extra sessions to manage
for (let i = 0; i < 3; i++) {
await homeserver.loginUser(user.userId, user.password);
await homeserver.loginUser(user.userId, user.password!);
}
});
@@ -21,7 +21,7 @@ test.describe("Advanced section in Encryption tab", () => {
const section = util.getEncryptionDetailsSection();
const deviceId = await page.evaluate(() => window.mxMatrixClientPeg.get().getDeviceId());
await expect(section.getByText(deviceId)).toBeVisible();
await expect(section.getByText(deviceId!)).toBeVisible();
await expect(section).toMatchScreenshot("encryption-details.png", {
mask: [section.getByTestId("deviceId"), section.getByTestId("sessionKey")],
@@ -59,7 +59,7 @@ test.describe("Advanced section in Encryption tab", () => {
// Fill password dialog and validate
const dialog = page.locator(".mx_InteractiveAuthDialog");
await dialog.getByRole("textbox", { name: "Password" }).fill(credentials.password);
await dialog.getByRole("textbox", { name: "Password" }).fill(credentials.password!);
await dialog.getByRole("button", { name: "Continue" }).click();
await expect(section.getByRole("button", { name: "Reset cryptographic identity" })).toBeVisible();
@@ -26,6 +26,7 @@ test.describe("Encryption tab", () => {
test.beforeEach(async ({ page, homeserver, credentials }) => {
// The bot bootstraps cross-signing, creates a key backup and sets up a recovery key
const botCredentials = { ...credentials };
// @ts-expect-error
delete botCredentials.accessToken; // use a new login for the bot
const res = await createBot(page, homeserver, botCredentials);
recoveryKey = res.recoveryKey;
@@ -71,7 +72,7 @@ test.describe("Encryption tab", () => {
"should prompt to enter the recovery key when the secrets are not cached locally",
{ tag: "@screenshot" },
async ({ page, app, util }) => {
await verifySession(app, recoveryKey.encodedPrivateKey);
await verifySession(app, recoveryKey.encodedPrivateKey!);
// We need to delete the cached secrets
await deleteCachedSecrets(page);
@@ -104,7 +105,7 @@ test.describe("Encryption tab", () => {
app,
util,
}) => {
await verifySession(app, recoveryKey.encodedPrivateKey);
await verifySession(app, recoveryKey.encodedPrivateKey!);
// We need to delete the cached secrets
await deleteCachedSecrets(page);
@@ -120,7 +121,7 @@ test.describe("Encryption tab", () => {
});
test("should warn before turning off key storage", { tag: "@screenshot" }, async ({ page, app, util }) => {
await verifySession(app, recoveryKey.encodedPrivateKey);
await verifySession(app, recoveryKey.encodedPrivateKey!);
await util.openEncryptionTab();
await page.getByRole("switch", { name: "Allow key storage" }).click();
@@ -55,7 +55,7 @@ class Helpers {
async enterRecoveryKey(recoveryKey: GeneratedSecretStorageKey) {
// Fill the recovery key
const dialog = this.page.locator(".mx_Dialog");
await dialog.getByRole("textbox").fill(recoveryKey.encodedPrivateKey);
await dialog.getByRole("textbox").fill(recoveryKey.encodedPrivateKey!);
await dialog.getByRole("button", { name: "Continue" }).click();
}
@@ -18,6 +18,7 @@ test.describe("Recovery section in Encryption tab", () => {
test.beforeEach(async ({ page, homeserver, credentials }) => {
// The bot bootstraps cross-signing, creates a key backup and sets up a recovery key
const botCredentials = { ...credentials };
// @ts-expect-error
delete botCredentials.accessToken; // use a new login for the bot
const res = await createBot(page, homeserver, botCredentials);
recoveryKey = res.recoveryKey;
@@ -27,7 +28,7 @@ test.describe("Recovery section in Encryption tab", () => {
"should change the recovery key",
{ tag: ["@screenshot", "@no-webkit"] },
async ({ page, app, homeserver, credentials, util, context }) => {
await verifySession(app, recoveryKey.encodedPrivateKey);
await verifySession(app, recoveryKey.encodedPrivateKey!);
const dialog = await util.openEncryptionTab();
// The user can only change the recovery key
@@ -54,7 +55,7 @@ test.describe("Recovery section in Encryption tab", () => {
);
test("should setup the recovery key", { tag: ["@screenshot", "@no-webkit"] }, async ({ page, app, util }) => {
await verifySession(app, recoveryKey.encodedPrivateKey);
await verifySession(app, recoveryKey.encodedPrivateKey!);
await util.removeSecretStorageDefaultKeyId();
// The key backup is deleted and the user needs to set it up
@@ -54,6 +54,6 @@ test.describe("General room settings tab", () => {
const dialogBoundingBox = await page.locator(".mx_Dialog").boundingBox();
const inputBoundingBox = await settings.locator("#canonicalAlias").boundingBox();
// Assert that the width of the select element is less than that of .mx_Dialog div.
expect(inputBoundingBox.width).toBeLessThan(dialogBoundingBox.width);
expect(inputBoundingBox!.width).toBeLessThan(dialogBoundingBox!.width);
});
});