Turn a saved draft into the finished Rule, and greet with congratulations.
This commit is contained in:
1 parent
a2815ae05f
commit
851133e56d
11 files changed
+150
-23
No files matched your search
@@ -2,7 +2,11 @@ import { renderHook, act } from "@testing-library/react";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import type { CreateFlowState } from "../../../app/(app)/create/types";
|
||||
import { useCreateFlowFinalize } from "../../../app/(app)/create/hooks/useCreateFlowFinalize";
|
||||
import { publishRule, updatePublishedRule } from "../../../lib/create/api";
|
||||
import {
|
||||
deleteServerDraft,
|
||||
publishRule,
|
||||
updatePublishedRule,
|
||||
} from "../../../lib/create/api";
|
||||
import { buildPublishPayload } from "../../../lib/create/buildPublishPayload";
|
||||
import { stateWithPendingCommunityAvatar } from "../../../lib/create/flushPendingCommunityAvatar";
|
||||
import messages from "../../../messages/en/index";
|
||||
@@ -25,6 +29,7 @@ vi.mock("../../../lib/create/buildPublishPayload", () => ({
|
||||
vi.mock("../../../lib/create/api", () => ({
|
||||
publishRule: vi.fn(),
|
||||
updatePublishedRule: vi.fn(),
|
||||
deleteServerDraft: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../../lib/create/flushPendingCommunityAvatar", () => ({
|
||||
@@ -50,6 +55,8 @@ describe("useCreateFlowFinalize", () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(publishRule).mockReset();
|
||||
vi.mocked(updatePublishedRule).mockReset();
|
||||
vi.mocked(deleteServerDraft).mockReset();
|
||||
vi.mocked(deleteServerDraft).mockResolvedValue(undefined);
|
||||
vi.mocked(writeLastPublishedRule).mockReset();
|
||||
vi.mocked(stateWithPendingCommunityAvatar).mockReset();
|
||||
vi.mocked(stateWithPendingCommunityAvatar).mockImplementation(
|
||||
@@ -101,6 +108,7 @@ describe("useCreateFlowFinalize", () => {
|
||||
expect(
|
||||
sessionStorage.getItem(CREATE_FLOW_PENDING_KEEP_RULE_LOGIN_KEY),
|
||||
).toBeNull();
|
||||
expect(deleteServerDraft).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not publish while the session is unresolved", async () => {
|
||||
@@ -408,6 +416,7 @@ describe("useCreateFlowFinalize", () => {
|
||||
summary: "Published summary",
|
||||
document: {},
|
||||
});
|
||||
expect(deleteServerDraft).toHaveBeenCalledTimes(1);
|
||||
expect(updateState).toHaveBeenCalledWith({
|
||||
editingPublishedRuleId: undefined,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user