fix: scope mobile media text behavior

This commit is contained in:
Keith Solomon
2026-06-27 20:35:10 -05:00
parent 6263a98988
commit d19924e22b
3 changed files with 68 additions and 26 deletions
+46 -11
View File
@@ -245,10 +245,15 @@ test("mobile media text matches the 402px reference composition", async ({
}) => {
await page.goto(homepage);
const block = await getBox(page.locator(".media-cols"));
const content = await getBox(page.locator(".media-cols .content-wrapper"));
const media = await getBox(page.locator(".media-cols > div:first-child"));
const buttons = page.locator(".media-cols .reset .button");
const blockLocator = page.locator(
".wp-block-acf-media-text.media-cols.has-two-ctas",
);
const block = await getBox(blockLocator);
const content = await getBox(
blockLocator.locator(":scope > .content-wrapper"),
);
const media = await getBox(blockLocator.locator(":scope > .media-wrapper"));
const buttons = blockLocator.locator(".reset .button");
const services = await getBox(buttons.nth(0));
const about = await getBox(buttons.nth(1));
const contact = await getBox(page.locator(".contact-block.home-contact"));
@@ -265,6 +270,26 @@ test("mobile media text matches the 402px reference composition", async ({
expectNear(contact.y - (media.y + media.height), 232, 5);
});
test("media text keeps content first in the DOM and marks its CTA pair", async ({
page,
}) => {
await page.goto(homepage);
const block = page.locator(".wp-block-acf-media-text.media-cols");
const childOrder = await block
.locator(":scope > div")
.evaluateAll((children) =>
children.map((child) =>
child.classList.contains("content-wrapper")
? "content"
: "media",
),
);
expect(childOrder).toEqual(["content", "media"]);
await expect(block).toHaveClass(/\bhas-two-ctas\b/);
});
test("mobile media text remains contained at responsive endpoints", async ({
page,
}) => {
@@ -272,13 +297,14 @@ test("mobile media text remains contained at responsive endpoints", async ({
await page.setViewportSize({ width, height: 900 });
await page.goto(homepage);
const block = page.locator(
".wp-block-acf-media-text.media-cols.has-two-ctas",
);
const content = await getBox(
page.locator(".media-cols .content-wrapper"),
block.locator(":scope > .content-wrapper"),
);
const media = await getBox(
page.locator(".media-cols > div:first-child"),
);
const buttons = page.locator(".media-cols .reset .button");
const media = await getBox(block.locator(":scope > .media-wrapper"));
const buttons = block.locator(".reset .button");
const services = await getBox(buttons.nth(0));
const about = await getBox(buttons.nth(1));
@@ -297,12 +323,21 @@ test("media text keeps its configured ordering at 768px", async ({ page }) => {
await page.setViewportSize({ width: 768, height: 900 });
await page.goto(homepage);
const content = await getBox(page.locator(".media-cols .content-wrapper"));
const media = await getBox(page.locator(".media-cols > div:first-child"));
const block = page.locator(".wp-block-acf-media-text.media-cols");
const contentLocator = block.locator(":scope > .content-wrapper");
const mediaLocator = block.locator(":scope > .media-wrapper");
const content = await getBox(contentLocator);
const media = await getBox(mediaLocator);
expect(media.y).toBeLessThan(content.y);
expectNear(media.x, 70, 3);
expectNear(media.width, 627, 3);
await expect(block).toHaveCSS("padding-top", "0px");
await expect(contentLocator.locator(".font-light")).toHaveCSS(
"font-size",
"18px",
);
await expect(contentLocator.locator(".reset")).toHaveCSS("display", "flex");
});
test("mobile recent posts exposes previous and next controls", async ({