Let anyone finish a Rule without an account or email.

Continue on final review and Finish without inviting no longer open a login wall. The header stays Exit until Save your progress is done, and Send invitations is the only invite-path login.
This commit is contained in:
adilallo committed 2026-11-23 14:48:01 -07:00
1 parent 077942166c
commit 0535f6f167
14 files changed
+377 -225

No files matched your search

+47 -5
View File
@@ -12,7 +12,10 @@ import {
readPendingCommunityAvatarFile,
storePendingCommunityAvatarFile,
} from "../../lib/create/pendingCommunityAvatarUpload";
import { fetchAuthSession } from "../../lib/create/api";
import {
CreateFlowUploadValidationError,
uploadCreateFlowFile,
} from "../../lib/create/uploadToServer";
import messages from "../../messages/en/index";
vi.mock("../../lib/create/pendingCommunityAvatarUpload", () => ({
@@ -21,9 +24,14 @@ vi.mock("../../lib/create/pendingCommunityAvatarUpload", () => ({
clearPendingCommunityAvatarFile: vi.fn().mockResolvedValue(undefined),
}));
vi.mock("../../lib/create/api", () => ({
fetchAuthSession: vi.fn().mockResolvedValue({ user: null }),
}));
vi.mock("../../lib/create/uploadToServer", async (importOriginal) => {
const actual =
await importOriginal<typeof import("../../lib/create/uploadToServer")>();
return {
...actual,
uploadCreateFlowFile: vi.fn(),
};
});
const pngBytes = Uint8Array.from(
Buffer.from(
@@ -46,7 +54,7 @@ describe("CommunityUploadScreen", () => {
vi.mocked(readPendingCommunityAvatarFile).mockResolvedValue(null);
vi.mocked(storePendingCommunityAvatarFile).mockResolvedValue(undefined);
vi.mocked(clearPendingCommunityAvatarFile).mockResolvedValue(undefined);
vi.mocked(fetchAuthSession).mockResolvedValue({ user: null });
vi.mocked(uploadCreateFlowFile).mockReset();
Object.defineProperty(URL, "createObjectURL", {
value: vi.fn(() => "blob:pending-avatar"),
writable: true,
@@ -98,7 +106,35 @@ describe("CommunityUploadScreen", () => {
expect(screen.getByText("avatar.png")).toBeInTheDocument();
});
it("uploads a guest logo without signing in", async () => {
vi.mocked(uploadCreateFlowFile).mockResolvedValue({
url: "/api/uploads/guest-logo",
id: "11111111-1111-4111-8111-111111111111",
mimeType: "image/png",
byteLength: pngBytes.byteLength,
});
render(<CommunityUploadScreen />);
await screen.findByRole("heading", { name: copy.title });
fireEvent.change(fileInput(), {
target: {
files: [new File([pngBytes], "logo.png", { type: "image/png" })],
},
});
expect(await screen.findByText("logo.png")).toBeInTheDocument();
expect(uploadCreateFlowFile).toHaveBeenCalledWith(
expect.any(File),
"communityAvatar",
);
expect(storePendingCommunityAvatarFile).not.toHaveBeenCalled();
});
it("rejects an empty file with a clear error and does not stage it", async () => {
vi.mocked(uploadCreateFlowFile).mockRejectedValue(
new CreateFlowUploadValidationError("empty"),
);
render(<CommunityUploadScreen />);
await screen.findByRole("heading", { name: copy.title });
@@ -113,6 +149,9 @@ describe("CommunityUploadScreen", () => {
});
it("rejects a text file renamed as PNG", async () => {
vi.mocked(uploadCreateFlowFile).mockRejectedValue(
new CreateFlowUploadValidationError("invalidType"),
);
render(<CommunityUploadScreen />);
await screen.findByRole("heading", { name: copy.title });
@@ -129,6 +168,9 @@ describe("CommunityUploadScreen", () => {
});
it("rejects SVG uploads", async () => {
vi.mocked(uploadCreateFlowFile).mockRejectedValue(
new CreateFlowUploadValidationError("svg"),
);
render(<CommunityUploadScreen />);
await screen.findByRole("heading", { name: copy.title });