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

Commit

Permalink
Add e2e test to pin/unpin from message action bar
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Aug 21, 2024
1 parent c41d69d commit 5af7247
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
26 changes: 24 additions & 2 deletions playwright/e2e/pinned-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,35 @@ export class Helpers {
}

/**
* Pin the given message
* Pin the given message from the quick actions
* @param message
* @param unpin
*/
async pinMessageFromQuickActions(message: string, unpin = false) {
const timelineMessage = this.page.locator(".mx_MTextBody", { hasText: message });
await timelineMessage.hover();
await this.page.getByRole("button", { name: unpin ? "Unpin" : "Pin", exact: true }).click();
}

/**
* Pin the given messages from the quick actions
* @param messages
* @param unpin
*/
async pinMessagesFromQuickActions(messages: string[], unpin = false) {
for (const message of messages) {
await this.pinMessageFromQuickActions(message, unpin);
}
}

/**
* Pin the given message from the contextual menu
* @param message
*/
async pinMessage(message: string) {
const timelineMessage = this.page.locator(".mx_MTextBody", { hasText: message });
await timelineMessage.click({ button: "right" });
await this.page.getByRole("menuitem", { name: "Pin" }).click();
await this.page.getByRole("menuitem", { name: "Pin", exact: true }).click();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions playwright/e2e/pinned-messages/pinned-messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@ test.describe("Pinned messages", () => {
await util.backPinnedMessagesList();
await util.assertPinnedCountInRoomInfo(0);
});

test("should be able to pin and unpin from the quick actions", async ({ page, app, room1, util }) => {
await util.goTo(room1);
await util.receiveMessages(room1, ["Msg1", "Msg2", "Msg3", "Msg4"]);
await util.pinMessagesFromQuickActions(["Msg1"]);
await util.openRoomInfo();
await util.assertPinnedCountInRoomInfo(1);

await util.pinMessagesFromQuickActions(["Msg1"], true);
await util.assertPinnedCountInRoomInfo(0);
});
});

0 comments on commit 5af7247

Please sign in to comment.