forked from lukevella/rallly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvote-and-comment.spec.ts
38 lines (32 loc) · 1.46 KB
/
vote-and-comment.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { expect, test } from "@playwright/test";
test("should be able to vote and comment on a poll", async ({ page }) => {
const touchRequest = page.waitForRequest(
(request) =>
request.method() === "POST" &&
request.url().includes("/api/trpc/polls.touch"),
);
await page.goto("/demo");
await expect(page.locator('text="Lunch Meeting"')).toBeVisible();
await page.type('[placeholder="Your name…"]', "Test user");
// There is a hidden checkbox (nth=0) that exists so that the behaviour of the form is consistent even
// when we only have a single option/checkbox.
await page.locator("data-testid=vote-selector >> nth=0").click();
await page.locator("data-testid=vote-selector >> nth=2").click();
await page.click("text='Save'");
await expect(page.locator("text='Test user'")).toBeVisible();
await expect(page.locator("text=Guest")).toBeVisible();
await expect(
page.locator("data-testid=participant-row >> nth=4").locator("text=You"),
).toBeVisible();
await page.type(
"[placeholder='Leave a comment on this poll (visible to everyone)']",
"This is a comment!",
);
await page.type('[placeholder="Your name…"]', "Test user");
await page.click("text='Comment'");
const comment = page.locator("data-testid=comment");
await expect(comment.locator("text='This is a comment!'")).toBeVisible();
await expect(comment.locator("text=You")).toBeVisible();
// make sure call to touch RPC is made
await touchRequest;
});