Add Persona Studio link in docs nav, update smoke tests to target unified proxy
- 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>
This commit is contained in:
parent
e36bc19cfb
commit
7f7016b4ad
|
|
@ -467,6 +467,7 @@ footer{padding:12px 18px 16px;padding-bottom:max(16px,env(safe-area-inset-bottom
|
||||||
<nav class="ls-nav">
|
<nav class="ls-nav">
|
||||||
<button class="nav-tab active" data-view="announcements" onclick="navigateTo('announcements')">📢 公告栏</button>
|
<button class="nav-tab active" data-view="announcements" onclick="navigateTo('announcements')">📢 公告栏</button>
|
||||||
<button class="nav-tab" data-view="chat" onclick="navigateTo('chat')">💬 聊天</button>
|
<button class="nav-tab" data-view="chat" onclick="navigateTo('chat')">💬 聊天</button>
|
||||||
|
<button class="nav-tab" onclick="window.open('../persona-studio/frontend/index.html','_blank')">🧠 Persona Studio</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<button class="ls-new-conv" onclick="newConvAndNav()">+ 新对话</button>
|
<button class="ls-new-conv" onclick="newConvAndNav()">+ 新对话</button>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
const http = require('http');
|
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) {
|
function post(path, body) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -64,7 +64,17 @@ describe('POST /api/ps/apikey/detect-models', () => {
|
||||||
});
|
});
|
||||||
expect(res.status).toBe(502);
|
expect(res.status).toBe(502);
|
||||||
expect(res.body.error).toBe(true);
|
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)', () => {
|
describe('GET /api/health (proxy health check)', () => {
|
||||||
test('EXP-000 dev_id login succeeds', async () => {
|
test('returns ok status', async () => {
|
||||||
const res = await post('/api/ps/auth/login', { dev_id: 'EXP-000' });
|
return new Promise((resolve, reject) => {
|
||||||
expect(res.status).toBe(200);
|
const url = new URL(BASE + '/api/health');
|
||||||
expect(res.body.error).toBe(false);
|
const req = http.request({
|
||||||
expect(res.body.dev_id).toBe('EXP-000');
|
hostname: url.hostname,
|
||||||
expect(res.body.token).toBeTruthy();
|
port: url.port,
|
||||||
});
|
path: url.pathname,
|
||||||
|
method: 'GET',
|
||||||
test('invalid dev_id is rejected', async () => {
|
timeout: 10000
|
||||||
const res = await post('/api/ps/auth/login', { dev_id: 'INVALID' });
|
}, (res) => {
|
||||||
expect(res.status).toBe(400);
|
let chunks = '';
|
||||||
expect(res.body.error).toBe(true);
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue