-
Couldn't load subscription status.
- Fork 2
fix(test): stabilise examples #90
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
Conversation
- Load .env and provide safe fallbacks in bun.test.setup.ts - Default SKIP_LLM_EXAMPLES=1 to avoid LLM-dependent examples in CI - Run examples with preload + .env; allow skipping openai/ai-sdk/human-in-the-loop - MSW: mock StackOne HRIS endpoints used by examples for deterministic behavior All tests passing locally: 135 pass, 0 fail.
- Use ??= for env fallbacks in test setup - Replace null/undefined unions with checks in RequestBuilder - Update snapshots to match current generated specs
commit: |
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.
Pull Request Overview
This PR stabilizes example tests by adding MSW mocks for network dependencies and improving null/undefined checks with nullish coalescing operators.
Key changes:
- Enhanced test setup with environment variable defaults and LLM example skipping
- Added MSW mocks for StackOne HRIS endpoints to eliminate network dependencies
- Replaced explicit null/undefined checks with nullish coalescing in RequestBuilder
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| examples/examples.spec.ts | Added LLM example filtering and MSW preloading for isolated test runs |
| bun.test.setup.ts | Added dotenv loading and safe environment variable defaults using nullish assignment |
| mocks/handlers.ts | Added StackOne HRIS endpoint mocks for employee data |
| src/modules/requestBuilder.ts | Replaced explicit null/undefined checks with nullish equality operators |
| src/toolsets/tests/snapshots/stackone.spec.ts.snap | Updated snapshots with new date-time format and description changes |
| src/openapi/tests/snapshots/openapi-parser.spec.ts.snap | Updated snapshots with new date-time format and description changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
1 issue found across 6 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| return HttpResponse.json({ | ||
| id: params.id, | ||
| name: 'Michael Scott', | ||
| phone_numbers: ['+1-555-0100'], |
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.
Inconsistent field naming/type between list and detail responses ('phone_number' string vs 'phone_numbers' array). Align the property for consistency to avoid downstream confusion.
Prompt for AI agents
Address the following comment on mocks/handlers.ts at line 23:
<comment>Inconsistent field naming/type between list and detail responses ('phone_number' string vs 'phone_numbers' array). Align the property for consistency to avoid downstream confusion.</comment>
<file context>
@@ -1,6 +1,30 @@
+ return HttpResponse.json({
+ id: params.id,
+ name: 'Michael Scott',
+ phone_numbers: ['+1-555-0100'],
+ });
+ }
</file context>
| phone_numbers: ['+1-555-0100'], | |
| phone_number: '+1-555-0100', |
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.
LGTM
Stabilize example tests to run without network and prefer nullish operations.
Changes
Results
Summary by cubic
Stabilizes example tests to run offline and reduces flakiness in CI. Also adopts nullish operations for env defaults and RequestBuilder checks, and updates snapshots to current specs.
New Features
Refactors