From 7f7016b4ad9a05493c69081b6c62e0a49c0a3423 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Mar 2026 12:30:08 +0000 Subject: [PATCH] Add Persona Studio link in docs nav, update smoke tests to target unified proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 🧠 Persona Studio navigation tab in docs/index.html sidebar - Update smoke tests to target api-proxy.js (port 3721) instead of persona-studio backend (3002) - Update error code assertion to match improved error specificity - Add test for INVALID_API_BASE validation - Replace auth/login tests with /api/health check (auth is on separate service) Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- docs/index.html | 1 + tests/smoke/apikey-detect.test.js | 54 ++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/docs/index.html b/docs/index.html index f2ff6304..02a72375 100644 --- a/docs/index.html +++ b/docs/index.html @@ -467,6 +467,7 @@ footer{padding:12px 18px 16px;padding-bottom:max(16px,env(safe-area-inset-bottom diff --git a/tests/smoke/apikey-detect.test.js b/tests/smoke/apikey-detect.test.js index 8ba67d90..ac51ec8b 100644 --- a/tests/smoke/apikey-detect.test.js +++ b/tests/smoke/apikey-detect.test.js @@ -6,7 +6,7 @@ */ const http = require('http'); -const BASE = process.env.TEST_BASE || 'http://localhost:3002'; +const BASE = process.env.TEST_BASE || 'http://localhost:3721'; function post(path, body) { return new Promise((resolve, reject) => { @@ -64,7 +64,17 @@ describe('POST /api/ps/apikey/detect-models', () => { }); expect(res.status).toBe(502); expect(res.body.error).toBe(true); - expect(res.body.code).toBe('DETECT_FAILED'); + expect(['DETECT_FAILED', 'DNS_ERROR', 'NETWORK_ERROR', 'TIMEOUT']).toContain(res.body.code); + }); + + test('returns INVALID_API_BASE for malformed URL', async () => { + const res = await post('/api/ps/apikey/detect-models', { + api_base: 'not-a-url', + api_key: 'sk-test' + }); + expect(res.status).toBe(400); + expect(res.body.error).toBe(true); + expect(res.body.code).toBe('INVALID_API_BASE'); }); }); @@ -88,18 +98,32 @@ describe('POST /api/ps/apikey/chat', () => { }); }); -describe('POST /api/ps/auth/login (dev_id still works)', () => { - test('EXP-000 dev_id login succeeds', async () => { - const res = await post('/api/ps/auth/login', { dev_id: 'EXP-000' }); - expect(res.status).toBe(200); - expect(res.body.error).toBe(false); - expect(res.body.dev_id).toBe('EXP-000'); - expect(res.body.token).toBeTruthy(); - }); - - test('invalid dev_id is rejected', async () => { - const res = await post('/api/ps/auth/login', { dev_id: 'INVALID' }); - expect(res.status).toBe(400); - expect(res.body.error).toBe(true); +describe('GET /api/health (proxy health check)', () => { + test('returns ok status', async () => { + return new Promise((resolve, reject) => { + const url = new URL(BASE + '/api/health'); + const req = http.request({ + hostname: url.hostname, + port: url.port, + path: url.pathname, + method: 'GET', + timeout: 10000 + }, (res) => { + let chunks = ''; + res.on('data', (c) => { chunks += c; }); + res.on('end', () => { + try { + const body = JSON.parse(chunks); + expect(res.statusCode).toBe(200); + expect(body.status).toBe('ok'); + resolve(); + } catch (e) { + reject(e); + } + }); + }); + req.on('error', reject); + req.end(); + }); }); });