Playwright: Convert sliding-sync test to playwright (#11989)

* Add method to send text message

* Add dockerUrl to HomeServerConfig

* Implement sliding sync proxy

* Convert tests

* Reload page after applying labs feature

* Remove converted files

* Remove timeout

* Remove sliding-sync

* Remove proxy import

* Remove reference to proxy

* wait for load

* Update date

* Convert enableLabsFeature to separate fixture

* Enable feature in fixture

* Skip over config and just write to local-storage

* Rename fixture

* Fix room header test

* Use type inference

* Override config instead of setting localstorage

* Set default language

* Always add labs feature

* Put this one test into a separate describe block

* Move labs lag within describe block
This commit is contained in:
R Midhun Suresh 2023-12-16 15:31:26 +05:30 committed by GitHub
parent de5931d5a8
commit 7b3d5b5f21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 547 additions and 770 deletions

View file

@ -18,13 +18,11 @@ import { type Locator, type Page, expect } from "@playwright/test";
import { Settings } from "./settings";
import { Client } from "./client";
import { Labs } from "./labs";
import { Spotlight } from "./Spotlight";
export class ElementAppPage {
public constructor(public readonly page: Page) {}
public labs = new Labs(this.page);
public settings = new Settings(this.page);
public client: Client = new Client(this.page);

View file

@ -101,7 +101,7 @@ export class Client {
}
/**
* Send a message as a bot into a room
* Send a message into a room
* @param roomId ID of the room to send the message into
* @param content the event content to send
*/
@ -134,6 +134,15 @@ 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

View file

@ -1,37 +0,0 @@
/*
Copyright 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Page } from "playwright-core";
export class Labs {
constructor(private page: Page) {}
/**
* Enables a labs feature for an element session.
* @param feature labsFeature to enable (e.g. "feature_spotlight")
*/
public async enableLabsFeature(feature: string): Promise<void> {
if (this.page.url() === "about:blank") {
await this.page.addInitScript((feature) => {
window.localStorage.setItem(`mx_labs_feature_${feature}`, "true");
}, feature);
} else {
await this.page.evaluate((feature) => {
window.localStorage.setItem(`mx_labs_feature_${feature}`, "true");
}, feature);
}
}
}