From 846a5e65668e7b382ba123d2810cf8dcc02feb87 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 04:22:10 +0000 Subject: [PATCH 1/2] Initial plan From 5504a42964471c7758df094d249bbed9a527b315 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 04:24:08 +0000 Subject: [PATCH 2/2] Fix async rate-limited API test requests Co-authored-by: aaronparker <8227455+aaronparker@users.noreply.github.com> --- tests/test.js | 98 ++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/tests/test.js b/tests/test.js index 4b8e445..d7050ae 100644 --- a/tests/test.js +++ b/tests/test.js @@ -162,28 +162,26 @@ describe('Request validation', () => { it('GET /app/MicrosoftEdge without User-Agent should stay compatible with deployed API variants', () => { return makeRequest('/health') - .then((healthRes) => { + .then(async (healthRes) => { const newApi = isNewCachingAPI(healthRes.headers); - return makeRateLimitedRequest('/app/MicrosoftEdge', false) - .expect('Content-Type', /json/) - .then((res) => { - if (newApi) { - assert.equal(res.status, 400); - assert.property(res.body, 'message'); - assert.include(res.body.message, 'User-Agent'); - } else if (res.status === 200) { - if (Array.isArray(res.body)) { - assert.isArray(res.body); - } else { - assert.isObject(res.body); - } - } else if (res.status === 404) { - assert.property(res.body, 'message'); - } else { - throw new Error(`Unexpected status code: ${res.status}`); - } - }); + const res = await makeRateLimitedRequest('/app/MicrosoftEdge', false); + assert.match(res.headers['content-type'], /json/); + if (newApi) { + assert.equal(res.status, 400); + assert.property(res.body, 'message'); + assert.include(res.body.message, 'User-Agent'); + } else if (res.status === 200) { + if (Array.isArray(res.body)) { + assert.isArray(res.body); + } else { + assert.isObject(res.body); + } + } else if (res.status === 404) { + assert.property(res.body, 'message'); + } else { + throw new Error(`Unexpected status code: ${res.status}`); + } }); }); }); @@ -266,37 +264,35 @@ describe('Apps API', () => { // Individual app endpoint validation describe('App API', () => { - it('GET /app/MicrosoftEdge should return app details or not found', () => { - return makeRateLimitedRequest('/app/MicrosoftEdge') - .expect('Content-Type', /json/) - .then((res) => { - if (res.status === 200) { - // App data exists - validate structure - if (Array.isArray(res.body)) { - // Production API returns array - assert.isArray(res.body); - assert.isNotEmpty(res.body); - - const firstItem = res.body[0]; - assert.property(firstItem, 'Version'); - assert.property(firstItem, 'URI'); - } else { - // New API returns object - assert.isObject(res.body); - assert.property(res.body, 'Version'); - assert.property(res.body, 'URI'); - } - - // Check cache headers - assert.property(res.headers, 'cache-control'); - } else if (res.status === 404) { - // Expected if no data in KV - assert.property(res.body, 'message'); - assert.include(res.body.message, 'Application not found'); - } else { - throw new Error(`Unexpected status code: ${res.status}`); - } - }); + it('GET /app/MicrosoftEdge should return app details or not found', async () => { + const res = await makeRateLimitedRequest('/app/MicrosoftEdge'); + assert.match(res.headers['content-type'], /json/); + if (res.status === 200) { + // App data exists - validate structure + if (Array.isArray(res.body)) { + // Production API returns array + assert.isArray(res.body); + assert.isNotEmpty(res.body); + + const firstItem = res.body[0]; + assert.property(firstItem, 'Version'); + assert.property(firstItem, 'URI'); + } else { + // New API returns object + assert.isObject(res.body); + assert.property(res.body, 'Version'); + assert.property(res.body, 'URI'); + } + + // Check cache headers + assert.property(res.headers, 'cache-control'); + } else if (res.status === 404) { + // Expected if no data in KV + assert.property(res.body, 'message'); + assert.include(res.body.message, 'Application not found'); + } else { + throw new Error(`Unexpected status code: ${res.status}`); + } }); it('GET /app without name should return 400 error', () => {