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
@@ -33,8 +33,8 @@ test.describe("Collapsible Room list", () => {
const boundingBox = await leftPanelLocator.boundingBox();
// Move mouse 2px to the right of the left-panel, this should be region that the user drags to resize the panel.
const mouseX = boundingBox.x + boundingBox.width + 2;
const mouseY = boundingBox.y + boundingBox.height / 2;
const mouseX = boundingBox!.x + boundingBox!.width + 2;
const mouseY = boundingBox!.y + boundingBox!.height / 2;
await page.mouse.move(mouseX, mouseY);
await page.mouse.down();
@@ -50,12 +50,12 @@ test.describe("Collapsible Room list", () => {
// Contract the panel
let previousBoundingBox = await resize(page, -50);
let currentBoundingBox = await leftPanelLocator.boundingBox();
expect(currentBoundingBox.width).toBeCloseTo(previousBoundingBox.width - 50, 0);
expect(currentBoundingBox!.width).toBeCloseTo(previousBoundingBox!.width - 50, 0);
// Expand the panel
previousBoundingBox = await resize(page, 30);
currentBoundingBox = await leftPanelLocator.boundingBox();
expect(currentBoundingBox.width).toBeCloseTo(previousBoundingBox.width + 30, 0);
expect(currentBoundingBox!.width).toBeCloseTo(previousBoundingBox!.width + 30, 0);
});
test(
@@ -67,7 +67,7 @@ test.describe("Collapsible Room list", () => {
// Collapse the panel
await resize(page, -300);
let currentBoundingBox = await leftPanelLocator.boundingBox();
expect(currentBoundingBox.width).toStrictEqual(0);
expect(currentBoundingBox!.width).toStrictEqual(0);
// Expect te separator to be shown
const separator = page.getByRole("separator", { name: "Click or drag to expand" });
@@ -77,19 +77,19 @@ test.describe("Collapsible Room list", () => {
// Should be possible to expand by clicking on the separator
await separator.click();
currentBoundingBox = await leftPanelLocator.boundingBox();
expect(currentBoundingBox.width).toBeGreaterThan(365);
expect(currentBoundingBox!.width).toBeGreaterThan(365);
// Collapse the panel again
await resize(page, -300);
// Check that the panel can be expanded by dragging the separator
const separatorBoundingBox = await separator.boundingBox();
const mouseX = separatorBoundingBox.x + separatorBoundingBox.width / 2;
const mouseY = separatorBoundingBox.y + separatorBoundingBox.height / 2;
const mouseX = separatorBoundingBox!.x + separatorBoundingBox!.width / 2;
const mouseY = separatorBoundingBox!.y + separatorBoundingBox!.height / 2;
await page.mouse.move(mouseX, mouseY);
await page.mouse.down();
await page.mouse.move(mouseX + 400, mouseY);
expect(currentBoundingBox.width).toBeGreaterThan(365);
expect(currentBoundingBox!.width).toBeGreaterThan(365);
},
);
});
@@ -48,7 +48,7 @@ test.describe("Room list filters and sort", () => {
We will also send a simple message in this room.
*/
const oldRoomId = await app.client.createRoom({ name: "Old Room" });
await app.client.inviteUser(oldRoomId, bot.credentials.userId);
await app.client.inviteUser(oldRoomId, bot.credentials!.userId);
await bot.joinRoom(oldRoomId);
const response = await app.client.sendMessage(oldRoomId, "Hello!");
@@ -99,8 +99,8 @@ test.describe("Room list filters and sort", () => {
});
test.describe("Room list", () => {
let unReadDmId: string | undefined;
let unReadRoomId: string | undefined;
let unReadDmId: string;
let unReadRoomId: string;
test.beforeEach(async ({ page, app, bot, user }) => {
await app.client.createRoom({ name: "empty room" });
@@ -114,7 +114,7 @@ test.describe("Room list filters and sort", () => {
await bot.sendMessage(unReadDmId, "I am a robot. Beep.");
unReadRoomId = await app.client.createRoom({ name: "unread room" });
await app.client.inviteUser(unReadRoomId, bot.credentials.userId);
await app.client.inviteUser(unReadRoomId, bot.credentials!.userId);
await bot.joinRoom(unReadRoomId);
await bot.sendMessage(unReadRoomId, "I am a robot. Beep.");
@@ -135,7 +135,7 @@ test.describe("Room list filters and sort", () => {
});
const mentionRoomId = await app.client.createRoom({ name: "room with mention" });
await app.client.inviteUser(mentionRoomId, bot.credentials.userId);
await app.client.inviteUser(mentionRoomId, bot.credentials!.userId);
await bot.joinRoom(mentionRoomId);
const clientBot = await bot.prepareClient();
@@ -364,7 +364,7 @@ test.describe("Room list sections", () => {
const roomList = getRoomList(page);
// Invite the bot and have it send a message to generate an unread
await app.client.inviteUser(favouriteId, bot.credentials.userId);
await app.client.inviteUser(favouriteId, bot.credentials!.userId);
await bot.joinRoom(favouriteId);
await bot.sendMessage(favouriteId, "Hello from bot!");
@@ -391,7 +391,7 @@ test.describe("Room list sections", () => {
// A room with a mention, landing in the Chats section
const mentionId = await app.client.createRoom({ name: "mention room" });
await app.client.inviteUser(mentionId, bot.credentials.userId);
await app.client.inviteUser(mentionId, bot.credentials!.userId);
await bot.joinRoom(mentionId);
const clientBot = await bot.prepareClient();
await clientBot.evaluate(
@@ -464,13 +464,13 @@ test.describe("Room list sections", () => {
await app.client.evaluate(async (client, roomId) => {
await client.setRoomTag(roomId, "m.favourite");
}, favouriteId);
await app.client.inviteUser(favouriteId, bot.credentials.userId);
await app.client.inviteUser(favouriteId, bot.credentials!.userId);
await bot.joinRoom(favouriteId);
await bot.sendMessage(favouriteId, "Hello from favourite!");
// Create a regular room with unread messages
const regularId = await app.client.createRoom({ name: "regular with unread" });
await app.client.inviteUser(regularId, bot.credentials.userId);
await app.client.inviteUser(regularId, bot.credentials!.userId);
await bot.joinRoom(regularId);
await bot.sendMessage(regularId, "Hello from regular!");
@@ -62,7 +62,7 @@ test.describe("Room list unread activity toast", () => {
// A room with a real notification count, named so it sorts to the very bottom under A-Z.
const targetId = await app.client.createRoom({ name: "zzz unread room" });
await app.client.inviteUser(targetId, bot.credentials.userId);
await app.client.inviteUser(targetId, bot.credentials!.userId);
await bot.joinRoom(targetId);
// Enough filler rooms to push the target well below the visible area.
@@ -100,7 +100,7 @@ test.describe("Room list unread activity toast", () => {
// The target's unread state will only ever be an activity dot, never a notification count: set it
// to "@mentions & keywords" so a plain (non-mention) message produces activity rather than a count.
const targetId = await app.client.createRoom({ name: "zzz activity room" });
await app.client.inviteUser(targetId, bot.credentials.userId);
await app.client.inviteUser(targetId, bot.credentials!.userId);
await bot.joinRoom(targetId);
await app.viewRoomById(targetId);
@@ -148,7 +148,7 @@ test.describe("Room list unread activity toast", () => {
// A regular (Chats) room with a notification count.
const notifyId = await app.client.createRoom({ name: "chats notify room" });
await app.client.inviteUser(notifyId, bot.credentials.userId);
await app.client.inviteUser(notifyId, bot.credentials!.userId);
await bot.joinRoom(notifyId);
// A favourite room so the list renders in section mode from the start.
@@ -192,7 +192,7 @@ test.describe("Room list", () => {
const roomListView = getRoomList(page);
const roomId = await app.client.createRoom({ name: "1 notification" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
await bot.sendMessage(roomId, "I am a robot. Beep.");
@@ -396,7 +396,7 @@ test.describe("Room list", () => {
const roomListView = getRoomList(page);
const roomId = await app.client.createRoom({ name: "2 notifications" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
await bot.sendMessage(roomId, "I am a robot. Beep.");
@@ -412,7 +412,7 @@ test.describe("Room list", () => {
const roomListView = getRoomList(page);
const roomId = await app.client.createRoom({ name: "mention" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
const clientBot = await bot.prepareClient();
@@ -445,7 +445,7 @@ test.describe("Room list", () => {
// focus the user menu to avoid to have hover decoration
await page.getByRole("button", { name: "User menu" }).focus();
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
await bot.sendMessage(roomId, "I am a robot. Beep.");
@@ -483,7 +483,7 @@ test.describe("Room list", () => {
const otherRoomId = await app.client.createRoom({ name: "other room" });
const roomId = await app.client.createRoom({ name: "activity" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
await app.viewRoomById(roomId);
@@ -510,7 +510,7 @@ test.describe("Room list", () => {
const roomListView = getRoomList(page);
const roomId = await app.client.createRoom({ name: "mark as unread" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
const room = roomListView.getByRole("option", { name: "mark as unread" });
@@ -527,7 +527,7 @@ test.describe("Room list", () => {
const roomListView = getRoomList(page);
const roomId = await app.client.createRoom({ name: "silent" });
await app.client.inviteUser(roomId, bot.credentials.userId);
await app.client.inviteUser(roomId, bot.credentials!.userId);
await bot.joinRoom(roomId);
await app.viewRoomById(roomId);