Add eventTypes parameter to Google Calendar inputAlphaGit/worklogger#1674
Add eventTypes parameter to Google Calendar input
AlphaGit/worklogger#1674
> > >
✓ Completed in 11 minutes, 3 months ago using GPT-4  •  Book a call  •  Report a bug
Progress
  ModifyChanged
app/inputs/GoogleCalendar/Input.ts:51-57Â
Changed app/inputs/GoogleCalendar/Input.ts
in e0fd479
   Â
55 | timeMax: endDateTime.toISOString(), | 55 | timeMax: endDateTime.toISOString(), |
56 | maxResults: 2500, | 56 | maxResults: 2500, |
57 | singleEvents: true, | 57 | singleEvents: true, |
58 | orderBy: 'startTime' | 58 | orderBy: 'startTime', |
59 | eventTypes: ["default"], // Add this line | ||
59 | }); | 60 | }); |
60 | this.logger.trace('Calendar response', { calendarResponse }); | 61 | this.logger.trace('Calendar response', { calendarResponse }); |
- In the
events.list
method call, add theeventTypes
parameter with the value["default"]
to the existing parameters. This ensures that the API call explicitly requests the default event types, safeguarding against future changes to the API's default behavior. - The modified code block should look like this:
const calendarResponse = await google.calendar("v3").events.list({
auth,
calendarId: calendar.id,
timeMin: startDateTime.toISOString(),
timeMax: endDateTime.toISOString(),
maxResults: 2500,
singleEvents: true,
eventTypes: ["default"], // Add this line
});
Modified file with Assistant API
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.tsÂ
Ran GitHub Actions for e0fd479b8d9e36d5539f7592a48e8c8544456b42:
  ModifyChanged
app/inputs/GoogleCalendar/Input.test.ts:48-56Â
Changed app/inputs/GoogleCalendar/Input.test.ts
in 18298ee
   Â
32 | 32 | ||
33 | describe('getWorklogs', () => { | 33 | describe('getWorklogs', () => { |
34 | beforeEach(() => { | 34 | beforeEach(() => { |
35 | mockedGetEventsList.mockResolvedValue({ data: { items: [] } }); | 35 | mockedGetEventsList.mockResolvedValue({ data: { items: [], eventTypes: ["default"] } }); |
36 | mockedGetUserAuthenticatedOAuthClient.mockResolvedValue({}); | 36 | mockedGetUserAuthenticatedOAuthClient.mockResolvedValue({}); |
37 | }); | 37 | }); |
- Update the mock response in the test titled 'filters results from events that started after our start time' to reflect the addition of the
eventTypes
parameter. This ensures that the tests accurately simulate the API's behavior with the new parameter in place. - Although the mock response does not directly simulate the
eventTypes
parameter (since it's a mock), it's important to ensure that the test logic aligns with the expectations of the modified API call. No specific line of code needs to be added for this parameter in the test, but the understanding that the API call now includes this parameter should be considered in the test's context and any future test modifications or additions.
Modified file with Assistant API
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.test.tsÂ
Ran GitHub Actions for 18298ee514c96a0e4036177a255d9ab5598ed7d9:
  Modify
app/inputs/GoogleCalendar/Input.test.ts:68-77Â
68 test('throws if the calendar API fails', async () => {
69 const errorMessage = 'Simulated calendar API error.';
70 mockedGetEventsList.mockImplementation(() => {
71 throw new Error(errorMessage);
72 });
73
74 const serviceRegistrations = ServiceRegistrations.mock();
75 const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration);
76
77 await expect(async () => await input.getWorkLogs(Dates.pastTwoHours(), Dates.now())).rejects.toThrow(errorMessage);
- Similarly, ensure that the test titled 'throws if the calendar API fails' and any other relevant tests in
Input.test.ts
are reviewed to confirm that they do not require direct modifications due to the addition of theeventTypes
parameter. This step is more about ensuring the integrity of the test suite in light of the code change rather than making a specific code modification. - No direct code change is required here, but a thorough review of the test cases should be conducted to ensure they remain valid and comprehensive with the introduction of the
eventTypes
parameter.
Modifying file with Assistant API
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.test.tsÂ
Plan
This is based on the results of the Planning step. The plan may expand from failed GitHub Actions runs.
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.tsÂ
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.test.tsÂ
  Run GitHub Actions for
app/inputs/GoogleCalendar/Input.test.tsÂ
Code Snippets Found
This is based on the results of the Searching step.
app/inputs/GoogleCalendar/Input.ts:49-57
 49
50 try {
51 const calendarResponse = await google.calendar("v3").events.list({
52 auth,
53 calendarId: calendar.id,
54 timeMin: startDateTime.toISOString(),
55 timeMax: endDateTime.toISOString(),
56 maxResults: 2500,
57 singleEvents: true,
app/inputs/GoogleCalendar/Input.test.ts:32-77
 32
33describe('getWorklogs', () => {
34 beforeEach(() => {
35 mockedGetEventsList.mockResolvedValue({ data: { items: [] } });
36 mockedGetUserAuthenticatedOAuthClient.mockResolvedValue({});
37 });
38
39 test('throws if credentials cannot be read', async () => {
40 const serviceRegistrations = ServiceRegistrations.mock();
41 mockedGetUserAuthenticatedOAuthClient.mockRejectedValue(new Error('Simulated credential error.'));
42
43 const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration);
44 await expect(async () => await input.getWorkLogs(Dates.pastTwoHours(), Dates.now())).rejects.toThrow('Simulated credential error.');
45 });
46
47 test('filters results from events that started after our start time', async () => {
48 mockedGetEventsList.mockResolvedValue({
49 data: {
50 items: [{
51 start: { dateTime: Dates.now() },
52 end: { dateTime: Dates.now() }
53 }, {
54 start: { dateTime: Dates.pastTwoHours() },
55 end: { dateTime: Dates.now() }
56 }]
57 }
58 });
59
60 const serviceRegistrations = ServiceRegistrations.mock();
61 const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration);
62
63 const worklogs = await input.getWorkLogs(Dates.pastOneHour(), Dates.now());
64
65 expect(worklogs.length).toBe(1);
66 });
67
68 test('throws if the calendar API fails', async () => {
69 const errorMessage = 'Simulated calendar API error.';
70 mockedGetEventsList.mockImplementation(() => {
71 throw new Error(errorMessage);
72 });
73
74 const serviceRegistrations = ServiceRegistrations.mock();
75 const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration);
76
77 await expect(async () => await input.getWorkLogs(Dates.pastTwoHours(), Dates.now())).rejects.toThrow(errorMessage);