Add e2e tests for the knocking feature (#11803)
* Add e2e tests for knocking Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Add e2e tests for knocking into public knock rooms Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Smaller changes Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Remove room disappear check when forgotten due to exising issue Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> --------- Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> Co-authored-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
This commit is contained in:
parent
806e146f16
commit
ea648753f9
8 changed files with 627 additions and 110 deletions
|
@ -19,9 +19,10 @@ limitations under the License.
|
|||
|
||||
import { IWidget } from "matrix-widget-api/src/interfaces/IWidget";
|
||||
|
||||
import type { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
|
||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
||||
import { UserCredentials } from "../../support/login";
|
||||
import { waitForRoom } from "../utils";
|
||||
|
||||
const DEMO_WIDGET_ID = "demo-widget-id";
|
||||
const DEMO_WIDGET_NAME = "Demo Widget";
|
||||
|
@ -68,30 +69,6 @@ const DEMO_WIDGET_HTML = `
|
|||
</html>
|
||||
`;
|
||||
|
||||
function waitForRoom(win: Cypress.AUTWindow, roomId: string, predicate: (room: Room) => boolean): Promise<void> {
|
||||
const matrixClient = win.mxMatrixClientPeg.get();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const room = matrixClient.getRoom(roomId);
|
||||
|
||||
if (predicate(room)) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
function onEvent(ev: MatrixEvent) {
|
||||
if (ev.getRoomId() !== roomId) return;
|
||||
|
||||
if (predicate(room)) {
|
||||
matrixClient.removeListener(win.matrixcs.ClientEvent.Event, onEvent);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
|
||||
matrixClient.on(win.matrixcs.ClientEvent.Event, onEvent);
|
||||
});
|
||||
}
|
||||
|
||||
describe("Widget Events", () => {
|
||||
let homeserver: HomeserverInstance;
|
||||
let user: UserCredentials;
|
||||
|
@ -182,7 +159,7 @@ describe("Widget Events", () => {
|
|||
|
||||
// widget should receive 'm.room.topic' event after invite
|
||||
cy.window().then(async (win) => {
|
||||
await waitForRoom(win, roomId, (room) => {
|
||||
await waitForRoom(win, win.mxMatrixClientPeg.get(), roomId, (room) => {
|
||||
const events = room.getLiveTimeline().getEvents();
|
||||
return events.some(
|
||||
(e) =>
|
||||
|
@ -207,7 +184,7 @@ describe("Widget Events", () => {
|
|||
|
||||
// widget should receive updated 'm.room.topic' event after re-invite
|
||||
cy.window().then(async (win) => {
|
||||
await waitForRoom(win, roomId, (room) => {
|
||||
await waitForRoom(win, win.mxMatrixClientPeg.get(), roomId, (room) => {
|
||||
const events = room.getLiveTimeline().getEvents();
|
||||
return events.some(
|
||||
(e) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue