Keep a guest community logo on review and on the published rule.
Sign-in was clearing the staged file before it uploaded, and review only read the server URL, so a chosen logo disappeared after the upload step.
This commit is contained in:
1 parent
2348a9e94f
commit
8212423ec3
19 files changed
+780
-61
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const clearPendingCommunityAvatarFile = vi.fn();
|
||||
const forgetFlushedCommunityAvatarUrl = vi.fn();
|
||||
|
||||
vi.mock("../../lib/create/pendingCommunityAvatarUpload", () => ({
|
||||
clearPendingCommunityAvatarFile: () => clearPendingCommunityAvatarFile(),
|
||||
}));
|
||||
|
||||
vi.mock("../../lib/create/flushPendingCommunityAvatar", () => ({
|
||||
forgetFlushedCommunityAvatarUrl: () => forgetFlushedCommunityAvatarUrl(),
|
||||
}));
|
||||
|
||||
import {
|
||||
CREATE_FLOW_ANONYMOUS_KEY,
|
||||
CREATE_FLOW_TRANSFER_PENDING_KEY,
|
||||
clearAnonymousCreateFlowStorage,
|
||||
} from "../../app/(app)/create/utils/anonymousDraftStorage";
|
||||
|
||||
describe("clearAnonymousCreateFlowStorage", () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
clearPendingCommunityAvatarFile.mockReset();
|
||||
forgetFlushedCommunityAvatarUrl.mockReset();
|
||||
localStorage.setItem(CREATE_FLOW_ANONYMOUS_KEY, "{\"title\":\"Garden\"}");
|
||||
localStorage.setItem(CREATE_FLOW_TRANSFER_PENDING_KEY, "1");
|
||||
});
|
||||
|
||||
it("removes the draft and the staged logo", () => {
|
||||
clearAnonymousCreateFlowStorage();
|
||||
expect(localStorage.getItem(CREATE_FLOW_ANONYMOUS_KEY)).toBeNull();
|
||||
expect(localStorage.getItem(CREATE_FLOW_TRANSFER_PENDING_KEY)).toBeNull();
|
||||
expect(clearPendingCommunityAvatarFile).toHaveBeenCalledTimes(1);
|
||||
expect(forgetFlushedCommunityAvatarUrl).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("keeps the staged logo when a transfer upload still needs to retry", () => {
|
||||
clearAnonymousCreateFlowStorage({ preservePendingAvatar: true });
|
||||
expect(localStorage.getItem(CREATE_FLOW_ANONYMOUS_KEY)).toBeNull();
|
||||
expect(clearPendingCommunityAvatarFile).not.toHaveBeenCalled();
|
||||
expect(forgetFlushedCommunityAvatarUrl).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user