-
Notifications
You must be signed in to change notification settings - Fork 64
docs(test-fixtures): add AI documentation - AGENTS.md and ARCHITECTURE.md #595
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
base: next
Are you sure you want to change the base?
Conversation
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
Shreyas281299
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Looks good.
| - **Ensures consistency** - Same mock data across all tests | ||
| - **Supports customization** - Easy to extend or override fixtures | ||
|
|
||
| ### Key Capabilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current mockCC fixture does not include all SDK methods listed here (e.g., acceptTask, transferTask, outdial, etc.). Either expand mockCC or update this section to match the actual fixture surface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
|
|
||
| --- | ||
|
|
||
| ### mockProfile (Profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fixtures.ts, teams are {teamId, teamName}, and loginVoiceOptions is a string array. Update the example to match the real fixture shape.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
|
|
||
| --- | ||
|
|
||
| ### mockTask (ITask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual mockTask data uses data.interaction fields, not origin/destination. Update the example to match the real TaskData shape in fixtures.ts.
|
|
||
| --- | ||
|
|
||
| ## Available Fixtures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package exports additional fixtures from incomingTaskFixtures, taskListFixtures, and outdialCallFixtures (e.g., mockIncomingTaskData, mockTaskData, mockOutdialCallProps, mockAniEntries, mockCCWithAni). Add them to this table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
| --- | ||
|
|
||
| ## Dependencies | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixtures import types from @webex/contact-center as well. Either list it as a dependency or update this section to clarify it’s a type-only import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ensure we are not creating a circular dependency here. NOT IN THE SCOPE OF THIS PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, yeah we dont introduce any circular dependency.
dependency tree looks like below
@webex/contact-center
|
|
|-------------
| |
| V
| @webex/cc-store
| |
V V
@webex/test-fixtures
| Test Fixtures is a testing utility package that provides realistic mock data for all contact center SDK types and widgets. It follows a fixture pattern where each fixture is a pre-configured, reusable mock object that matches the actual SDK types. | ||
|
|
||
| ### Fixture Table | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual mockCC in fixtures.ts does not implement those methods. Update this table to reflect the real mockCC surface, or extend the mock to match the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its just taking about what are the available properties we dont say that we are implementing these methods
| | **makeMockAddressBook** | `Function` | `src/fixtures.ts` | Factory for custom address book | Via function parameter | | ||
|
|
||
| ### File Structure | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all fixtures are in fixtures.ts. There are additional exports in incomingTaskFixtures, taskListFixtures, and components/task/outdialCallFixtures. Update file structure and/or add those files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
|
|
||
| ### Key Capabilities | ||
|
|
||
| - **Complete SDK Mock**: Mock `IContactCenter` with all methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ensure if we have all the methods in the fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dont, so Ive reword this
| jest.mock('@webex/cc-store', () => ({ | ||
| cc: mockCC, | ||
| teams: mockProfile.teams, | ||
| loginOptions: mockProfile.loginVoiceOptions, | ||
| logger: mockCC.LoggerProxy, | ||
| isAgentLoggedIn: false, | ||
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check if we can provide this mock by default in the fixture itself. If required we should have some methods to override the mock or we can override manually like this
NOT IN THE SCOPE OF THIS PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I like this approach, Il explore this
|
|
||
| // Use in tests | ||
| test('calls SDK stationLogin method', async () => { | ||
| const loginSpy = jest.spyOn(mockCC, 'stationLogin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's verify if this is correct. We should be spying on the actual object I think and a particular method would be mocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, we are spying on the method stationLogin which is present in the object mockCC. We can do a mockImplementation but its not required
| import { CallControl } from '@webex/cc-task'; | ||
| import { mockTask } from '@webex/test-fixtures'; | ||
|
|
||
| test('renders call control for active task', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using it instead of test in our test files. Semantically we should be using test because we are not developing with TDD approach. Lets keep it for now
| await mockTask.hold(); | ||
| expect(mockTask.hold).toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way it would be too obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the example
|
|
||
| ## Component Overview | ||
|
|
||
| Test Fixtures is a testing utility package that provides realistic mock data for all contact center SDK types and widgets. It follows a fixture pattern where each fixture is a pre-configured, reusable mock object that matches the actual SDK types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems repeated info from AGENTS.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its just an overview, I feel it can be a little repetetive. If we find this to be affecting the performance of the LLM in any way then we will remove this
| ├── package.json | ||
| ├── tsconfig.json | ||
| └── webpack.config.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel.config.js is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
| AgentProxy: { /* agent-related methods */ }, | ||
| DiagnosticsProxy: { /* diagnostics methods */ }, | ||
| LoggerProxy: { /* logger methods */ }, | ||
| ScreenRecordingProxy: { /* screen recording */ }, | ||
| TaskProxy: { /* task subscriptions */ }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these ? I think casing is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the names were incorrect for the methods
| graph TB | ||
| subgraph "Test Setup" | ||
| Fixtures[Import Fixtures] | ||
| Mock[Mock Store/SDK] | ||
| end | ||
|
|
||
| subgraph "Test Execution" | ||
| Render[Render Component] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add screenshots of all these diagrams
| | SDK Feature | Mock Provided | Customizable | | ||
| |-------------|---------------|--------------| | ||
| | Station Login/Logout | ✅ `mockCC.stationLogin`, `mockCC.stationLogout` | ✅ Via jest mocking | | ||
| | User State | ✅ `mockCC.setUserState` | ✅ Via jest mocking | | ||
| | Task Accept/End | ✅ `mockCC.acceptTask`, `mockCC.endTask` | ✅ Via jest mocking | | ||
| | Task Hold/Resume | ✅ `mockTask.hold`, `mockTask.resume` | ✅ Via jest mocking | | ||
| | Transfer/Consult | ✅ `mockCC.transferTask`, `mockCC.consultTask` | ✅ Via jest mocking | | ||
| | Recording | ✅ `mockCC.pauseRecording`, `mockCC.resumeRecording` | ✅ Via jest mocking | | ||
| | Outdial | ✅ `mockCC.outdial`, `mockEntryPointsResponse` | ✅ Via jest mocking | | ||
| | Address Book | ✅ `makeMockAddressBook` | ✅ Via factory parameter | | ||
| | Agent Profile | ✅ `mockProfile` | ✅ Via object spread | | ||
| | Queues | ✅ `mockQueueDetails` | ✅ Via array modification | | ||
| | Agents | ✅ `mockAgents` | ✅ Via array modification | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Values for 3rd column ( Customizable ) - Isn't all mocked using jest mocking only then we pass the mock value in different shapes as required ? Correct me if I my understanding is wrong here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wherever it says 'via jest mock' those are methods that are set to jest.fn() and where it says via object or array there we have set a custom object to map the correct type, for example AgentProfile
COMPLETES N/A - Documentation Enhancement
This pull request addresses
Adding AI-optimized documentation for the test-fixtures package to help AI assistants understand the test mocks and utilities.
by making the following changes
packages/contact-center/test-fixtures/ai-docs/AGENTS.md- Usage documentation for test mockspackages/contact-center/test-fixtures/ai-docs/ARCHITECTURE.md- Technical implementation detailsChange Type
The following scenarios were tested
The GAI Coding Policy And Copyright Annotation Best Practices
Checklist before merging
Make sure to have followed the contributing guidelines before submitting.