fix: harden workflow analysis diagnostics
This commit is contained in:
1 parent
6ce83dd8a7
commit
88a0d97974
5 files changed
+83
-19
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { isClientGoodOpened } from "./analyze.js";
|
||||
|
||||
describe("workflow analyze enterprise application status", () => {
|
||||
it("uses the enterprise opening status and ignores marketplace online status", () => {
|
||||
expect(isClientGoodOpened({ status: "OPENED", onLineStatus: "OFFLINE" })).toBe(true);
|
||||
expect(isClientGoodOpened({ status: "EXPIRE", onLineStatus: "ONLINE" })).toBe(false);
|
||||
expect(isClientGoodOpened({ status: "CLOSED", onLineStatus: "ONLINE" })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,10 @@ import { printJson, printTable, printKeyValue } from "../../printer.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
import { createWorkflowDetailClient } from "./shared.js";
|
||||
|
||||
export function isClientGoodOpened(item: { status?: string | null; onLineStatus?: string | null }): boolean {
|
||||
return item.status?.toUpperCase() === "OPENED";
|
||||
}
|
||||
|
||||
export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
|
||||
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipelineId"]);
|
||||
if (!pipelineId) return { stdout: "", stderr: "用法: hose-use workflow analyze <pipelineId>\n", exitCode: 1 };
|
||||
@@ -44,7 +48,7 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
|
||||
const goods = await fetchClientGoods(runtime.selectedCorp!, { isAll: true });
|
||||
const codes = new Set<string>();
|
||||
for (const item of goods) {
|
||||
const isOpened = item.status?.toUpperCase() === "OPENED" || item.onLineStatus?.toUpperCase() === "ONLINE";
|
||||
const isOpened = isClientGoodOpened(item);
|
||||
if (isOpened && Array.isArray(item.powers)) {
|
||||
for (const power of item.powers) {
|
||||
if (typeof power === "string") {
|
||||
|
||||
Reference in new issue
Block a user