-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding E2E tests for my-posts page Part 1 (#1187)
- Loading branch information
1 parent
2df1fd9
commit ac34024
Showing
6 changed files
with
125 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,56 @@ | ||
import test from "@playwright/test"; | ||
import { loggedInAsUserOne } from "./utils"; | ||
import test, { expect } from "@playwright/test"; | ||
import { articleExcerpt, loggedInAsUserOne } from "./utils"; | ||
|
||
test.describe("Unauthenticated my-posts Page", () => { | ||
// | ||
// Replace with tests for unauthenticated users | ||
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); | ||
}); | ||
// | ||
// Replace with tests for authenticated users | ||
|
||
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const articleContent = | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vitae ipsum id metus vestibulum rutrum eget a diam. Integer eget vulputate risus, ac convallis nulla. Mauris sed augue nunc. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam congue posuere tempor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut ac augue non libero ullamcorper ornare. Ut commodo ligula vitae malesuada maximus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam sagittis justo non justo placerat, a dapibus sapien volutpat. Nullam ullamcorper sodales justo sed."; | ||
|
||
export const articleExcerpt = "Lorem ipsum dolor sit amet"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./utils"; | ||
export * from "./constants"; |