Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1c72bb9

Browse files
authored
Migrate one-to-one-chat.spec.ts from Cypress to Playwright (#11953)
Signed-off-by: Michael Telatynski <[email protected]>
1 parent dbae856 commit 1c72bb9

File tree

5 files changed

+57
-74
lines changed

5 files changed

+57
-74
lines changed

cypress/e2e/one-to-one-chat/one-to-one-chat.spec.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Copyright 2023 Ahmad Kadri
3+
Copyright 2023 Nordeck IT + Consulting GmbH.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
import { test as base, expect } from "../../element-web-test";
19+
import { Credentials } from "../../plugins/homeserver";
20+
21+
const test = base.extend<{
22+
user2?: Credentials;
23+
}>({});
24+
25+
test.describe("1:1 chat room", () => {
26+
test.use({
27+
displayName: "Jeff",
28+
user2: async ({ homeserver }, use) => {
29+
const credentials = await homeserver.registerUser("user1234", "p4s5W0rD", "Timmy");
30+
await use(credentials);
31+
},
32+
});
33+
34+
test.beforeEach(async ({ page, user2, user }) => {
35+
await page.goto(`/#/user/${user2.userId}?action=chat`);
36+
});
37+
38+
test("should open new 1:1 chat room after leaving the old one", async ({ page, user2 }) => {
39+
// leave 1:1 chat room
40+
await page.locator(".mx_LegacyRoomHeader_nametext").getByText(user2.displayName).click();
41+
await page.getByRole("menuitem", { name: "Leave" }).click();
42+
await page.getByRole("button", { name: "Leave" }).click();
43+
44+
// wait till the room was left
45+
await expect(
46+
page.getByRole("group", { name: "Historical" }).locator(".mx_RoomTile").getByText(user2.displayName),
47+
).toBeVisible();
48+
49+
// open new 1:1 chat room
50+
await page.goto(`/#/user/${user2.userId}?action=chat`);
51+
await expect(page.locator(".mx_LegacyRoomHeader_nametext").getByText(user2.displayName)).toBeVisible();
52+
});
53+
});

playwright/element-web-test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ export const test = base.extend<
5858
startHomeserverOpts: StartHomeserverOpts | string;
5959
homeserver: HomeserverInstance;
6060
oAuthServer: { port: number };
61-
user: Credentials & {
62-
displayName: string;
63-
};
61+
user: Credentials;
6462
displayName?: string;
6563
app: ElementAppPage;
6664
mailhog?: { api: mailhog.API; instance: Instance };
@@ -144,10 +142,7 @@ export const test = base.extend<
144142

145143
await page.waitForSelector(".mx_MatrixChat", { timeout: 30000 });
146144

147-
await use({
148-
...credentials,
149-
displayName,
150-
});
145+
await use(credentials);
151146
},
152147

153148
axe: async ({ page }, use) => {

playwright/plugins/homeserver/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ export interface Credentials {
5555
deviceId: string;
5656
homeServer: string;
5757
password: string | null; // null for password-less users
58+
displayName?: string;
5859
}

playwright/plugins/homeserver/synapse/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ export class Synapse implements Homeserver, HomeserverInstance {
193193
userId: data.user_id,
194194
deviceId: data.device_id,
195195
password,
196+
displayName,
196197
};
197198
}
198199
}

0 commit comments

Comments
 (0)