Skip to content

Commit 04d4b6e

Browse files
committed
Added e2e test, minor changes to existing tests
1 parent d427128 commit 04d4b6e

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

tests/src/end-to-end/comments/comments.test.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,54 @@ import { test } from "../../setup/setupScript.js";
33
import { COMMENTS_URL, LINK_BUTTON_SELECTOR } from "../../utils/const.js";
44
import { focusOnEditor } from "../../utils/editor.js";
55

6+
const EMOJI_BUTTON_SELECTOR = "em-emoji-picker button[aria-posinset]";
7+
68
test.beforeEach(async ({ page }) => {
79
await page.goto(COMMENTS_URL);
810
});
911

1012
test.describe("Check Comments functionality", () => {
13+
test("Should be able to add reactions", async ({ page }) => {
14+
await focusOnEditor(page);
15+
16+
await page.keyboard.type("hello");
17+
await page.locator("text=hello").dblclick();
18+
19+
await page.click('[data-test="addcomment"]');
20+
await page.waitForSelector(".bn-thread");
21+
22+
await page.keyboard.type("test comment");
23+
await page.click('button[data-test="save"]');
24+
25+
// Wait for comment composer to close.
26+
await expect(page.locator(".bn-thread")).toHaveCount(0);
27+
28+
await page.locator("span.bn-thread-mark").first().click();
29+
await expect(page.locator(".bn-thread-comment")).toBeVisible();
30+
31+
// Hover comment to reveal action toolbar.
32+
await page.locator(".bn-thread-comment").first().hover();
33+
await expect(page.locator('[data-test="addreaction"]')).toBeVisible();
34+
35+
// Add a reaction via the action toolbar's add-reaction button.
36+
await page.click('[data-test="addreaction"]');
37+
await expect(page.locator(EMOJI_BUTTON_SELECTOR).first()).toBeVisible();
38+
await page.locator(EMOJI_BUTTON_SELECTOR).first().click();
39+
await expect(page.locator("em-emoji-picker")).toHaveCount(0);
40+
await expect(page.locator(".bn-comment-reaction")).toHaveCount(1);
41+
42+
// Add a second reaction via the add-reaction badge.
43+
await page.locator(".bn-thread-comment").first().hover();
44+
await page.click(".bn-comment-add-reaction");
45+
await expect(page.locator(EMOJI_BUTTON_SELECTOR).first()).toBeVisible();
46+
47+
// Pick a different emoji so it's added as a new reaction rather than
48+
// toggling the first one off.
49+
await page.locator(EMOJI_BUTTON_SELECTOR).nth(5).click();
50+
await expect(page.locator("em-emoji-picker")).toHaveCount(0);
51+
await expect(page.locator(".bn-comment-reaction")).toHaveCount(2);
52+
});
53+
1154
test("Should preserve existing comments when adding a link", async ({
1255
page,
1356
}) => {
@@ -30,7 +73,7 @@ test.describe("Check Comments functionality", () => {
3073
await page.keyboard.type("https://example.com");
3174
await page.keyboard.press("Enter");
3275

33-
await expect(await page.locator("span.bn-thread-mark")).toBeVisible();
76+
await expect(page.locator("span.bn-thread-mark")).toBeVisible();
3477
});
3578

3679
test("Should select thread on first click and open link on second click", async ({
@@ -64,6 +107,7 @@ test.describe("Check Comments functionality", () => {
64107
await page.keyboard.press("ArrowDown");
65108
await page.waitForTimeout(500);
66109
await expect(page.locator(".bn-thread-mark-selected")).toHaveCount(0);
110+
await expect(page.locator(".bn-formatting-toolbar")).toBeHidden();
67111

68112
const link = page.locator('a[data-inline-content-type="link"]').first();
69113

0 commit comments

Comments
 (0)