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
@@ -48,7 +48,7 @@ function spaceChildInitialState(
serverName: string,
roomId: string,
order?: string,
): ICreateRoomOpts["initial_state"]["0"] {
): NonNullable<ICreateRoomOpts["initial_state"]>[number] {
return {
type: "m.space.child",
state_key: roomId,
@@ -240,7 +240,7 @@ test.describe("Spaces", () => {
await shareDialog.getByRole("button", { name: "Invite people" }).click();
const otherSection = page.locator(".mx_InviteDialog_other");
await otherSection.getByRole("textbox").fill(bot.credentials.userId);
await otherSection.getByRole("textbox").fill(bot.credentials!.userId);
await otherSection.getByRole("button", { name: "Invite" }).click();
await expect(page.locator(".mx_InviteDialog_other")).not.toBeVisible();
@@ -25,9 +25,9 @@ type RoomRef = { name: string; roomId: string };
* - Invite the bot to both rooms and ensure that it has joined
*/
export const test = base.extend<{
room1Name?: string;
room1Name: string;
room1: { name: string; roomId: string };
room2Name?: string;
room2Name: string;
room2: { name: string; roomId: string };
msg: MessageBuilder;
util: Helpers;
@@ -39,7 +39,7 @@ export const test = base.extend<{
room1: async ({ room1Name: name, app, user, bot }, use) => {
const roomId = await app.client.createRoom({
name,
invite: [bot.credentials.userId],
invite: [bot.credentials!.userId],
preset: "public_chat" as Preset,
});
await bot.awaitRoomMembership(roomId);
@@ -47,12 +47,12 @@ export const test = base.extend<{
},
room2Name: "Room 2",
room2: async ({ room2Name: name, app, user, bot }, use) => {
const roomId = await app.client.createRoom({ name, invite: [bot.credentials.userId] });
const roomId = await app.client.createRoom({ name, invite: [bot.credentials!.userId] });
await bot.awaitRoomMembership(roomId);
await use({ name, roomId });
},
msg: async ({ page, app, util }, use) => {
await use(new MessageBuilder(page, app, util));
await use(new MessageBuilder());
},
util: async ({ room1, room2, page, app, bot }, use) => {
await use(new Helpers(page, app, bot));
@@ -70,12 +70,6 @@ export const test = base.extend<{
* which finds a message and then constructs a reply to it.
*/
export class MessageBuilder {
constructor(
private page: Page,
private app: ElementAppPage,
private helpers: Helpers,
) {}
/**
* Map of message content -> event.
*/
@@ -164,11 +158,7 @@ export class MessageBuilder {
* MessageBuilder.replyTo} which creates a reply based on a previous message.
*/
export abstract class MessageContentSpec {
messageFinder: MessageBuilder | null;
constructor(messageFinder: MessageBuilder = null) {
this.messageFinder = messageFinder;
}
constructor(public readonly messageFinder: MessageBuilder) {}
public abstract getContent(room: JSHandle<Room>): Promise<Record<string, unknown>>;
}
@@ -230,9 +220,9 @@ export class Helpers {
await expect(this.page.locator(".mx_ThreadView_timelinePanelWrapper")).toBeVisible();
}
async findRoomById(roomId: string): Promise<JSHandle<Room | undefined>> {
async findRoomById(roomId: string): Promise<JSHandle<Room>> {
return this.app.client.evaluateHandle((cli, roomId) => {
return cli.getRooms().find((r) => r.roomId === roomId);
return cli.getRooms().find((r) => r.roomId === roomId)!;
}, roomId);
}