-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
99 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { expect } from "@playwright/test"; | ||
import { test } from "../lib/cachebust-test"; | ||
import { publishingAppUrl, waitForUrlToBeAvailable } from "../lib/utils"; | ||
|
||
test.describe("Content Object Store", { tag: ["@app-content-object-store", "@integration"] }, () => { | ||
const title = `E2E TEST EMAIL - ${new Date().getTime()}`; | ||
|
||
test.use({ baseURL: `${publishingAppUrl("whitehall-admin")}/government/admin/content-object-store/` }); | ||
|
||
test("Can create and embed an object", async ({ page }) => { | ||
await test.step("Logging in", async () => { | ||
await page.goto("./"); | ||
await expect(page.getByRole("banner", { text: "Content Object Store" })).toBeVisible(); | ||
await expect(page.getByRole("heading", { name: "All content blocks" })).toBeVisible(); | ||
}); | ||
|
||
await test.step("Can create an object", async () => { | ||
await page.goto("./"); | ||
await page.getByRole("button", { text: "Create new object" }).click(); | ||
await page.getByLabel("Email address").click(); | ||
await page.getByRole("button", { text: "Save and continute" }).click(); | ||
|
||
await page.getByLabel("Title").fill(title); | ||
await page.getByLabel("Email address").fill(`foo${new Date().getTime()}@example.com`); | ||
|
||
await page.getByRole("combobox").click(); | ||
await page.getByRole("option", { name: "Academy for Social Justice" }).click(); | ||
await page.getByRole("button", { name: "Save and continue" }).click(); | ||
await page.getByRole("button", { name: "Accept and publish" }).click(); | ||
|
||
await expect(page.getByRole("alert", { text: "Email address created" })).toBeVisible(); | ||
}); | ||
|
||
await test.step("Can embed an object", async () => { | ||
const summaryCardRows = page | ||
.locator(".govuk-summary-list") | ||
.filter({ hasText: title }) | ||
.locator(".govuk-summary-list__row"); | ||
|
||
const emailAddress = await summaryCardRows | ||
.filter({ hasText: "Email address" }) | ||
.locator(".govuk-summary-list__value") | ||
.textContent(); | ||
|
||
const embedCode = await summaryCardRows | ||
.filter({ hasText: "Embed code" }) | ||
.locator(".govuk-summary-list__value") | ||
.textContent(); | ||
|
||
await page.goto(publishingAppUrl("whitehall-admin")); | ||
|
||
await page.getByRole("link", { name: "New document" }).click(); | ||
await page.getByLabel("News article").check(); | ||
await page.getByRole("button", { name: "Next" }).click(); | ||
|
||
await page.locator(".choices__item").first().click(); | ||
await page.getByRole("option", { name: "News story", exact: true }).click(); | ||
|
||
const documentTitle = `TEST DOCUMENT - ${new Date().getTime()}`; | ||
|
||
await page.getByLabel("Title (required)").fill(documentTitle); | ||
await page.getByLabel("Summary (required)").fill("Some summary"); | ||
await page.getByLabel("Body (required)").fill(`Text goes here - ${embedCode}`); | ||
await page.getByRole("button", { name: "Save and go to document" }).click(); | ||
await page.getByRole("link", { name: "Add tags" }).click(); | ||
await page | ||
.locator('[id="taxonomy_tag_form\\[taxons\\]"]') | ||
.getByRole("list") | ||
.locator("div") | ||
.filter({ hasText: "Brexit" }) | ||
.click(); | ||
await page.getByRole("button", { name: "Save" }).click(); | ||
await page.getByRole("button", { name: "Force publish" }).click(); | ||
await page.getByLabel("Reason for force publishing").fill("Some reason"); | ||
await page.getByRole("button", { name: "Force publish" }).click(); | ||
|
||
await page.getByRole("link", { name: documentTitle }).click(); | ||
const url = await waitForUrlToBeAvailable( | ||
page, | ||
await page.getByRole("link", { name: "View on website" }).getAttribute("href") | ||
); | ||
|
||
await page.goto(url); | ||
await expect(page.getByText(emailAddress)).toBeVisible(); | ||
}); | ||
}); | ||
}); |