Skip to content

Conversation

@ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Sep 2, 2025

Stabilize example tests to run without network and prefer nullish operations.

Changes

  • Examples: run with preload + .env; skip LLM-heavy files via SKIP_LLM_EXAMPLES.
  • Test setup: load dotenv; use ??= defaults for OPENAI_API_KEY/STACKONE_API_KEY/SKIP_LLM_EXAMPLES.
  • MSW mocks: add HRIS endpoints used by examples.
  • RequestBuilder: replace null/undefined checks with == null / != null where appropriate.
  • Snapshots: update to match current generated specs.

Results

  • bun test: 135 pass, 0 fail.

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

    • Run examples with Bun preload and .env to activate MSW and env loading.
    • Mock StackOne HRIS endpoints in MSW for deterministic example runs.
    • Skip LLM-heavy examples via SKIP_LLM_EXAMPLES (default 1).
  • Refactors

    • Use dotenv and ??= for OPENAI_API_KEY, STACKONE_API_KEY, and SKIP_LLM_EXAMPLES in test setup.
    • Replace explicit null/undefined checks with == null / != null in RequestBuilder.
    • Refresh OpenAPI and toolset snapshots.
    • Result: 135 passing tests, 0 failing.

- 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
Copilot AI review requested due to automatic review settings September 2, 2025 13:02
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 2, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@90

commit: f17566c

Copy link

Copilot AI left a 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.

@ryoppippi ryoppippi changed the title chore(test): stabilize examples and prefer nullish ops fix(test): stabilize examples and prefer nullish ops Sep 2, 2025
@ryoppippi ryoppippi changed the title fix(test): stabilize examples and prefer nullish ops fix(test): stabilise examplesf Sep 2, 2025
@ryoppippi ryoppippi changed the title fix(test): stabilise examplesf fix(test): stabilise examples Sep 2, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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'],
Copy link
Contributor

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 (&#39;phone_number&#39; string vs &#39;phone_numbers&#39; array). Align the property for consistency to avoid downstream confusion.</comment>

<file context>
@@ -1,6 +1,30 @@
+      return HttpResponse.json({
+        id: params.id,
+        name: &#39;Michael Scott&#39;,
+        phone_numbers: [&#39;+1-555-0100&#39;],
+      });
+    }
</file context>
Suggested change
phone_numbers: ['+1-555-0100'],
phone_number: '+1-555-0100',

Copy link
Contributor

@glebedel glebedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ryoppippi ryoppippi merged commit 015660d into main Sep 4, 2025
14 checks passed
@ryoppippi ryoppippi deleted the test/stabilize-examples branch September 4, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants