Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ describe("useDraftConfirmation", () => {
expect(discard).not.toHaveBeenCalled();
});

it("submits an existing standalone draft made recurring without opening the update scope dialog", async () => {
const draft = createDraft({
recurrence: {
rule: ["FREQ=WEEKLY;COUNT=4"],
},
});
const { discard, result, submit } = renderDraftConfirmation({ draft });

await act(async () => {
await result.current.onSubmit(draft);
});

expect(result.current.isRecurrenceUpdateScopeDialogOpen).toBe(false);
expect(result.current.finalDraft).toBeNull();
expect(submit).toHaveBeenCalledTimes(1);
expect(submit).toHaveBeenCalledWith(
draft,
RecurringEventUpdateScope.THIS_EVENT,
);
expect(discard).toHaveBeenCalledTimes(1);
});

it("submits a single-occurrence recurring instance without opening the update scope dialog", async () => {
const baseEventId = new ObjectId().toString();
const baseEvent = createDraft({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ export const useDraftConfirmation = ({
const draftIsInstance = ObjectId.isValid(
_draft.recurrence?.eventId ?? "",
);
const draftIsRecurring = Array.isArray(rule) || draftIsInstance;
const isExistingDraft = Boolean(_draft._id) || draftIsInstance;
const isRecurringEvent =
isExistingDraft && (isRecurrence() || draftIsRecurring);
isExistingDraft && (isRecurrence() || draftIsInstance);
const instanceEvent = isInstance() || draftIsInstance;
const toStandAlone = instanceEvent && rule === null;
const hasMultipleOccurrences = hasMultipleRecurrenceOccurrences(
Expand Down