forked from lukevella/rallly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-delete-poll.spec.ts
55 lines (39 loc) · 1.59 KB
/
create-delete-poll.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { expect, test } from "@playwright/test";
test("should be able to create a new poll and delete it", async ({ page }) => {
await page.goto("/new");
await page.type('[placeholder="Monthly Meetup"]', "Monthly Meetup");
// click on label to focus on input
await page.click('text="Location"');
await page.keyboard.type("Joe's Coffee Shop");
await page.click('text="Description"');
await page.keyboard.type("This is a test description");
await page.click('text="Continue"');
await page.click('[title="Next month"]');
// Select a few days
await page.click("text=/^5$/");
await page.click("text=/^7$/");
await page.click("text=/^10$/");
await page.click("text=/^15$/");
await page.click('text="Continue"');
await page.type('[placeholder="Jessie Smith"]', "John");
await page.type(
'[placeholder="[email protected]"]',
);
await page.click('text="Create poll"');
await expect(page.locator("data-testid=poll-title")).toHaveText(
"Monthly Meetup",
);
// let's delete the poll we just created
await page.click("text=Manage");
await page.click("text=Delete poll");
const deletePollForm = page.locator("data-testid=delete-poll-form");
// button should be disabled
await expect(deletePollForm.locator("text=Delete poll")).toBeDisabled();
// enter confirmation text
await page.type("[placeholder=delete-me]", "delete-me");
// button should now be enabled
await deletePollForm.locator("text=Delete poll").click();
// expect delete message to appear
await expect(page.locator("text=Deleted poll")).toBeVisible();
});