-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a spec for the Content Object Store #46
Draft
pezholio
wants to merge
1
commit into
main
Choose a base branch
from
content-object-store-specs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,115 @@ | ||
import { expect } from "@playwright/test"; | ||
import { test } from "../lib/cachebust-test"; | ||
import { publishingAppUrl, waitForUrlToBeAvailable } from "../lib/utils"; | ||
|
||
test.describe("Content Block Manager", { tag: ["@app-content-object-store", "@integration"] }, () => { | ||
test.use({ baseURL: publishingAppUrl("whitehall-admin") }); | ||
|
||
test("Can create and embed an object", async ({ page }) => { | ||
await test.step("Logging in", async () => { | ||
await page.goto("/content-block-manager"); | ||
await expect(page.getByRole("banner", { text: "Content Block Manager" })).toBeVisible(); | ||
await expect(page.getByRole("heading", { name: "All content blocks" })).toBeVisible(); | ||
}); | ||
|
||
const title = await test.step("Can create an object", async () => { | ||
const title = `E2E TEST EMAIL - ${new Date().getTime()}`; | ||
|
||
await page.goto("/content-block-manager"); | ||
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("heading", { name: "Your content block is available for use" })).toBeVisible(); | ||
|
||
return title; | ||
}); | ||
|
||
const url = await test.step("Can embed an object", async () => { | ||
await page.goto("/content-block-manager"); | ||
|
||
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(); | ||
|
||
return url; | ||
}); | ||
|
||
await test.step("Dependent content updates when block content changes", async () => { | ||
await page.goto("/content-block-manager"); | ||
|
||
await page | ||
.getByRole("link") | ||
.filter({ hasText: `View/edit ${title}` }) | ||
.click(); | ||
|
||
await page.locator(".govuk-summary-list").getByRole("link").filter({ hasText: "Change" }).first().click(); | ||
|
||
const emailAddress = `foo${new Date().getTime()}@example.org`; | ||
await page.getByLabel("Email address").fill(emailAddress); | ||
await page.getByRole("button", { name: "Save and continue" }).click(); | ||
|
||
await page.getByRole("button", { name: "Save and continue" }).click(); | ||
await page.getByLabel("Publish the change now").check(); | ||
await page.getByRole("button", { name: "Accept and publish" }).click(); | ||
|
||
await page.goto(url); | ||
await expect(page.getByText(emailAddress)).toBeVisible(); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm it's a shame there's not a why to write the test where we just click on the link instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's annoying. I think the issue is there's latency between when we send the document to be published and when it actually gets published. Additionally, if we keep trying to click the link, the page gets cached from the first visit, so we need to add a cachebust param to the URL to force the reload 😞