Add staging simulation guide and refine hose integration sync
- Add comprehensive reference guide for staging simulation and production rule evolution - Require latest CLI, skill, and plugin versions with self-update instructions in SKILL.md - Deduplicate prod hosecloud integrations by corporationId during corps sync-test - Support key and password fallback in enterprise source config for hose credentials - Add unit and integration tests covering deduplication and source credential compatibility
This commit is contained in:
1 parent
0794f319b0
commit
bdeca88354
4 files changed
+296
-21
No files matched your search
@@ -686,6 +686,85 @@ describe("sync-test hosecloud integration auto-sync", () => {
|
||||
expect(parsed.hosecloudSync.skipped).toBe(true);
|
||||
expect(parsed.hosecloudSync.reason).toContain("not hose");
|
||||
});
|
||||
|
||||
test("deduplicates multiple prod integrations for the same corporationId into one test integration", async () => {
|
||||
setupHoseTestEnv();
|
||||
await runCli(["corps", "bind-test", "hose-prod", "hose-test", "--confirm"]);
|
||||
|
||||
let capturedBody: any;
|
||||
// Prod has TWO integrations for the same corporationId (e.g. assisted and fully_automatic)
|
||||
mockHoseSyncRequests({
|
||||
prodHosecloudIntegrations: [
|
||||
{
|
||||
type: "hosecloud",
|
||||
signKey: "prod-assisted-key",
|
||||
outboundName: "辅助审批",
|
||||
mode: "assisted",
|
||||
apiKey: "test-app-key-123",
|
||||
apiSecret: "test-app-secret-456",
|
||||
apiOrigin: "wechat",
|
||||
corporationId: "hose-prod"
|
||||
},
|
||||
{
|
||||
type: "hosecloud",
|
||||
signKey: "prod-auto-key",
|
||||
outboundName: "全自动审批",
|
||||
mode: "fully_automatic",
|
||||
apiKey: "test-app-key-123",
|
||||
apiSecret: "test-app-secret-456",
|
||||
apiOrigin: "wechat",
|
||||
corporationId: "hose-prod"
|
||||
}
|
||||
],
|
||||
onConfigWrite: (isProd, body) => {
|
||||
if (!isProd) capturedBody = body;
|
||||
}
|
||||
});
|
||||
|
||||
const result = await runCli(["corps", "sync-test", "hose-prod", "--yes"]);
|
||||
expect(result.isError).toBe(false);
|
||||
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
// Synced array should contain exactly 1 entry, not 2
|
||||
expect(parsed.hosecloudSync.synced).toHaveLength(1);
|
||||
expect(parsed.hosecloudSync.synced[0].corporationId).toBe("hose-prod");
|
||||
|
||||
const writtenIntegrations = (capturedBody?.integrations ?? []).filter((i: any) => i.type === "hosecloud");
|
||||
expect(writtenIntegrations).toHaveLength(1);
|
||||
expect(writtenIntegrations[0].mode).toBe("assisted");
|
||||
expect(writtenIntegrations[0].apiOrigin).toBe("wechat");
|
||||
});
|
||||
|
||||
test("supports key/password fallback in source config when appKey/appSecurity are omitted", async () => {
|
||||
const { enterprises } = setupHoseTestEnv();
|
||||
// Overwrite hose-prod.json to use key / password instead of appKey / appSecurity
|
||||
const prodCorpWithKeyPassword = JSON.parse(readFileSync(join(enterprises, "hose-prod.json"), "utf-8"));
|
||||
delete prodCorpWithKeyPassword.source.appKey;
|
||||
delete prodCorpWithKeyPassword.source.appSecurity;
|
||||
prodCorpWithKeyPassword.source.key = "fallback-key-789";
|
||||
prodCorpWithKeyPassword.source.password = "fallback-secret-012";
|
||||
writeFileSync(join(enterprises, "hose-prod.json"), JSON.stringify(prodCorpWithKeyPassword, null, 2));
|
||||
|
||||
await runCli(["corps", "bind-test", "hose-prod", "hose-test", "--confirm"]);
|
||||
|
||||
let capturedBody: any;
|
||||
mockHoseSyncRequests({
|
||||
onConfigWrite: (isProd, body) => {
|
||||
if (!isProd) capturedBody = body;
|
||||
}
|
||||
});
|
||||
|
||||
const result = await runCli(["corps", "sync-test", "hose-prod", "--yes"]);
|
||||
expect(result.isError).toBe(false);
|
||||
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
expect(parsed.hosecloudSync.skipped).toBe(false);
|
||||
expect(parsed.hosecloudSync.synced).toHaveLength(1);
|
||||
|
||||
const writtenIntegration = capturedBody?.integrations?.find((i: any) => i.type === "hosecloud");
|
||||
expect(writtenIntegration?.apiKey).toBe("fallback-key-789");
|
||||
expect(writtenIntegration?.apiSecret).toBe("fallback-secret-012");
|
||||
});
|
||||
});
|
||||
|
||||
describe("corps list & current", () => {
|
||||
|
||||
Reference in new issue
Block a user