push to maple-street
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { signInAs, resetDb, BASE } from "./dev";
|
||||
|
||||
/**
|
||||
* Announcements: an admin posts a published update; a volunteer sees it but no
|
||||
* authoring controls; unpublishing hides it from the volunteer feed.
|
||||
*/
|
||||
|
||||
const title = `E2E announcement ${Date.now()}`;
|
||||
|
||||
test.describe("announcements", () => {
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
await resetDb(page);
|
||||
await context.close();
|
||||
});
|
||||
|
||||
test("an admin creates and publishes an announcement", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1200, height: 900 });
|
||||
await signInAs(page, "admin@glenloch.local");
|
||||
await page.goto(`${BASE}/announcements`);
|
||||
|
||||
await page.getByLabel("Title").fill(title);
|
||||
await page
|
||||
.getByLabel("Message")
|
||||
.fill("Doors open 30 minutes early this Sunday.");
|
||||
await page.getByRole("button", { name: "Create announcement" }).click();
|
||||
|
||||
await expect(page.getByRole("heading", { name: title })).toBeVisible();
|
||||
await expect(page.getByText("Published")).toBeVisible();
|
||||
});
|
||||
|
||||
test("a volunteer sees the post but no authoring controls", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1200, height: 900 });
|
||||
await signInAs(page, "avery@glenloch.local");
|
||||
await page.goto(`${BASE}/announcements`);
|
||||
|
||||
await expect(page.getByRole("heading", { name: title })).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Create announcement" }),
|
||||
).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: "Unpublish" })).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("unpublishing hides the post from volunteers", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1200, height: 900 });
|
||||
await signInAs(page, "admin@glenloch.local");
|
||||
await page.goto(`${BASE}/announcements`);
|
||||
await page.getByRole("button", { name: "Unpublish" }).first().click();
|
||||
|
||||
await expect(page.getByText("Draft")).toBeVisible();
|
||||
|
||||
await signInAs(page, "avery@glenloch.local");
|
||||
await page.goto(`${BASE}/announcements`);
|
||||
await expect(page.getByRole("heading", { name: title })).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user