小壹续做时锁定版本在知识库已下线或换号,提示后继续用本地锁定资料;认证失败仍停止
This commit is contained in:
parent
a8d52c5ec0
commit
2aed7dc1cf
@ -34,7 +34,7 @@ export async function openEnterpriseSkills(store, selection, load, loadReference
|
||||
if (await checkPinned(saved)) versionNotice = '有新版规则,当前项目继续使用已锁定的版本。';
|
||||
} catch (error) {
|
||||
signal?.throwIfAborted();
|
||||
if (error.name==='AbortError' || [401,403,404,410].includes(error.status)) throw error;
|
||||
if (error.name==='AbortError' || [401,403].includes(error.status)) throw error;
|
||||
versionNotice = '无法检查企业规则版本,当前项目继续使用已锁定的版本:' + error.message;
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,10 +121,10 @@ test('a project downloads every declared guide at startup and reads only its loc
|
||||
assert.match((await reopen()).versionNotice,/有新版规则/u);
|
||||
assert.equal(await fs.readFile(reviewPath,'utf8'),'rules body 11');
|
||||
assert.equal(docs.length,19);
|
||||
for(const denied of [403,404]){
|
||||
status=denied;
|
||||
await assert.rejects(reopen(),{status:denied});
|
||||
}
|
||||
status=403;
|
||||
await assert.rejects(reopen(),{status:403});
|
||||
status=404;
|
||||
assert.match((await reopen()).versionNotice,/当前项目继续使用已锁定的版本/u);
|
||||
status=409;
|
||||
await fs.writeFile(reviewPath,'corrupted');
|
||||
await assert.rejects(reopen(),/本地副本校验失败/u);
|
||||
@ -253,6 +253,24 @@ test('制作锁定同时保存规则引用的图片、PDF 和 JSON 附件', asyn
|
||||
assert.equal(attached.files.length,4);
|
||||
});
|
||||
|
||||
test('续做时锁定版本在知识库已下线或换号,继续使用本地锁定资料;认证失败仍停止', async t => {
|
||||
const root=await fs.mkdtemp(path.join(os.tmpdir(),'xiaoyi-pinned-gone-'));
|
||||
t.after(()=>fs.rm(root,{recursive:true}));
|
||||
const store={root,dir:root,appendEvent:async()=>{}};
|
||||
const selection={resourceSetId:'pinned'};
|
||||
const skill={fileId:'skill',revision:'1',path:'Skills/guide/SKILL.md',kind:'skill',text:'---\nname: guide\ndescription: Guide.\n---\n正文'};
|
||||
await openEnterpriseSkills(store,selection,async()=>({skills:[skill],rules:[]}),()=>assert.fail('没有附件'));
|
||||
for (const status of [404,410]) {
|
||||
const reopened=await openEnterpriseSkills(store,selection,()=>assert.fail('续做不重新锁定'),undefined,
|
||||
async()=>{ throw Object.assign(Error('企业知识库资料不存在或不可读取(HTTP '+status+')'),{status}); });
|
||||
assert.match(reopened.versionNotice,/当前项目继续使用已锁定的版本/);
|
||||
}
|
||||
for (const status of [401,403]) {
|
||||
await assert.rejects(openEnterpriseSkills(store,selection,()=>assert.fail('续做不重新锁定'),undefined,
|
||||
async()=>{ throw Object.assign(Error('认证失败'),{status}); }),{status});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('开工读取按 Pi 节奏有限重试,权限和资源状态立即返回', async () => {
|
||||
const read=DetailPiAgent.prototype.productionKnowledgeRead.call({canvas:{read:async()=>({})}},'production');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user