Skip to content

Implement Spector integration tests for azure/client-generator-core/client-default-value#3835

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/implement-spector-integration-tests
Closed

Implement Spector integration tests for azure/client-generator-core/client-default-value#3835
Copilot wants to merge 5 commits intomainfrom
copilot/implement-spector-integration-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

Adds Spector integration test coverage for the @clientDefaultValue decorator scenarios, and fixes an emitter bug discovered in the process.

Emitter fix: header params with clientDefaultValue

Optional header parameters with @clientDefaultValue were wrapped in an options?.param !== undefined guard, which prevented the default from ever being sent when the caller omits the option. Since the paramMap already includes a ?? default fallback, the guard is unnecessary and incorrect.

Before (broken):

headers: {
  ...(options?.customHeader !== undefined
    ? { "custom-header": options?.customHeader ?? "application/json" }
    : {}),
}

After (fixed):

headers: {
  "custom-header": options?.customHeader ?? "application/json",
}

The fix is in buildHeaderParameter() in operationHelpers.ts: skip the undefined conditional when the parameter has a type-matching clientDefaultValue. This mirrors how query/path parameters with defaults are already handled.

New test coverage

  • Added azure/client-generator-core/client-default-value to azureModularTsps in cadl-ranch-list.js
  • Generated client and scaffolding (tspconfig.yaml, .gitignore, src/index.d.ts)
  • Created azureClientGeneratorCoreClientDefaultValue.spec.ts covering all four scenarios:
    • putModelProperty — model property defaults (timeout, tier, retry) returned by server
    • getOperationParameter — query param defaults (pageSize=10, format=json) auto-applied
    • getPathParameter — path parameter with explicit default value
    • getHeaderParameter — header defaults (accept, x-custom-header) auto-applied without caller input
  • Updated clientDefaultValue.md unit test snapshot to match corrected header emission
  • Updated @typespec/http-specs and @azure-tools/azure-http-specs to latest dev versions

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits March 10, 2026 08:17
…lient-default-value

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
…fined check

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Spector integration tests for client default value Implement Spector integration tests for azure/client-generator-core/client-default-value Mar 10, 2026
@v-jiaodi v-jiaodi added the Experiement Experiement PR/issue for AI label Mar 17, 2026
@qiaozha qiaozha added the HRLC label Apr 1, 2026
@v-jiaodi
Copy link
Copy Markdown
Member

v-jiaodi commented Apr 8, 2026

@copilot pull main branch and resolve conflicts, then fix ci error.

Co-authored-by: v-jiaodi <80496810+v-jiaodi@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot pull main branch and resolve conflicts, then fix ci error.

Done in commit 4b36224. Merged origin/main and resolved 3 conflicts:

  • packages/typespec-ts/package.json — used main's newer dependency versions
  • packages/typespec-ts/src/modular/helpers/operationHelpers.ts — combined our hasClientDefault fix with main's paramAccessor refactor
  • pnpm-lock.yaml — accepted main's lockfile

Also updated the spec file to use vitest imports (migrated from chai) per the test runner migration that landed on main. All 4 integration tests and 617 unit tests pass.

Copilot AI requested a review from v-jiaodi April 8, 2026 06:19
@v-jiaodi
Copy link
Copy Markdown
Member

v-jiaodi commented Apr 8, 2026

Close it as duplicating with #3901

@v-jiaodi v-jiaodi closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Experiement Experiement PR/issue for AI HRLC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants