Fix case-study share chrome, hero lockup width, and copy confirmation in the share dialog.
Marketing pages omitted create-flow nav copy, so Share rendered as a translation key; the case-study banner squeezed hero text to the thumbnail width; Copy link had no hover or copied state. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -157,11 +157,14 @@ describe("ContentBanner", () => {
|
||||
|
||||
const title = screen.getByRole("heading", { name: "Test Article" });
|
||||
expect(title).toBeInTheDocument();
|
||||
expect(title).toHaveClass("sm:text-x-small-display", "md:text-[32px]");
|
||||
expect(title).toHaveClass("text-[32px]", "lg:text-medium-display");
|
||||
expect(title).not.toHaveClass("xl:text-x-large-display");
|
||||
expect(screen.getByText("Sample Operating Manual")).toBeInTheDocument();
|
||||
const copyColumn = container.querySelector('[data-node-id="19189:9171"]');
|
||||
expect(copyColumn).toHaveClass("lg:max-w-[365px]");
|
||||
expect(copyColumn).not.toHaveClass("max-w-[365px]");
|
||||
const copyLockup = title.closest("div.relative.z-20");
|
||||
expect(copyLockup).toHaveStyle({ width: "100%" });
|
||||
const bannerRow = container.querySelector(
|
||||
'[data-figma-node="22015:42621"]',
|
||||
);
|
||||
|
||||
@@ -70,6 +70,43 @@ describe("Share modal", () => {
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("confirms Copy link with Copied! when the handler succeeds", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onCopyLink = vi.fn().mockResolvedValue(true);
|
||||
render(
|
||||
<Share
|
||||
isOpen={true}
|
||||
onClose={vi.fn()}
|
||||
{...noopHandlers}
|
||||
onCopyLink={onCopyLink}
|
||||
/>,
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: "Copy link" }));
|
||||
expect(onCopyLink).toHaveBeenCalledTimes(1);
|
||||
expect(screen.getByRole("button", { name: "Copied!" })).toHaveAttribute(
|
||||
"aria-pressed",
|
||||
"true",
|
||||
);
|
||||
expect(screen.getByText("Link copied to clipboard")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps Copy link when the handler reports failure", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(
|
||||
<Share
|
||||
isOpen={true}
|
||||
onClose={vi.fn()}
|
||||
{...noopHandlers}
|
||||
onCopyLink={vi.fn().mockResolvedValue(false)}
|
||||
/>,
|
||||
);
|
||||
await user.click(screen.getByRole("button", { name: "Copy link" }));
|
||||
expect(screen.getByRole("button", { name: "Copy link" })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("button", { name: "Copied!" }),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("calls onClose when header overflow (more) is activated, matching modal chrome parity", async () => {
|
||||
const user = userEvent.setup();
|
||||
const onClose = vi.fn();
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { describe, test, expect, vi } from "vitest";
|
||||
import { screen } from "@testing-library/react";
|
||||
import { screen, render as rtlRender } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { renderWithProviders as render } from "../utils/test-utils";
|
||||
import { MessagesProvider } from "../../app/contexts/MessagesContext";
|
||||
import UseCaseCompletedRulePage from "../../app/(marketing-case-study)/use-cases/[slug]/rule/page";
|
||||
import messages from "../../messages/en/index";
|
||||
import marketingMessages from "../../messages/en/marketing";
|
||||
import { getTranslation } from "../../lib/i18n/getTranslation";
|
||||
import { USE_CASE_DETAIL_SLUGS } from "../../lib/useCaseSyntheticPost";
|
||||
|
||||
const mockPush = vi.fn();
|
||||
@@ -83,9 +86,31 @@ describe("UseCaseCompletedRulePage", () => {
|
||||
name: messages.pages.useCasesCompletedRule.topNav.duplicateAriaLabel,
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Share" })).toBeInTheDocument();
|
||||
},
|
||||
);
|
||||
|
||||
test("marketing message bundle resolves Share (not the dotted create.topNav key)", () => {
|
||||
expect(getTranslation(marketingMessages, "create.topNav.share")).toBe(
|
||||
"Share",
|
||||
);
|
||||
});
|
||||
|
||||
test("Share button reads Share under the marketing case-study bundle", async () => {
|
||||
rtlRender(
|
||||
<MessagesProvider messages={marketingMessages}>
|
||||
{await UseCaseCompletedRulePage({
|
||||
params: Promise.resolve({ slug: "mutual-aid-colorado" }),
|
||||
})}
|
||||
</MessagesProvider>,
|
||||
);
|
||||
|
||||
expect(screen.getByRole("button", { name: "Share" })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("button", { name: "create.topNav.share" }),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test("Duplicate opens login when signed out", async () => {
|
||||
const user = userEvent.setup();
|
||||
mockOpenLogin.mockClear();
|
||||
|
||||
@@ -111,6 +111,17 @@ describe("ContentContainer", () => {
|
||||
expect(container).toHaveStyle("width: 200px");
|
||||
});
|
||||
|
||||
it("applies full width and case-study type scale for useCase size", () => {
|
||||
render(<ContentContainer post={mockPost} size="useCase" />);
|
||||
|
||||
const container = document.querySelector("div[class*='relative z-20']");
|
||||
expect(container).toHaveStyle("width: 100%");
|
||||
|
||||
const title = screen.getByText("Test Article Title");
|
||||
expect(title).toHaveClass("text-[32px]", "lg:text-medium-display");
|
||||
expect(title).not.toHaveClass("xl:text-x-large-display");
|
||||
});
|
||||
|
||||
it("has proper spacing between icon and text", () => {
|
||||
render(<ContentContainer post={mockPost} />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user