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:
1 parent
3a264ac2df
commit
0fe2624002
11 files changed
+132
-14
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const getReadablePublishedRuleMock = vi.fn();
|
||||
const getSessionUserMock = vi.fn();
|
||||
const notFoundMock = vi.fn(() => {
|
||||
throw new Error("NEXT_NOT_FOUND");
|
||||
});
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
notFound: () => notFoundMock(),
|
||||
}));
|
||||
|
||||
vi.mock("../../lib/server/publishedRules", () => ({
|
||||
getReadablePublishedRule: (...args: unknown[]) =>
|
||||
getReadablePublishedRuleMock(...args),
|
||||
}));
|
||||
|
||||
vi.mock("../../lib/server/session", () => ({
|
||||
getSessionUser: () => getSessionUserMock(),
|
||||
}));
|
||||
|
||||
import { generateMetadata } from "../../app/(marketing)/r/[shareSlug]/page";
|
||||
|
||||
describe("shared Rule page", () => {
|
||||
beforeEach(() => {
|
||||
getReadablePublishedRuleMock.mockReset();
|
||||
getSessionUserMock.mockReset();
|
||||
notFoundMock.mockClear();
|
||||
getSessionUserMock.mockResolvedValue(null);
|
||||
});
|
||||
|
||||
it("returns 404 when the share link is off or unknown", async () => {
|
||||
getReadablePublishedRuleMock.mockResolvedValue(null);
|
||||
await expect(
|
||||
generateMetadata({
|
||||
params: Promise.resolve({ shareSlug: "k7f2-9qxm" }),
|
||||
}),
|
||||
).rejects.toThrow("NEXT_NOT_FOUND");
|
||||
expect(notFoundMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user