Playwright: Convert lazy-loading test to playwright (#11988)

* Implement method to wait for next sync

* Add timeline coded to app page

* Convert network plugin

* Add createBot fixture

* Convert lazy-loading test

* Remove cypress test

* Remove converted files

* Remove imports

* Fix date in copyright header

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix date in copyright header

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

* Use proper method to send messages

* Fix sliding-sync test

* Address comments

* Move code to timeline

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
R Midhun Suresh 2023-12-19 14:06:54 +05:30 committed by GitHub
parent 24cda5fc59
commit 4c2efc3637
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 279 additions and 358 deletions

View file

@ -17,6 +17,7 @@ limitations under the License.
import { JSHandle, Page } from "@playwright/test";
import { PageFunctionOn } from "playwright-core/types/structs";
import { Network } from "./network";
import type {
IContent,
ICreateRoomOpts,
@ -34,6 +35,7 @@ import type {
import { Credentials } from "../plugins/homeserver";
export class Client {
public network: Network;
protected client: JSHandle<MatrixClient>;
protected getClientHandle(): Promise<JSHandle<MatrixClient>> {
@ -51,6 +53,7 @@ export class Client {
page.on("framenavigated", async () => {
this.client = null;
});
this.network = new Network(page, this);
}
public evaluate<R, Arg, O extends MatrixClient = MatrixClient>(
@ -134,15 +137,6 @@ export class Client {
);
}
/**
* Send a text message into a room
* @param roomId ID of the room to send the message into
* @param content the event content to send
*/
public async sendTextMessage(roomId: string, message: string): Promise<ISendEventResponse> {
return await this.sendMessage(roomId, { msgtype: "m.text", body: message });
}
/**
* Create a room with given options.
* @param options the options to apply when creating the room
@ -215,6 +209,17 @@ export class Client {
);
}
/**
* Wait until next sync from this client
*/
public async waitForNextSync(): Promise<void> {
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);
});
}
/**
* Invites the given user to the given room.
* @param roomId the id of the room to invite to