This commit is contained in:
QLHazyCoder
2026-05-20 04:02:39 +08:00
8 changed files with 149 additions and 14 deletions
@@ -171,6 +171,65 @@ test('kiro publisher reads latest kiro.rs key from background state instead of s
assert.equal(completed[0].nodeId, 'kiro-upload-credential');
});
test('kiro publisher routes step 9 through public contribution upload when contribution mode is enabled', async () => {
const api = loadPublisherApi();
const requests = [];
const completed = [];
let liveState = {
activeFlowId: 'kiro',
flowId: 'kiro',
accountContributionEnabled: true,
contributionAdapterId: 'kiro-builder-id',
kiroTargetId: 'kiro-rs',
kiroRuntime: {
register: {
email: 'aws-user@example.com',
},
desktopAuth: {
region: 'us-east-1',
clientId: 'client-001',
clientSecret: 'secret-001',
refreshToken: 'refresh-token-001',
},
upload: {
targetId: 'kiro-rs',
},
},
};
const publisher = api.createKiroRsPublisher({
addLog: async () => {},
completeNodeFromBackground: async (nodeId, payload) => {
completed.push({ nodeId, payload });
},
fetchImpl: async (url, options = {}) => {
requests.push({ url, options });
throw new Error('kiro.rs upload should not be called in contribution mode');
},
getState: async () => ({ ...liveState }),
maybeSubmitFlowContribution: async (_state, options = {}) => ({
ok: true,
skipped: false,
contributionId: 'kiro-contribution-009',
message: `贡献链路成功:${options.trigger || 'unknown'}`,
}),
setState: async (updates = {}) => {
liveState = { ...liveState, ...updates };
},
});
await publisher.executeKiroUploadCredential({
nodeId: 'kiro-upload-credential',
});
assert.equal(requests.length, 0);
assert.equal(completed.length, 1);
assert.equal(completed[0].nodeId, 'kiro-upload-credential');
assert.equal(completed[0].payload.kiroRuntime.upload.targetId, 'contribution');
assert.equal(completed[0].payload.kiroRuntime.upload.status, 'uploaded');
assert.equal(completed[0].payload.kiroRuntime.upload.credentialId, 'kiro-contribution-009');
assert.equal(completed[0].payload.kiroRuntime.upload.lastMessage, '贡献链路成功:kiro-step-9');
});
test('kiro publisher trims api key and includes fallback Authorization header during connection check', async () => {
const api = loadPublisherApi();
const requests = [];
+6 -4
View File
@@ -210,8 +210,10 @@ test('Kiro contribution adapter redacts server errors that echo submitted secret
assert.equal(combined.includes('client-secret-super-long'), false);
});
test('Kiro desktop authorization runner is wired to submit public contribution after step 8', () => {
const source = fs.readFileSync('background/kiro/desktop-authorize-runner.js', 'utf8');
assert.match(source, /maybeSubmitFlowContribution/);
assert.match(source, /trigger:\s*'kiro-step-8'/);
test('Kiro public contribution is triggered from step 9 instead of step 8', () => {
const desktopSource = fs.readFileSync('background/kiro/desktop-authorize-runner.js', 'utf8');
const publisherSource = fs.readFileSync('background/kiro/publisher-kiro-rs.js', 'utf8');
assert.doesNotMatch(desktopSource, /trigger:\s*'kiro-step-8'/);
assert.match(publisherSource, /maybeSubmitFlowContribution/);
assert.match(publisherSource, /trigger:\s*'kiro-step-9'/);
});
+2
View File
@@ -190,6 +190,8 @@ test('step definitions module exposes ordered normal and Plus step metadata', ()
assert.equal(kiroSteps[6].title, '启动桌面授权');
assert.equal(kiroSteps[7].title, '完成桌面授权');
assert.equal(kiroSteps[8].title, '上传凭据到 kiro.rs');
const kiroContributionSteps = api.getSteps({ activeFlowId: 'kiro', accountContributionEnabled: true });
assert.equal(kiroContributionSteps[8].title, '贡献上传');
assert.deepStrictEqual(api.getStepIds({ activeFlowId: 'kiro' }), [1, 2, 3, 4, 5, 6, 7, 8, 9]);
assert.equal(api.getLastStepId({ activeFlowId: 'kiro' }), 9);
assert.deepStrictEqual(