Skip to content

Commit fbb965a

Browse files
authored
✨ feat(someday-events): show someday base recurring events in sidebar (#923)
1 parent 91f93a8 commit fbb965a

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

packages/backend/src/event/services/event.find.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { mockEventSetSomeday1 } from "@core/__mocks__/v1/events/events.someday.1
44
import { MapEvent, gEventToCompassEvent } from "@core/mappers/map.event";
55
import { Schema_Event } from "@core/types/event.types";
66
import { isBase, isExistingInstance } from "@core/util/event/event.util";
7+
import { createMockBaseEvent } from "@core/util/test/ccal.event.factory";
78
import {
89
cleanupTestDb,
910
setupTestDb,
@@ -88,6 +89,31 @@ describe("Jan 2022: Many Formats", () => {
8889
const instances = result.filter(isExistingInstance);
8990
expect(instances).toHaveLength(gInstances.length);
9091
});
92+
93+
it("excludes base calendar recurring events when someday=false", async () => {
94+
// Create a base calendar recurring event (isSomeday: false)
95+
const baseCalendarRecurringEvent = createMockBaseEvent({
96+
user: userId,
97+
isSomeday: false,
98+
});
99+
100+
// Insert the test event
101+
await mongoService.event.insertOne(baseCalendarRecurringEvent);
102+
103+
// Query for calendar events (not someday)
104+
const filter = getReadAllFilter(userId, {
105+
start: "2023-10-01",
106+
end: "2023-10-31",
107+
});
108+
const result = await mongoService.event.find(filter).toArray();
109+
110+
// Should NOT include the base calendar recurring event
111+
const baseCalendarRecurringEvents = result.filter(
112+
(e) => isBase(e) && e.isSomeday === false,
113+
);
114+
115+
expect(baseCalendarRecurringEvents).toHaveLength(0);
116+
});
91117
});
92118

93119
describe("finds events with exact same timestamps", () => {
@@ -298,6 +324,28 @@ describe("Jan 2022: Many Formats", () => {
298324
expect(result[0]?.title).toBe("Multi-Month 2");
299325
});
300326
});
327+
328+
it("includes base someday recurring events when someday query provided", async () => {
329+
// Create a base someday recurring event
330+
const baseSomedayRecurringEvent = createMockBaseEvent({
331+
user: userId,
332+
isSomeday: true,
333+
});
334+
335+
// Insert the test event
336+
await mongoService.event.insertOne(baseSomedayRecurringEvent);
337+
338+
// Query for someday events
339+
const filter = getReadAllFilter(userId, { someday: "true" });
340+
const result = await mongoService.event.find(filter).toArray();
341+
342+
// Should include the base someday recurring event
343+
const baseSomedayRecurringEvents = result.filter(
344+
(e) => isBase(e) && e.isSomeday === true,
345+
);
346+
347+
expect(baseSomedayRecurringEvents.length).toBeGreaterThan(0);
348+
});
301349
});
302350
});
303351

packages/backend/src/event/services/event.service.util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ export const getReadAllFilter = (
7272
Object.assign(filter, dateFilters);
7373
}
7474

75-
// Exclude base recurring events (those with recurrence.rule)
76-
filter["recurrence.rule"] = { $exists: false };
75+
// For someday events: include base recurring events (those with recurrence.rule)
76+
// For calendar events: exclude base recurring events (those with recurrence.rule)
77+
if (!isSomeday) filter["recurrence.rule"] = { $exists: false };
7778

7879
return filter;
7980
};

0 commit comments

Comments
 (0)