Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .chronus/changes/fix-http-specs-e2e-tests-2026-03-09.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@typespec/http-specs"
- "@typespec/spector"
---

Fix e2e test failures: duration header float scenarios, multipart file upload scenarios, XML pagination content-type mismatch, and response body data mismatch validation
2 changes: 1 addition & 1 deletion packages/http-specs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"upload-coverage": "tsp-spector upload-coverage --generatorName @typespec/http-specs --generatorVersion 0.1.0-alpha.4 --containerName coverages --generatorMode standard --storageAccountName typespec",
"validate-mock-apis": "tsp-spector validate-mock-apis ./specs",
"check-scenario-coverage": "tsp-spector check-coverage ./specs",
"validate-client-server": "concurrently \"tsp-spector server start ./specs\" \"pnpm knock\"; tsp-spector server stop",
"validate-client-server": "concurrently \"tsp-spector server start ./specs\" \"pnpm knock\"; code=$?; tsp-spector server stop; exit $code",
"build:smoke": "tsp compile smoke/petstore --warn-as-error --no-emit && tsp compile smoke/todoapp --warn-as-error --no-emit",
"client": "pnpm knock",
"knock": "tsp-spector knock ./specs",
Expand Down
5 changes: 5 additions & 0 deletions packages/http-specs/specs/encode/duration/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ function createHeaderFloatServerTests(uri: string, value: number) {
return passOnSuccess({
uri,
method: "get",
request: {
headers: {
duration: String(value),
},
},
response: {
status: 204,
},
Expand Down
25 changes: 16 additions & 9 deletions packages/http-specs/specs/payload/multipart/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@ Scenarios.Payload_MultiPart_FormData_File_uploadFileSpecificContentType = passOn
uri: "/multipart/form-data/file/specific-content-type",
method: "post",
request: {
headers: {
"content-type": "multipart/form-data",
},
body: multipart({
files: [
{ fieldname: "file", originalname: "image.png", buffer: pngFile, mimetype: "image/png" },
],
}),
},
response: {
status: 204,
Expand All @@ -460,9 +462,11 @@ Scenarios.Payload_MultiPart_FormData_File_uploadFileRequiredFilename = passOnSuc
uri: "/multipart/form-data/file/required-filename",
method: "post",
request: {
headers: {
"content-type": "multipart/form-data",
},
body: multipart({
files: [
{ fieldname: "file", originalname: "image.png", buffer: pngFile, mimetype: "image/png" },
],
}),
},
response: {
status: 204,
Expand All @@ -483,9 +487,12 @@ Scenarios.Payload_MultiPart_FormData_File_uploadFileArray = passOnSuccess({
uri: "/multipart/form-data/file/file-array",
method: "post",
request: {
headers: {
"content-type": "multipart/form-data",
},
body: multipart({
files: [
{ fieldname: "files", originalname: "image.png", buffer: pngFile, mimetype: "image/png" },
{ fieldname: "files", originalname: "image.png", buffer: pngFile, mimetype: "image/png" },
],
}),
},
response: {
status: 204,
Expand Down
17 changes: 12 additions & 5 deletions packages/http-specs/specs/payload/pageable/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
json,
MockRequest,
passOnSuccess,
ResolverConfig,
ScenarioMockApi,
ValidationError,
xml,
Expand Down Expand Up @@ -553,7 +554,7 @@ Scenarios.Payload_Pageable_XmlPagination_listWithContinuation = passOnSuccess([
status: 200,
body: xml(XmlContTokenFirstPage),
headers: {
"content-type": "application/xml",
"content-type": "application/xml; charset=utf-8",
},
},
handler: (req: MockRequest) => {
Expand Down Expand Up @@ -590,7 +591,7 @@ Scenarios.Payload_Pageable_XmlPagination_listWithContinuation = passOnSuccess([
status: 200,
body: xml(XmlContTokenSecondPage),
headers: {
"content-type": "application/xml",
"content-type": "application/xml; charset=utf-8",
},
},
handler: (req: MockRequest) => {
Expand Down Expand Up @@ -659,9 +660,15 @@ Scenarios.Payload_Pageable_XmlPagination_listWithNextLink = passOnSuccess([
request: {},
response: {
status: 200,
body: xml(xmlNextLinkFirstPage("PLACEHOLDER_BASE_URL")),
body: {
contentType: "application/xml",
rawContent: {
serialize: (config: ResolverConfig) =>
`<?xml version='1.0' encoding='UTF-8'?>` + xmlNextLinkFirstPage(config.baseUrl),
},
},
headers: {
"content-type": "application/xml",
"content-type": "application/xml; charset=utf-8",
},
},
handler: (req: MockRequest) => {
Expand All @@ -683,7 +690,7 @@ Scenarios.Payload_Pageable_XmlPagination_listWithNextLink = passOnSuccess([
status: 200,
body: xml(XmlNextLinkSecondPage),
headers: {
"content-type": "application/xml",
"content-type": "application/xml; charset=utf-8",
},
},
kind: "MockApiDefinition",
Expand Down
2 changes: 1 addition & 1 deletion packages/spector/src/actions/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ServerTestsGenerator {
switch (body.contentType) {
case "application/xml":
case "text/plain":
if (body.rawContent !== responseData) {
if (raw !== responseData) {
throw new ValidationError("Response data mismatch", raw, responseData);
}
break;
Expand Down
Loading