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

Commit 88d5b83

Browse files
committed
Refactor test code into method
1 parent da1b493 commit 88d5b83

File tree

15 files changed

+43
-38
lines changed

15 files changed

+43
-38
lines changed

playwright/e2e/chat-export/html-export.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test.describe("HTML Export", () => {
108108
page.locator(".mx_EventTile_last .mx_MTextBody .mx_EventTile_body").getByText("Testing 9"),
109109
).toBeVisible();
110110

111-
await page.getByRole("button", { name: "Room info" }).click();
111+
await app.toggleRoomInfoPanel();
112112
await page.getByRole("menuitem", { name: "Export Chat" }).click();
113113

114114
const downloadPromise = page.waitForEvent("download");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe("Create Room", () => {
3636
await dialog.getByRole("button", { name: "Create room" }).click();
3737

3838
await expect(page).toHaveURL(/\/#\/room\/#test-room-1:localhost/);
39-
const header = page.locator(".mx_LegacyRoomHeader");
39+
const header = page.locator(".mx_RoomHeader");
4040
await expect(header).toContainText(name);
4141
await expect(header).toContainText(topic);
4242
});

playwright/e2e/crypto/utils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,6 @@ export async function createRoom(page: Page, roomName: string, isEncrypted: bool
329329
}
330330
}
331331

332-
/**
333-
* Open the room info panel and return the panel element
334-
* @param page - the page to use
335-
*/
336-
export const openRoomInfo = async (page: Page) => {
337-
await page.getByRole("button", { name: "Room info" }).click();
338-
return page.locator(".mx_RightPanel");
339-
};
340-
341332
/**
342333
* Configure the given MatrixClient to auto-accept any invites
343334
* @param client - the client to configure
@@ -357,10 +348,11 @@ export async function autoJoin(client: Client) {
357348
* @param page - the page to use
358349
* @param bob - the user to verify
359350
*/
360-
export const verify = async (page: Page, bob: Bot) => {
351+
export const verify = async (app: ElementAppPage, bob: Bot) => {
352+
const page = app.page;
361353
const bobsVerificationRequestPromise = waitForVerificationRequest(bob);
362354

363-
const roomInfo = await openRoomInfo(page);
355+
const roomInfo = await app.toggleRoomInfoPanel();
364356
await page.locator(".mx_RightPanelTabs").getByText("People").click();
365357
await roomInfo.getByText("Bob").click();
366358
await roomInfo.getByRole("button", { name: "Verify" }).click();

playwright/e2e/integration-manager/get-openid-token.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ test.describe("Integration Manager: Get OpenID Token", () => {
118118
await app.viewRoomByName(ROOM_NAME);
119119
});
120120

121-
test("should successfully obtain an openID token", async ({ page }) => {
122-
await openIntegrationManager(page);
121+
test("should successfully obtain an openID token", async ({ page, app }) => {
122+
await openIntegrationManager(app);
123123
await sendActionFromIntegrationManager(page, integrationManagerUrl);
124124

125125
const iframe = page.frameLocator(`iframe[src*="${integrationManagerUrl}"]`);

playwright/e2e/integration-manager/kick.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ test.describe("Integration Manager: Kick", () => {
167167
await app.client.inviteUser(room.roomId, targetUser.credentials.userId);
168168
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
169169

170-
await openIntegrationManager(page);
170+
await openIntegrationManager(app);
171171
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
172172
await closeIntegrationManager(page, integrationManagerUrl);
173173
await expectKickedMessage(page, true);
@@ -185,7 +185,7 @@ test.describe("Integration Manager: Kick", () => {
185185
},
186186
});
187187

188-
await openIntegrationManager(page);
188+
await openIntegrationManager(app);
189189
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
190190
await closeIntegrationManager(page, integrationManagerUrl);
191191
await expectKickedMessage(page, false);
@@ -197,7 +197,7 @@ test.describe("Integration Manager: Kick", () => {
197197
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
198198
await targetUser.leave(room.roomId);
199199

200-
await openIntegrationManager(page);
200+
await openIntegrationManager(app);
201201
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
202202
await closeIntegrationManager(page, integrationManagerUrl);
203203
await expectKickedMessage(page, false);
@@ -209,7 +209,7 @@ test.describe("Integration Manager: Kick", () => {
209209
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
210210
await app.client.ban(room.roomId, targetUser.credentials.userId);
211211

212-
await openIntegrationManager(page);
212+
await openIntegrationManager(app);
213213
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
214214
await closeIntegrationManager(page, integrationManagerUrl);
215215
await expectKickedMessage(page, false);
@@ -218,7 +218,7 @@ test.describe("Integration Manager: Kick", () => {
218218
test("should no-op if the target was never a room member", async ({ page, app, bot: targetUser, room }) => {
219219
await app.viewRoomByName(ROOM_NAME);
220220

221-
await openIntegrationManager(page);
221+
await openIntegrationManager(app);
222222
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
223223
await closeIntegrationManager(page, integrationManagerUrl);
224224
await expectKickedMessage(page, false);

playwright/e2e/integration-manager/read_events.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ test.describe("Integration Manager: Read Events", () => {
142142

143143
// Send a state event
144144
const sendEventResponse = await app.client.sendStateEvent(room.roomId, eventType, eventContent, stateKey);
145-
await openIntegrationManager(page);
145+
await openIntegrationManager(app);
146146

147147
// Read state events
148148
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);
@@ -162,7 +162,7 @@ test.describe("Integration Manager: Read Events", () => {
162162

163163
// Send a state event
164164
const sendEventResponse = await app.client.sendStateEvent(room.roomId, eventType, eventContent, stateKey);
165-
await openIntegrationManager(page);
165+
await openIntegrationManager(app);
166166

167167
// Read state events
168168
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);
@@ -196,7 +196,7 @@ test.describe("Integration Manager: Read Events", () => {
196196
app.client.sendStateEvent(room.roomId, eventType, eventContent3, stateKey3),
197197
]);
198198

199-
await openIntegrationManager(page);
199+
await openIntegrationManager(app);
200200

201201
// Read state events
202202
await sendActionFromIntegrationManager(
@@ -217,11 +217,11 @@ test.describe("Integration Manager: Read Events", () => {
217217
await expect(iframe.locator("#message-response")).toContainText(`"content":${JSON.stringify(eventContent3)}`);
218218
});
219219

220-
test("should fail to read an event type which is not allowed", async ({ page, room }) => {
220+
test("should fail to read an event type which is not allowed", async ({ page, app, room }) => {
221221
const eventType = "com.example.event";
222222
const stateKey = "";
223223

224-
await openIntegrationManager(page);
224+
await openIntegrationManager(app);
225225

226226
// Read state events
227227
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);

playwright/e2e/integration-manager/send_event.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test.describe("Integration Manager: Send Event", () => {
137137
);
138138

139139
await app.viewRoomByName(ROOM_NAME);
140-
await openIntegrationManager(page);
140+
await openIntegrationManager(app);
141141
});
142142

143143
test("should send a state event", async ({ page, app, room }) => {

playwright/e2e/integration-manager/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import type { Page } from "@playwright/test";
17+
import type { ElementAppPage } from "../../pages/ElementAppPage";
1818

19-
export async function openIntegrationManager(page: Page) {
20-
await page.getByRole("button", { name: "Room info" }).click();
19+
export async function openIntegrationManager(app: ElementAppPage) {
20+
const { page } = app;
21+
await app.toggleRoomInfoPanel();
2122
await page
2223
.locator(".mx_RoomSummaryCard_appsGroup")
2324
.getByRole("button", { name: "Add widgets, bridges & bots" })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe("Invite dialog", function () {
3636
await expect(page.getByText("Hanako created and configured the room.")).toBeVisible();
3737

3838
// Open the room info panel
39-
await page.getByRole("button", { name: "Room info" }).click();
39+
await app.toggleRoomInfoPanel();
4040

4141
await page.locator(".mx_BaseCard").getByRole("menuitem", { name: "Invite" }).click();
4242

playwright/e2e/lazy-loading/lazy-loading.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ test.describe("Lazy Loading", () => {
7878
}
7979
}
8080

81-
async function openMemberlist(page: Page): Promise<void> {
82-
await page.locator(".mx_LegacyRoomHeader").getByRole("button", { name: "Room info" }).click();
81+
async function openMemberlist(app: ElementAppPage): Promise<void> {
82+
await app.toggleRoomInfoPanel();
83+
const { page } = app;
8384
await page.locator(".mx_RightPanelTabs").getByText("People").click();
8485
}
8586

0 commit comments

Comments
 (0)