Files
CWC/tests/services-hero-scope.spec.js
T

47 lines
1.7 KiB
JavaScript

import { expect, test } from "@playwright/test";
const servicesUrl =
process.env.TEST_SERVICES_URL ||
"http://community-works-collaborative.test/services/";
const childUrl =
process.env.TEST_SERVICES_CHILD_URL ||
"http://community-works-collaborative.test/services/engagement/";
const grandchildUrl =
process.env.TEST_SERVICES_GRANDCHILD_URL ||
"http://community-works-collaborative.test/services/engagement/sample-grandchild/";
const nonServicesUrl =
process.env.TEST_NON_SERVICES_URL ||
"http://community-works-collaborative.test/about/";
const blogUrl =
process.env.TEST_BLOG_URL ||
"http://community-works-collaborative.test/blog/";
test.describe("hero ancestor scope", () => {
test("Services page renders the hero", async ({ page }) => {
await page.goto(servicesUrl);
await expect(page.locator(".page-hero").first()).toBeVisible();
});
test("child of Services renders the hero", async ({ page }) => {
await page.goto(childUrl);
await expect(page.locator(".page-hero").first()).toBeVisible();
});
test("grandchild of Services renders the hero", async ({ page }) => {
await page.goto(grandchildUrl);
await expect(page.locator(".page-hero").first()).toBeVisible();
});
test("non-Services page does NOT render the hero", async ({ page }) => {
await page.goto(nonServicesUrl);
expect(await page.locator(".page-hero").count()).toBe(0);
});
test("blog index still renders the hero (bypasses ancestor gate)", async ({
page,
}) => {
await page.goto(blogUrl);
await expect(page.locator(".page-hero").first()).toBeVisible();
});
});