|
1 | 1 | import { test, expect } from "playwright/test"; |
| 2 | +import { randomUUID } from "crypto"; |
2 | 3 |
|
3 | 4 | test.describe("Unauthenticated Articles Page", () => { |
4 | 5 | test.beforeEach(async ({ page }) => { |
@@ -57,6 +58,24 @@ test.describe("Unauthenticated Articles Page", () => { |
57 | 58 | await expect(page.getByText("Sponsorship")).toBeVisible(); |
58 | 59 | await expect(page.getByText("Code Of Conduct")).toBeVisible(); |
59 | 60 | }); |
| 61 | + |
| 62 | + test("Should not be able to post a comment on an article", async ({ |
| 63 | + page, |
| 64 | + }) => { |
| 65 | + await page.goto("http://localhost:3000"); |
| 66 | + // Waits for articles to be loaded |
| 67 | + await expect(page.getByText("Read Full Article").first()).toBeVisible(); |
| 68 | + await page.getByText("Read Full Article").first().click(); |
| 69 | + await page.waitForURL(/^http:\/\/localhost:3000\/articles\/.*$/); |
| 70 | + |
| 71 | + await expect(page.getByPlaceholder("What do you think?")).toBeHidden(); |
| 72 | + |
| 73 | + await expect(page.getByText("Hey! 👋")).toBeVisible(); |
| 74 | + await expect(page.getByText("Got something to say?")).toBeVisible(); |
| 75 | + await expect( |
| 76 | + page.getByText("Sign in or sign up to leave a comment"), |
| 77 | + ).toBeVisible(); |
| 78 | + }); |
60 | 79 | }); |
61 | 80 |
|
62 | 81 | test.describe("Authenticated Articles Page", () => { |
@@ -186,4 +205,19 @@ test.describe("Authenticated Articles Page", () => { |
186 | 205 | await expect(page.getByLabel("like-trigger")).toBeVisible(); |
187 | 206 | await expect(page.getByLabel("bookmark-trigger")).toBeVisible(); |
188 | 207 | }); |
| 208 | + |
| 209 | + test("Should post a comment on an article", async ({ page }, workerInfo) => { |
| 210 | + const commentContent = `This is a great read. Thanks for posting! Sent from ${workerInfo.project.name} + ${randomUUID()}`; |
| 211 | + await page.goto("http://localhost:3000"); |
| 212 | + // Waits for articles to be loaded |
| 213 | + await expect(page.getByText("Read Full Article").first()).toBeVisible(); |
| 214 | + await page.getByText("Read Full Article").first().click(); |
| 215 | + await page.waitForURL(/^http:\/\/localhost:3000\/articles\/.*$/); |
| 216 | + |
| 217 | + await expect(page.getByPlaceholder("What do you think?")).toBeVisible(); |
| 218 | + await page.getByPlaceholder("What do you think?").fill(commentContent); |
| 219 | + await page.getByRole("button", { name: "Submit" }).click(); |
| 220 | + |
| 221 | + await expect(page.getByText(commentContent)).toBeVisible(); |
| 222 | + }); |
189 | 223 | }); |
0 commit comments