Remove use of KnownMembership from playwright tests

This commit is contained in:
Andy Balaam 2024-03-18 16:32:36 +00:00
parent d3c0435446
commit 5cd7743fcb
5 changed files with 10 additions and 17 deletions

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { KnownMembership } from "matrix-js-sdk/src/types";
import type { Page } from "@playwright/test";
import { test, expect } from "../../element-web-test";
import {
@ -89,7 +87,7 @@ const bobJoin = async (page: Page, bob: Bot) => {
async function autoJoin(client: Client) {
await client.evaluate((cli) => {
cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => {
if (member.membership === KnownMembership.Invite && member.userId === cli.getUserId()) {
if (member.membership === "invite" && member.userId === cli.getUserId()) {
cli.joinRoom(member.roomId);
}
});

View file

@ -16,7 +16,6 @@ limitations under the License.
import jsQR from "jsqr";
import { type Preset, type Visibility } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import type { JSHandle, Locator, Page } from "@playwright/test";
import type { VerificationRequest, Verifier } from "matrix-js-sdk/src/crypto-api";
@ -263,7 +262,7 @@ test.describe("User verification", () => {
const bobVerificationRequest = await bob.evaluateHandle(
async (client, { dmRoomId, aliceCredentials }) => {
const room = client.getRoom(dmRoomId);
while (room.getMember(aliceCredentials.userId)?.membership !== KnownMembership.Join) {
while (room.getMember(aliceCredentials.userId)?.membership !== "join") {
await new Promise((resolve) => {
room.once(window.matrixcs.RoomStateEvent.Members, resolve);
});

View file

@ -17,7 +17,6 @@ limitations under the License.
*/
import { type Visibility } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { test, expect } from "../../element-web-test";
import { waitForRoom } from "../utils";
@ -75,7 +74,7 @@ test.describe("Knock Into Room", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Knock &&
e.getContent()?.membership === "knock" &&
e.getContent()?.displayname === "Alice",
);
});
@ -110,7 +109,7 @@ test.describe("Knock Into Room", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Knock &&
e.getContent()?.membership === "knock" &&
e.getContent()?.displayname === "Alice",
);
});
@ -152,7 +151,7 @@ test.describe("Knock Into Room", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Knock &&
e.getContent()?.membership === "knock" &&
e.getContent()?.displayname === "Alice",
);
});
@ -194,7 +193,7 @@ test.describe("Knock Into Room", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Knock &&
e.getContent()?.membership === "knock" &&
e.getContent()?.displayname === "Alice",
);
});
@ -260,7 +259,7 @@ test.describe("Knock Into Room", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Knock &&
e.getContent()?.membership === "knock" &&
e.getContent()?.displayname === "Alice",
);
});

View file

@ -16,8 +16,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { KnownMembership } from "matrix-js-sdk/src/types";
import { test, expect } from "../../element-web-test";
import { waitForRoom } from "../utils";
@ -75,7 +73,7 @@ test.describe("Manage Knocks", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Leave &&
e.getContent()?.membership === "leave" &&
e.getContent()?.displayname === "Bob",
);
});
@ -112,7 +110,7 @@ test.describe("Manage Knocks", () => {
return events.some(
(e) =>
e.getType() === "m.room.member" &&
e.getContent()?.membership === KnownMembership.Leave &&
e.getContent()?.membership === "leave" &&
e.getContent()?.displayname === "Bob",
);
});

View file

@ -17,7 +17,6 @@ limitations under the License.
import { JSHandle, Page } from "@playwright/test";
import { uniqueId } from "lodash";
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import type { Logger } from "matrix-js-sdk/src/logger";
import type { SecretStorageKeyDescription } from "matrix-js-sdk/src/secret-storage";
@ -179,7 +178,7 @@ export class Bot extends Client {
if (opts.autoAcceptInvites) {
cli.on(window.matrixcs.RoomMemberEvent.Membership, (event, member) => {
if (member.membership === KnownMembership.Invite && member.userId === cli.getUserId()) {
if (member.membership === "invite" && member.userId === cli.getUserId()) {
cli.joinRoom(member.roomId);
}
});