Conversation
There was a problem hiding this comment.
Pull request overview
Removes several legacy Twilio Serverless endpoints (and their tests) that are no longer used or have been migrated to Twilio Lambda, while keeping the adjustChatCapacity logic as an internal/private module used by other functions.
Changes:
- Deleted unused/migrated function endpoints:
assignOfflineContact,checkTaskAssignment,completeTaskAssignment,getTaskAndReservations,autopilotRedirect,createContactlessTask. - Updated
adjustChatCapacityto be logic-only (no HTTP handler) and updated callers/tests to import/use the private module. - Removed tests that only covered deleted endpoints and refactored
adjustChatCapacitytests to exercise the internal function directly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/createContactlessTask.test.ts | Removed tests for deleted createContactlessTask endpoint. |
| tests/autopilotRedirect.test.ts | Removed tests for deleted autopilotRedirect endpoint. |
| tests/assignOfflineContact.test.ts | Removed tests for deleted assignOfflineContact endpoint. |
| tests/adjustChatCapacity.test.ts | Updated tests to target adjustChatCapacity.private directly (no serverless callback/response). |
| functions/transferChatStart.ts | Updated type import to reference adjustChatCapacity.private. |
| functions/taskrouterListeners/adjustCapacityListener.private.ts | Updated type import to reference adjustChatCapacity.private. |
| functions/pullTask.ts | Updated AdjustChatCapacityType import path to adjustChatCapacity.private. |
| functions/getTaskAndReservations.ts | Deleted unused/migrated endpoint implementation. |
| functions/createContactlessTask.ts | Deleted unused endpoint implementation. |
| functions/completeTaskAssignment.ts | Deleted unused/migrated endpoint implementation. |
| functions/checkTaskAssignment.ts | Deleted unused/migrated endpoint implementation. |
| functions/autopilotRedirect.protected.ts | Deleted unused endpoint implementation. |
| functions/assignOfflineContact.ts | Deleted superseded endpoint implementation. |
| functions/adjustChatCapacity.private.ts | Removed serverless handler; retained internal adjustChatCapacity function + type export. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| success, | ||
| } from '@tech-matters/serverless-helpers'; | ||
| import { AdjustChatCapacityType } from './adjustChatCapacity'; | ||
| import { AdjustChatCapacityType } from './adjustChatCapacity.private'; |
There was a problem hiding this comment.
AdjustChatCapacityType is only used as a type in this file; consider switching this to a type-only import (import type { ... }) to avoid any chance of a runtime import and to match the pattern used in transferChatStart.ts / adjustCapacityListener.private.ts.
| import { AdjustChatCapacityType } from './adjustChatCapacity.private'; | |
| import type { AdjustChatCapacityType } from './adjustChatCapacity.private'; |
| test('Should throw with incomplete data', async () => { | ||
| const workerSid = 'worker123'; | ||
| // const adjustment = 'increase'; | ||
| const event1 = { request: { cookies: {}, headers: {} } }; | ||
| const event2 = { ...event1, workerSid }; | ||
|
|
||
| const events = [event1, event2]; | ||
|
|
||
| const callback: ServerlessCallback = (err, result) => { | ||
| expect(result).toBeDefined(); | ||
| const response = result as MockedResponse; | ||
| expect(response.getStatus()).toBe(400); | ||
| }; | ||
|
|
||
| await Promise.all(events.map((e) => adjustChatCapacity(baseContext, e, callback))); | ||
| const event1 = {}; | ||
| const event2 = { workerSid }; | ||
| await expect(adjustChatCapacity(baseContext, event1 as Body)).rejects.toThrow(); | ||
| await expect(adjustChatCapacity(baseContext, event2 as Body)).resolves.toStrictEqual({ | ||
| status: 400, | ||
| message: 'Invalid adjustment argument', | ||
| }); | ||
| }); |
There was a problem hiding this comment.
This test name says it "Should throw with incomplete data", but the second case expects a resolved { status: 400, ... }. Consider splitting into two tests (missing workerSid vs missing/invalid adjustment) or renaming the test to reflect both behaviors. Also, casting event1/event2 to a Required Body bypasses type-safety in a way that's easy to miss; using a Partial<Body>/unknown cast for the negative cases would make the intent clearer.
Description
Remove several endpoints that were either migrated to the Twilio Lambda or just haven't been used for years
Checklist
Other Related Issues
None
Verification steps
AFTER YOU MERGE
You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P