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:
@@ -60,7 +60,7 @@ export type PageFunctionOn<On, Arg2, R> = string | ((on: On, arg2: Unboxed<Arg2>
|
||||
|
||||
export class Client {
|
||||
public network: Network;
|
||||
protected client: JSHandle<MatrixClient>;
|
||||
protected client: JSHandle<MatrixClient> | null = null;
|
||||
|
||||
protected getClientHandle(): Promise<JSHandle<MatrixClient>> {
|
||||
return this.page.evaluateHandle(() => window.mxMatrixClientPeg.get());
|
||||
@@ -93,8 +93,8 @@ export class Client {
|
||||
arg?: any,
|
||||
): Promise<R>;
|
||||
public async evaluate<T>(fn: (client: MatrixClient) => T, arg?: any): Promise<T> {
|
||||
await this.prepareClient();
|
||||
return this.client.evaluate(fn, arg);
|
||||
const client = await this.prepareClient();
|
||||
return client.evaluate(fn, arg);
|
||||
}
|
||||
|
||||
public evaluateHandle<R, Arg, O extends MatrixClient = MatrixClient>(
|
||||
@@ -106,8 +106,8 @@ export class Client {
|
||||
arg?: any,
|
||||
): Promise<JSHandle<R>>;
|
||||
public async evaluateHandle<T>(fn: (client: MatrixClient) => T, arg?: any): Promise<JSHandle<T>> {
|
||||
await this.prepareClient();
|
||||
return this.client.evaluateHandle(fn, arg);
|
||||
const client = await this.prepareClient();
|
||||
return client.evaluateHandle(fn, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ export class Client {
|
||||
const client = await this.prepareClient();
|
||||
return client.evaluate(
|
||||
async (client, { roomName }) => {
|
||||
const room = client.getRooms().find((r) => r.getDefaultRoomName(client.getUserId()) === roomName);
|
||||
const room = client.getRooms().find((r) => r.getDefaultRoomName(client.getSafeUserId()) === roomName);
|
||||
if (room) {
|
||||
await client.joinRoom(room.roomId);
|
||||
return room.roomId;
|
||||
@@ -268,7 +268,7 @@ export class Client {
|
||||
await this.page.waitForResponse(async (response) => {
|
||||
const accessToken = await this.evaluate((client) => client.getAccessToken());
|
||||
const authHeader = await response.request().headerValue("authorization");
|
||||
return response.url().includes("/sync") && authHeader.includes(accessToken);
|
||||
return response.url().includes("/sync") && !!accessToken && !!authHeader?.includes(accessToken);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -392,11 +392,11 @@ export class Client {
|
||||
event: JSHandle<MatrixEvent>,
|
||||
receiptType?: ReceiptType,
|
||||
unthreaded?: boolean,
|
||||
): Promise<EmptyObject> {
|
||||
): Promise<void> {
|
||||
const client = await this.prepareClient();
|
||||
return client.evaluate(
|
||||
(client, { event, receiptType, unthreaded }) => {
|
||||
return client.sendReadReceipt(event, receiptType, unthreaded);
|
||||
async (client, { event, receiptType, unthreaded }) => {
|
||||
await client.sendReadReceipt(event, receiptType, unthreaded);
|
||||
},
|
||||
{ event, receiptType, unthreaded },
|
||||
);
|
||||
@@ -555,7 +555,7 @@ export function bootstrapCrossSigningForClient(
|
||||
) {
|
||||
return client.evaluate(
|
||||
async (client, { credentials, resetKeys }) => {
|
||||
await client.getCrypto().bootstrapCrossSigning({
|
||||
await client.getCrypto()!.bootstrapCrossSigning({
|
||||
authUploadDeviceSigningKeys: async (func) => {
|
||||
await func({
|
||||
type: "m.login.password",
|
||||
|
||||
Reference in New Issue
Block a user