Show Share initials, a readable link, and a copy confirmation.

Filled avatars used white ink on yellow, the link field was a dimmed disabled input, and Copy failed silently when the clipboard API was denied.
This commit is contained in:
adilallo committed 2026-11-21 11:42:49 -07:00
1 parent 3a264ac2df
commit 0fe2624002
11 files changed
+132 -14

No files matched your search

+24 -3
View File
@@ -86,11 +86,30 @@ describe("Share modal", () => {
).toBeInTheDocument();
expect(screen.getByText("Juniper Street Food Share")).toBeInTheDocument();
expect(screen.getByText("You")).toBeInTheDocument();
expect(screen.getByText("N")).toBeInTheDocument();
expect(screen.getByText("R")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Invite" })).toBeEnabled();
expect(screen.getByText("rosa@example.org")).toBeInTheDocument();
expect(screen.getByText("Five more people can read it")).toBeInTheDocument();
expect(screen.getByText("Only people you invite can open it.")).toBeInTheDocument();
});
it("confirms a copy when the clipboard API is denied", async () => {
writeText.mockRejectedValueOnce(new Error("denied"));
const exec = vi.fn().mockReturnValue(true);
Object.defineProperty(document, "execCommand", {
configurable: true,
value: exec,
});
openShare();
fireEvent.click(screen.getByRole("button", { name: /Copy link/i }));
await waitFor(() => {
expect(screen.getByText("Link copied")).toBeInTheDocument();
});
expect(screen.getByRole("button", { name: /Copied/i })).toBeInTheDocument();
expect(exec).toHaveBeenCalledWith("copy");
});
it("copies the private Rule URL", async () => {
openShare();
fireEvent.click(screen.getByRole("button", { name: /Copy link/i }));
@@ -141,9 +160,11 @@ describe("Share modal", () => {
}),
);
await user.click(screen.getByRole("button", { name: "Turn on link" }));
expect(
screen.getByDisplayValue("communityrule.info/r/k7f2-9qxm"),
).toBeInTheDocument();
const linkField = screen.getByDisplayValue(
"communityrule.info/r/k7f2-9qxm",
);
expect(linkField).toHaveAttribute("readonly");
expect(linkField).not.toBeDisabled();
expect(
screen.getByRole("button", { name: "Turn off link" }),
).toBeInTheDocument();