t160 測試跟上規格:人工建庫 POST → 404(庫只從 daemon 同步來)
舊測試驗「POST 建庫 200+重複 409」=已刪端點的規格;vitest 回基線 9 failed/187 passed。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -300,42 +300,16 @@ describe('PATCH libraries(每帳號可查庫)', () => {
|
|||||||
// ═══════════════ 5. 庫目錄管理 ═══════════════
|
// ═══════════════ 5. 庫目錄管理 ═══════════════
|
||||||
|
|
||||||
describe('/portal/admin/libraries', () => {
|
describe('/portal/admin/libraries', () => {
|
||||||
it('POST 建庫:寫 {tenant}::portal 子 namespace;重複登記 → 409', async () => {
|
it('t160:人工建庫端點已刪(leo「沒有登記這回事」)——POST → 404;庫只從 daemon 同步來', async () => {
|
||||||
await seedAdminSession();
|
// 舊測試驗「POST 建庫 200+重複 409」——t160 拔掉人工建庫(e744ad1)後規格為:
|
||||||
mockGetRecord('rec_admin', adminValues());
|
// 庫由 /portal/daemon/libraries(連線精靈自動登記,t159)產生,admin 只能 GET/PATCH。
|
||||||
mockTemplatesExist();
|
|
||||||
mockListByTemplate('portal_library', []);
|
|
||||||
let recordBody = '';
|
|
||||||
fetchMock
|
|
||||||
.get(KBDB)
|
|
||||||
.intercept({ path: '/records', method: 'POST' })
|
|
||||||
.reply(200, (opts) => {
|
|
||||||
recordBody = String(opts.body);
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
record: { record_id: 'rec_lib1', template_id: 'tpl_pl', values: { name: 'finance', display_name: '財務庫', status: 'active' } },
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const res = await json(
|
const res = await json(
|
||||||
'POST',
|
'POST',
|
||||||
'/portal/admin/libraries',
|
'/portal/admin/libraries',
|
||||||
{ name: 'finance', display_name: '財務庫' },
|
{ name: 'finance', display_name: '財務庫' },
|
||||||
{ Authorization: 'Bearer tok-admin' },
|
{ Authorization: 'Bearer tok-admin' },
|
||||||
);
|
);
|
||||||
expect(res.status).toBe(200);
|
expect(res.status).toBe(404);
|
||||||
const rec = JSON.parse(recordBody) as { owner_id: string; template: string };
|
|
||||||
expect(rec.owner_id).toBe(NS);
|
|
||||||
expect(rec.template).toBe('portal_library');
|
|
||||||
|
|
||||||
// 重複登記
|
|
||||||
await seedAdminSession('tok-admin3');
|
|
||||||
mockGetRecord('rec_admin', adminValues());
|
|
||||||
mockTemplatesExist();
|
|
||||||
mockListByTemplate('portal_library', [
|
|
||||||
{ record_id: 'rec_lib1', values: { name: 'finance', display_name: '財務庫', status: 'active' } },
|
|
||||||
]);
|
|
||||||
const dup = await json('POST', '/portal/admin/libraries', { name: 'finance' }, { Authorization: 'Bearer tok-admin3' });
|
|
||||||
expect(dup.status).toBe(409);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('PATCH graph_source:boolean 進、slot 存字串;非 boolean → 400', async () => {
|
it('PATCH graph_source:boolean 進、slot 存字串;非 boolean → 400', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user