fix(objects): render MySQL event create editor with fresh state
This commit is contained in:
1 parent
349342efb7
commit
de2c4b38cd
4 files changed
+41
-6
No files matched your search
+12
-1
@@ -1,8 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveInitialEventEditorRequest } from "./eventEditorRequest";
|
||||
import { eventEditorInstanceKey, resolveInitialEventEditorRequest } from "./eventEditorRequest";
|
||||
|
||||
const base = { openedRequestKey: "" };
|
||||
|
||||
describe("eventEditorInstanceKey", () => {
|
||||
it("separates repeated CREATE requests", () => {
|
||||
expect(eventEditorInstanceKey({ createRequestId: 1 })).not.toBe(eventEditorInstanceKey({ createRequestId: 2 }));
|
||||
});
|
||||
|
||||
it("separates ALTER rows from CREATE mode", () => {
|
||||
expect(eventEditorInstanceKey({ openRequestId: 1, rowId: "event:old_event" })).not.toBe(eventEditorInstanceKey({ createRequestId: 3 }));
|
||||
expect(eventEditorInstanceKey({ openRequestId: 1, rowId: "event:old_event" })).not.toBe(eventEditorInstanceKey({ openRequestId: 1, rowId: "event:other_event" }));
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveInitialEventEditorRequest", () => {
|
||||
describe("create request (New Event)", () => {
|
||||
it("opens CREATE mode without requiring an existing EVENT row", () => {
|
||||
|
||||
@@ -30,6 +30,17 @@ export interface InitialEventEditorRequestInput {
|
||||
loadingObjects?: boolean;
|
||||
}
|
||||
|
||||
export interface EventEditorInstanceKeyInput {
|
||||
createRequestId?: number;
|
||||
openRequestId?: number;
|
||||
rowId?: string;
|
||||
}
|
||||
|
||||
export function eventEditorInstanceKey({ createRequestId, openRequestId, rowId }: EventEditorInstanceKeyInput): string {
|
||||
const requestKey = createRequestId !== undefined ? `create:${createRequestId}` : `open:${openRequestId ?? 0}`;
|
||||
return `${requestKey}:${rowId ?? "new"}`;
|
||||
}
|
||||
|
||||
export function resolveInitialEventEditorRequest(input: InitialEventEditorRequestInput): InitialEventEditorDecision {
|
||||
const { eventCreateRequestId, eventName, eventOpenRequestId, openedRequestKey, hasEventRow = false, loadingObjects = false } = input;
|
||||
|
||||
|
||||
Reference in new issue
Block a user