Skip to content

Commit 4b9ac43

Browse files
authored
fix(web): avoid scope prompt for standalone recurrence (#1847)
1 parent 536cf0f commit 4b9ac43

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

packages/web/src/views/Week/components/Draft/hooks/state/useDraftConfirmation.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,28 @@ describe("useDraftConfirmation", () => {
151151
expect(discard).not.toHaveBeenCalled();
152152
});
153153

154+
it("submits an existing standalone draft made recurring without opening the update scope dialog", async () => {
155+
const draft = createDraft({
156+
recurrence: {
157+
rule: ["FREQ=WEEKLY;COUNT=4"],
158+
},
159+
});
160+
const { discard, result, submit } = renderDraftConfirmation({ draft });
161+
162+
await act(async () => {
163+
await result.current.onSubmit(draft);
164+
});
165+
166+
expect(result.current.isRecurrenceUpdateScopeDialogOpen).toBe(false);
167+
expect(result.current.finalDraft).toBeNull();
168+
expect(submit).toHaveBeenCalledTimes(1);
169+
expect(submit).toHaveBeenCalledWith(
170+
draft,
171+
RecurringEventUpdateScope.THIS_EVENT,
172+
);
173+
expect(discard).toHaveBeenCalledTimes(1);
174+
});
175+
154176
it("submits a single-occurrence recurring instance without opening the update scope dialog", async () => {
155177
const baseEventId = new ObjectId().toString();
156178
const baseEvent = createDraft({

packages/web/src/views/Week/components/Draft/hooks/state/useDraftConfirmation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ export const useDraftConfirmation = ({
8585
const draftIsInstance = ObjectId.isValid(
8686
_draft.recurrence?.eventId ?? "",
8787
);
88-
const draftIsRecurring = Array.isArray(rule) || draftIsInstance;
8988
const isExistingDraft = Boolean(_draft._id) || draftIsInstance;
9089
const isRecurringEvent =
91-
isExistingDraft && (isRecurrence() || draftIsRecurring);
90+
isExistingDraft && (isRecurrence() || draftIsInstance);
9291
const instanceEvent = isInstance() || draftIsInstance;
9392
const toStandAlone = instanceEvent && rule === null;
9493
const hasMultipleOccurrences = hasMultipleRecurrenceOccurrences(

0 commit comments

Comments
 (0)