From 7a23fcd9ff89f528a9cc885c4a88cd1556caa213 Mon Sep 17 00:00:00 2001 From: Guillaume Deconinck Date: Tue, 24 Jun 2025 13:27:39 +0900 Subject: [PATCH] test: add tests on expired recurring events --- clients/javascript/tests/account.spec.ts | 65 +++++++++++++++++++++--- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/clients/javascript/tests/account.spec.ts b/clients/javascript/tests/account.spec.ts index f816dcfd..df34689b 100644 --- a/clients/javascript/tests/account.spec.ts +++ b/clients/javascript/tests/account.spec.ts @@ -93,6 +93,7 @@ describe('Account API', () => { let eventId2: string let recurringEventId: string let recurringExceptionEventId: string + let expiredRecurringEventId: string const externalId = 'externalId' const externalId2 = 'externalId2' @@ -174,6 +175,20 @@ describe('Account API', () => { }) recurringExceptionEventId = exceptionEventRes.event.id + + const expiredRecurringEventRes = await adminClient.events.create(userId, { + calendarId, + status: 'confirmed', + duration: 500, + startTime: new Date(1400), + recurrence: { + freq: 'weekly', + interval: 1, + until: new Date(3000).toISOString(), + }, + }) + + expiredRecurringEventId = expiredRecurringEventRes.event.id }) it('should be able to search for events in the account (by startTime, for multiple users)', async () => { @@ -187,7 +202,7 @@ describe('Account API', () => { }, }, }) - expect(res.events.length).toBe(3) + expect(res.events.length).toBe(4) expect(res.events).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -199,6 +214,9 @@ describe('Account API', () => { expect.objectContaining({ id: eventId2, }), + expect.objectContaining({ + id: expiredRecurringEventId, + }), ]) ) }) @@ -215,7 +233,7 @@ describe('Account API', () => { }, sort: 'startTimeAsc', }) - expect(res.events.length).toBe(3) + expect(res.events.length).toBe(4) // Expect this order explicitly as we sort by startTimeAsc expect(res.events).toEqual([ expect.objectContaining({ @@ -227,6 +245,9 @@ describe('Account API', () => { expect.objectContaining({ id: eventId2, }), + expect.objectContaining({ + id: expiredRecurringEventId, + }), ]) }) @@ -247,7 +268,7 @@ describe('Account API', () => { // Expect only the last one, as we explicitly sorted by startTimeDesc and limited to 1 expect(res.events).toEqual([ expect.objectContaining({ - id: eventId2, + id: expiredRecurringEventId, }), ]) }) @@ -263,7 +284,7 @@ describe('Account API', () => { }, }, }) - expect(res.events.length).toBe(3) + expect(res.events.length).toBe(4) expect(res.events).toEqual( expect.arrayContaining([ expect.objectContaining({ @@ -275,6 +296,9 @@ describe('Account API', () => { expect.objectContaining({ id: recurringExceptionEventId, }), + expect.objectContaining({ + id: expiredRecurringEventId, + }), ]) ) }) @@ -290,11 +314,14 @@ describe('Account API', () => { }, }, }) - expect(res.events.length).toBe(1) + expect(res.events.length).toBe(2) expect(res.events).toEqual([ expect.objectContaining({ id: recurringEventId, }), + expect.objectContaining({ + id: expiredRecurringEventId, + }), ]) }) @@ -335,15 +362,39 @@ describe('Account API', () => { eq: userId, }, recurrence: { - existsAndRecurringAt: new Date(10000), + existsAndRecurringAt: new Date(1500), }, }, }) - expect(res.events.length).toBe(1) + + expect(res.events.length).toBe(2) expect(res.events).toEqual([ expect.objectContaining({ id: recurringEventId, }), + expect.objectContaining({ + id: expiredRecurringEventId, + }), + ]) + + // Search outside of the recurrence range + const res2 = await adminClient.account.searchEventsInAccount({ + filter: { + userId: { + eq: userId, + }, + recurrence: { + existsAndRecurringAt: new Date(10000), + }, + }, + }) + + // Only contains the recurring event, and not the expired one + expect(res2.events.length).toBe(1) + expect(res2.events).toEqual([ + expect.objectContaining({ + id: recurringEventId, + }), ]) })