





















@@ -31,7 +31,6 @@ import {
3131} from "../shared/credential-lease.runtime.js";
3232import {
3333appendQaLiveLaneIssue as appendLiveLaneIssue,
34-buildQaLiveLaneArtifactsError as buildLiveLaneArtifactsError,
3534redactQaLiveLaneDetails,
3635redactQaLiveLaneIssues,
3736} from "../shared/live-artifacts.js";
@@ -2950,6 +2949,43 @@ function appendPreScenarioFailureResults(params: {
29502949}
29512950}
295229512952+async function hasWhatsAppGatewayDebugArtifacts(gatewayDebugDirPath: string) {
2953+try {
2954+const entries = await fs.readdir(gatewayDebugDirPath);
2955+return entries.length > 0;
2956+} catch (error) {
2957+if ((error as NodeJS.ErrnoException).code === "ENOENT") {
2958+return false;
2959+}
2960+throw error;
2961+}
2962+}
2963+2964+async function buildPublishedWhatsAppQaRunView(params: {
2965+cleanupIssues: string[];
2966+gatewayDebugDirPath: string;
2967+preservedGatewayDebugArtifacts: boolean;
2968+redactMetadata: boolean;
2969+scenarioResults: WhatsAppQaScenarioResult[];
2970+}) {
2971+const publishedCleanupIssues = params.redactMetadata
2972+ ? redactQaLiveLaneIssues(params.cleanupIssues)
2973+ : params.cleanupIssues;
2974+const publishedScenarioResults = params.redactMetadata
2975+ ? redactWhatsAppQaScenarioResults(params.scenarioResults)
2976+ : params.scenarioResults;
2977+const gatewayDebugDirPath =
2978+params.preservedGatewayDebugArtifacts &&
2979+(await hasWhatsAppGatewayDebugArtifacts(params.gatewayDebugDirPath))
2980+ ? params.gatewayDebugDirPath
2981+ : undefined;
2982+return {
2983+cleanupIssues: publishedCleanupIssues,
2984+ gatewayDebugDirPath,
2985+scenarioResults: publishedScenarioResults,
2986+};
2987+}
2988+29532989function formatWhatsAppScenarioProgressLine(params: {
29542990details?: string;
29552991index: number;
@@ -3171,17 +3207,7 @@ export async function runWhatsAppQaLive(params: {
31713207}
31723208}
31733209} catch (error) {
3174-cleanupIssues.push(
3175-buildLiveLaneArtifactsError({
3176-heading: "WhatsApp QA failed before scenario completion.",
3177-details: [formatErrorMessage(error)],
3178-artifacts: {
3179-gatewayDebug: gatewayDebugDirPath,
3180-},
3181-}),
3182-);
3183-preservedGatewayDebugArtifacts = true;
3184-await fs.mkdir(gatewayDebugDirPath, { recursive: true }).catch(() => {});
3210+appendLiveLaneIssue(cleanupIssues, "WhatsApp QA failed before scenario completion", error);
31853211appendPreScenarioFailureResults({
31863212details: formatErrorMessage(error),
31873213 scenarioResults,
@@ -3221,19 +3247,20 @@ export async function runWhatsAppQaLive(params: {
32213247const summaryPath = path.join(outputDir, QA_EVIDENCE_FILENAME);
32223248const observedMessagesPath = path.join(outputDir, "whatsapp-qa-observed-messages.json");
32233249const credentialFingerprint = fingerprintQaCredentialId(credentialLease?.credentialId);
3224-const publishedCleanupIssues = redactPublicMetadata
3225- ? redactQaLiveLaneIssues(cleanupIssues)
3226- : cleanupIssues;
3227-const publishedScenarioResults = redactPublicMetadata
3228- ? redactWhatsAppQaScenarioResults(scenarioResults)
3229- : scenarioResults;
3250+const publishedRunView = await buildPublishedWhatsAppQaRunView({
3251+ cleanupIssues,
3252+ gatewayDebugDirPath,
3253+ preservedGatewayDebugArtifacts,
3254+redactMetadata: redactPublicMetadata,
3255+ scenarioResults,
3256+});
32303257const evidence = buildLiveTransportEvidenceSummary({
32313258artifactPaths: [
32323259{ kind: "summary", path: path.basename(summaryPath) },
32333260{ kind: "report", path: path.basename(reportPath) },
32343261{ kind: "transport-observations", path: path.basename(observedMessagesPath) },
32353262],
3236-checks: publishedScenarioResults.map(({ standardId, ...check }) => ({
3263+checks: publishedRunView.scenarioResults.map(({ standardId, ...check }) => ({
32373264 ...check,
32383265coverageIds: standardId ? [`channels.whatsapp.${standardId}`] : undefined,
32393266})),
@@ -3259,13 +3286,13 @@ export async function runWhatsAppQaLive(params: {
32593286await fs.writeFile(
32603287reportPath,
32613288`${renderWhatsAppQaMarkdown({
3262- cleanupIssues: publishedCleanupIssues,
3289+ cleanupIssues: publishedRunView.cleanupIssues,
32633290 credentialFingerprint,
32643291 credentialSource: credentialLease?.source ?? requestedCredentialSource,
32653292 finishedAt,
3266- gatewayDebugDirPath: preservedGatewayDebugArtifacts ? gatewayDebugDirPath : undefined,
3293+ gatewayDebugDirPath: publishedRunView.gatewayDebugDirPath,
32673294 redactMetadata: redactPublicMetadata,
3268- scenarios: publishedScenarioResults,
3295+ scenarios: publishedRunView.scenarioResults,
32693296 startedAt,
32703297 sutPhoneE164: runtimeEnv?.sutPhoneE164,
32713298 })}\n`,
@@ -3275,14 +3302,15 @@ export async function runWhatsAppQaLive(params: {
32753302 reportPath,
32763303 summaryPath,
32773304 observedMessagesPath,
3278-gatewayDebugDirPath: preservedGatewayDebugArtifacts ? gatewayDebugDirPath : undefined,
3305+gatewayDebugDirPath: publishedRunView.gatewayDebugDirPath,
32793306scenarios: scenarioResults,
32803307};
32813308}
3282330932833310export const testing = {
32843311 assertSafeArchiveEntries,
32853312 appendPreScenarioFailureResults,
3313+ buildPublishedWhatsAppQaRunView,
32863314 buildWhatsAppQaConfig,
32873315 callWhatsAppGatewayMessageAction,
32883316 callWhatsAppGatewayPoll,
@@ -3296,6 +3324,7 @@ export const testing = {
32963324 formatWhatsAppScenarioProgressLine,
32973325fingerprintWhatsAppCredentialId: fingerprintQaCredentialId,
32983326 formatWhatsAppScenarioWaitDiagnostics,
3327+ hasWhatsAppGatewayDebugArtifacts,
32993328 isTransientWhatsAppQaDriverError,
33003329 matchesWhatsAppApprovalResolvedText,
33013330 parseWhatsAppQaCredentialPayload,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。