New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sweep: add eventTypes parameter to Google Calendar input #1674
Comments
🚀 Here's the PR! #1676See Sweep's progress at the progress dashboard! ⚡ Sweep Basic Tier: I'm using GPT-4. You have 4 GPT-4 tickets left for the month and 2 for the day. (tracking ID:
6624754e2f )For more GPT-4 tickets, visit our payment portal. For a one week free trial, try Sweep Pro (unlimited GPT-4 tickets). Tip I can email you next time I complete a pull request if you set up your email here! Actions (click)
GitHub Actions✓Here are the GitHub Actions logs prior to making any changes: Sandbox logs for
|
try { | |
const calendarResponse = await google.calendar("v3").events.list({ | |
auth, | |
calendarId: calendar.id, | |
timeMin: startDateTime.toISOString(), | |
timeMax: endDateTime.toISOString(), | |
maxResults: 2500, | |
singleEvents: true, |
worklogger/app/inputs/GoogleCalendar/Input.test.ts
Lines 32 to 77 in 1adc591
describe('getWorklogs', () => { | |
beforeEach(() => { | |
mockedGetEventsList.mockResolvedValue({ data: { items: [] } }); | |
mockedGetUserAuthenticatedOAuthClient.mockResolvedValue({}); | |
}); | |
test('throws if credentials cannot be read', async () => { | |
const serviceRegistrations = ServiceRegistrations.mock(); | |
mockedGetUserAuthenticatedOAuthClient.mockRejectedValue(new Error('Simulated credential error.')); | |
const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration); | |
await expect(async () => await input.getWorkLogs(Dates.pastTwoHours(), Dates.now())).rejects.toThrow('Simulated credential error.'); | |
}); | |
test('filters results from events that started after our start time', async () => { | |
mockedGetEventsList.mockResolvedValue({ | |
data: { | |
items: [{ | |
start: { dateTime: Dates.now() }, | |
end: { dateTime: Dates.now() } | |
}, { | |
start: { dateTime: Dates.pastTwoHours() }, | |
end: { dateTime: Dates.now() } | |
}] | |
} | |
}); | |
const serviceRegistrations = ServiceRegistrations.mock(); | |
const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration); | |
const worklogs = await input.getWorkLogs(Dates.pastOneHour(), Dates.now()); | |
expect(worklogs.length).toBe(1); | |
}); | |
test('throws if the calendar API fails', async () => { | |
const errorMessage = 'Simulated calendar API error.'; | |
mockedGetEventsList.mockImplementation(() => { | |
throw new Error(errorMessage); | |
}); | |
const serviceRegistrations = ServiceRegistrations.mock(); | |
const input = new Input(serviceRegistrations, AppConfigurations.normal(), defaultConfiguration); | |
await expect(async () => await input.getWorkLogs(Dates.pastTwoHours(), Dates.now())).rejects.toThrow(errorMessage); |
Step 2: ⌨️ Coding
Modify app/inputs/GoogleCalendar/Input.ts with contents:
• In the `events.list` method call, add the `eventTypes` 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: ```typescript 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 }); ```--- +++ @@ -55,7 +55,8 @@ timeMax: endDateTime.toISOString(), maxResults: 2500, singleEvents: true, - orderBy: 'startTime' + orderBy: 'startTime', + eventTypes: ["default"], // Add this line }); this.logger.trace('Calendar response', { calendarResponse });
- Running GitHub Actions for
app/inputs/GoogleCalendar/Input.ts
✓ Edit
Check app/inputs/GoogleCalendar/Input.ts with contents:Ran GitHub Actions for e0fd479b8d9e36d5539f7592a48e8c8544456b42:
• build (20.x): ✓
• build (18.x): ✓
Modify app/inputs/GoogleCalendar/Input.test.ts with contents:
• 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.--- +++ @@ -32,7 +32,7 @@ describe('getWorklogs', () => { beforeEach(() => { - mockedGetEventsList.mockResolvedValue({ data: { items: [] } }); + mockedGetEventsList.mockResolvedValue({ data: { items: [], eventTypes: ["default"] } }); mockedGetUserAuthenticatedOAuthClient.mockResolvedValue({}); });
- Running GitHub Actions for
app/inputs/GoogleCalendar/Input.test.ts
✓ Edit
Check app/inputs/GoogleCalendar/Input.test.ts with contents:Ran GitHub Actions for 18298ee514c96a0e4036177a255d9ab5598ed7d9:
• build (20.x): ✓
• build (18.x): ✓
- Modify
app/inputs/GoogleCalendar/Input.test.ts
! No changes made Edit
Modify app/inputs/GoogleCalendar/Input.test.ts with contents:
• 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 the `eventTypes` 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.
- Running GitHub Actions for
app/inputs/GoogleCalendar/Input.test.ts
✗ Edit
Check app/inputs/GoogleCalendar/Input.test.ts with contents:
Step 3: 🔁 Code Review
I have finished reviewing the code for completeness. I did not find errors for sweep/add_eventtypes_parameter_to_google_calen_385b2
.
🎉 Latest improvements to Sweep:
- New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
- Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
- Use the GitHub issues extension for creating Sweep issues directly from your editor.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.
This is an automated message generated by Sweep AI.
The GoogleCalendar Events.list API will start receiving an
eventTypes
parameter, which will be an array of strings. We need to give it the value["default"]
so that when they change their default behaviour we will not be impacted.The changes should happen in the
app/inputs/GoogleCalendar/Input.ts
file and its related tests.Checklist
app/inputs/GoogleCalendar/Input.ts
✓ e0fd479 Editapp/inputs/GoogleCalendar/Input.ts
✓ Editapp/inputs/GoogleCalendar/Input.test.ts
✓ 18298ee Editapp/inputs/GoogleCalendar/Input.test.ts
✓ Editapp/inputs/GoogleCalendar/Input.test.ts
! No changes made Editapp/inputs/GoogleCalendar/Input.test.ts
✗ EditThe text was updated successfully, but these errors were encountered: