Skip to content

Commit f2c288a

Browse files
committed
Update playwright tests
1 parent 6b9b0fd commit f2c288a

File tree

9 files changed

+50
-11
lines changed

9 files changed

+50
-11
lines changed

apps/web/playwright/e2e/crypto/crypto.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const startDMWithBob = async (page: Page, bob: Bot) => {
2727
await page.getByRole("option", { name: bob.credentials.displayName }).click();
2828
await expect(page.getByTestId("invite-dialog-input-wrapper").getByText("Bob")).toBeVisible();
2929
await page.getByRole("button", { name: "Go" }).click();
30+
31+
await expect(page.getByRole("heading", { name: "Start a chat with this new contact?" })).toBeVisible();
32+
await page.getByRole("button", { name: "Continue" }).click();
3033
};
3134

3235
const testMessages = async (page: Page, bob: Bot, bobRoomId: string) => {

apps/web/playwright/e2e/crypto/history-sharing.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test.describe("History sharing", function () {
4949
await sendMessageInCurrentRoom(alicePage, "A message from Alice");
5050

5151
// Send the invite to Bob
52-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
52+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
5353

5454
// Bob accepts the invite
5555
await bobPage.getByRole("option", { name: "TestRoom" }).click();
@@ -105,7 +105,7 @@ test.describe("History sharing", function () {
105105

106106
// Alice invites Bob, and Bob accepts
107107
const roomId = await aliceElementApp.getCurrentRoomIdFromUrl();
108-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
108+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
109109
await bobPage.getByRole("option", { name: "TestRoom" }).click();
110110
await bobPage.getByRole("button", { name: "Accept" }).click();
111111

@@ -143,7 +143,7 @@ test.describe("History sharing", function () {
143143
await sendMessageInCurrentRoom(bobPage, "Message3: 'shared' visibility, but Bob thinks it is still 'joined'");
144144

145145
// Alice now invites Charlie
146-
await aliceElementApp.inviteUserToCurrentRoom(charlieCredentials.userId);
146+
await aliceElementApp.inviteUserToCurrentRoom(charlieCredentials.userId, { confirmUnknownUser: true });
147147
await charliePage.getByRole("option", { name: "TestRoom" }).click();
148148
await charliePage.getByRole("button", { name: "Accept" }).click();
149149

apps/web/playwright/e2e/invite/invite-dialog.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ test.describe("Invite dialog", function () {
6262
// Invite the bot
6363
await other.getByRole("button", { name: "Invite" }).click();
6464

65+
// Expect a confirmation dialog, screenshot, and dismiss
66+
await expect(
67+
page.locator(".mx_Dialog").getByRole("heading", { name: "Invite new contacts to this room?" }),
68+
).toBeVisible();
69+
await expect(page.locator(".mx_Dialog")).toMatchScreenshot("confirm-invite-new-contact.png");
70+
await page.locator(".mx_Dialog").getByRole("button", { name: "Invite" }).click();
71+
6572
// Assert that the invite dialog disappears
6673
await expect(page.locator(".mx_InviteDialog_other")).not.toBeVisible();
6774

@@ -104,6 +111,13 @@ test.describe("Invite dialog", function () {
104111
// Open a direct message UI
105112
await other.getByRole("button", { name: "Go" }).click();
106113

114+
// Expect a confirmation dialog, screenshot, and dismiss
115+
await expect(
116+
page.locator(".mx_Dialog").getByRole("heading", { name: "Start a chat with this new contact?" }),
117+
).toBeVisible();
118+
await expect(page.locator(".mx_Dialog")).toMatchScreenshot("confirm-chat-with-new-contact.png");
119+
await page.locator(".mx_Dialog").getByRole("button", { name: "Continue" }).click();
120+
107121
// Assert that the invite dialog disappears
108122
await expect(page.locator(".mx_InviteDialog_other")).not.toBeVisible();
109123

apps/web/playwright/e2e/room/create-room.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ test.describe("Create Room", () => {
5757

5858
await page.getByRole("button", { name: "Go" }).click();
5959

60+
await expect(page.getByRole("heading", { name: "Start a chat with this new contact?" })).toBeVisible();
61+
await page.getByRole("button", { name: "Continue" }).click();
62+
6063
await expect(page.getByText("Encryption enabled")).toBeVisible();
6164
await expect(page.getByText("Send your first message to")).toBeVisible();
6265

apps/web/playwright/e2e/room/room-status-bar.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ test.describe("Room Status Bar", () => {
163163
).toBeVisible();
164164
await other.getByRole("option", { name: "Alice" }).click();
165165
await other.getByRole("button", { name: "Go" }).click();
166+
167+
await expect(page.getByRole("heading", { name: "Start a chat with this new contact?" })).toBeVisible();
168+
await page.getByRole("button", { name: "Continue" }).click();
169+
166170
// Send a message to invite the bots
167171
const composer = app.getComposerField();
168172
await composer.fill("Hello");

apps/web/playwright/e2e/settings/encryption-user-tab/other-devices.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test.describe("Other people's devices section in Encryption tab", () => {
3333

3434
// Create the room and invite bob
3535
await createRoom(alicePage, "TestRoom", true);
36-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
36+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
3737

3838
// Bob accepts the invite
3939
await bobPage.getByRole("option", { name: "TestRoom" }).click();
@@ -72,7 +72,7 @@ test.describe("Other people's devices section in Encryption tab", () => {
7272

7373
// Create the room and invite bob
7474
await createRoom(alicePage, "TestRoom", true);
75-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
75+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
7676

7777
// Bob accepts the invite
7878
await bobPage.getByRole("option", { name: "TestRoom" }).click();
@@ -115,7 +115,7 @@ test.describe("Other people's devices section in Encryption tab", () => {
115115

116116
// Create the room and invite bob
117117
await createRoom(alicePage, "TestRoom", true);
118-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
118+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
119119

120120
// Bob accepts the invite and dismisses the warnings.
121121
await bobPage.getByRole("option", { name: "TestRoom" }).click();
@@ -149,7 +149,7 @@ test.describe("Other people's devices section in Encryption tab", () => {
149149

150150
// Alice creates the room and invite Bob.
151151
await createRoom(alicePage, "TestRoom", true);
152-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
152+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
153153

154154
// Bob accepts the invite.
155155
await bobPage.getByRole("option", { name: "TestRoom" }).click();
@@ -214,7 +214,7 @@ test.describe("Other people's devices section in Encryption tab", () => {
214214

215215
// Alice creates the room and invite Bob.
216216
await createRoom(alicePage, "TestRoom", true);
217-
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId);
217+
await aliceElementApp.inviteUserToCurrentRoom(bobCredentials.userId, { confirmUnknownUser: true });
218218

219219
// Bob accepts the invite.
220220
await bobPage.getByRole("option", { name: "TestRoom" }).click();

apps/web/playwright/pages/ElementAppPage.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,30 @@ export class ElementAppPage {
233233
* Open the room info panel, and use it to send an invite to the given user.
234234
*
235235
* @param userId - The user to invite to the room.
236+
* @param options - Options object
236237
*/
237-
public async inviteUserToCurrentRoom(userId: string): Promise<void> {
238+
public async inviteUserToCurrentRoom(
239+
userId: string,
240+
options?: {
241+
/** If true, expect and acknowledge "Confirm inviting new users" page */
242+
confirmUnknownUser?: boolean;
243+
},
244+
): Promise<void> {
238245
const rightPanel = await this.openRoomInfoPanel();
239246
await rightPanel.getByRole("menuitem", { name: "Invite" }).click();
240247

241-
const input = this.page.getByRole("dialog").getByTestId("invite-dialog-input");
248+
const dialogLocator = this.page.getByRole("dialog");
249+
const input = dialogLocator.getByTestId("invite-dialog-input");
242250
await input.fill(userId);
243251
await input.press("Enter");
244-
await this.page.getByRole("dialog").getByRole("button", { name: "Invite" }).click();
252+
await dialogLocator.getByRole("button", { name: "Invite" }).click();
253+
254+
if (options?.confirmUnknownUser) {
255+
await expect(
256+
dialogLocator.getByRole("heading", { name: "Invite new contacts to this room?" }),
257+
).toBeVisible();
258+
await dialogLocator.getByRole("button", { name: "Invite" }).click();
259+
}
245260
}
246261

247262
/**
31.4 KB
Loading
32 KB
Loading

0 commit comments

Comments
 (0)