forked from codu-code/codu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy-posts.spec.ts
More file actions
56 lines (47 loc) · 2.1 KB
/
my-posts.spec.ts
File metadata and controls
56 lines (47 loc) · 2.1 KB
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
56
import test, { expect } from "@playwright/test";
import { articleExcerpt, loggedInAsUserOne } from "./utils";
test.describe("Unauthenticated my-posts Page", () => {
test("Unauthenticated users should be redirected to get-started page if they access my-posts directly", async ({
page,
}) => {
await page.goto("http://localhost:3000/my-posts");
await page.waitForURL("http://localhost:3000/get-started");
expect(page.url()).toEqual("http://localhost:3000/get-started");
});
});
test.describe("Authenticated my-posts Page", () => {
test.beforeEach(async ({ page }) => {
await loggedInAsUserOne(page);
});
test("Tabs for different type of posts should be visible", async ({
page,
}) => {
await page.goto("http://localhost:3000/my-posts");
await expect(page.getByRole("link", { name: "Drafts" })).toBeVisible();
await expect(page.getByRole("link", { name: "Scheduled" })).toBeVisible();
await expect(page.getByRole("link", { name: "Published" })).toBeVisible();
});
test("Different article tabs should correctly display articles matching that type", async ({
page,
}) => {
await page.goto("http://localhost:3000/my-posts");
await expect(page.getByRole("link", { name: "Drafts" })).toBeVisible();
await expect(page.getByRole("link", { name: "Scheduled" })).toBeVisible();
await expect(page.getByRole("link", { name: "Published" })).toBeVisible();
await page.getByRole("link", { name: "Drafts" }).click();
await expect(
page.getByRole("heading", { name: "Draft Article" }),
).toBeVisible();
await expect(page.getByText(articleExcerpt)).toBeVisible();
await page.getByRole("link", { name: "Scheduled" }).click();
await expect(
page.getByRole("heading", { name: "Scheduled Article" }),
).toBeVisible();
await expect(page.getByText(articleExcerpt)).toBeVisible();
await page.getByRole("link", { name: "Published" }).click();
await expect(
page.getByRole("heading", { name: "Published Article" }),
).toBeVisible();
await expect(page.getByText(articleExcerpt, { exact: true })).toBeVisible();
});
});