digital-ai-testing-mcp 1.2.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -56
- package/dist/api/access-level.d.ts +46 -0
- package/dist/api/access-level.d.ts.map +1 -0
- package/dist/api/access-level.js +183 -0
- package/dist/api/access-level.js.map +1 -0
- package/dist/api/agents.js +1 -1
- package/dist/api/agents.js.map +1 -1
- package/dist/api/browser-inspection.d.ts.map +1 -1
- package/dist/api/browser-inspection.js +18 -17
- package/dist/api/browser-inspection.js.map +1 -1
- package/dist/api/client.d.ts +14 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +60 -43
- package/dist/api/client.js.map +1 -1
- package/dist/api/device-groups.js +1 -1
- package/dist/api/device-groups.js.map +1 -1
- package/dist/api/license.js +1 -1
- package/dist/api/license.js.map +1 -1
- package/dist/api/nv-servers.js +1 -1
- package/dist/api/nv-servers.js.map +1 -1
- package/dist/api/projects.d.ts +16 -3
- package/dist/api/projects.d.ts.map +1 -1
- package/dist/api/projects.js +60 -18
- package/dist/api/projects.js.map +1 -1
- package/dist/api/regions.js +1 -1
- package/dist/api/regions.js.map +1 -1
- package/dist/api/reporter-projects.d.ts.map +1 -1
- package/dist/api/reporter-projects.js +2 -1
- package/dist/api/reporter-projects.js.map +1 -1
- package/dist/api/reporting.d.ts +91 -0
- package/dist/api/reporting.d.ts.map +1 -1
- package/dist/api/reporting.js +220 -22
- package/dist/api/reporting.js.map +1 -1
- package/dist/api/sessions.js +1 -1
- package/dist/api/sessions.js.map +1 -1
- package/dist/api/test-orchestrator.d.ts +59 -0
- package/dist/api/test-orchestrator.d.ts.map +1 -0
- package/dist/api/test-orchestrator.js +126 -0
- package/dist/api/test-orchestrator.js.map +1 -0
- package/dist/api/test-runs.d.ts +80 -0
- package/dist/api/test-runs.d.ts.map +1 -0
- package/dist/api/test-runs.js +209 -0
- package/dist/api/test-runs.js.map +1 -0
- package/dist/api/test-views.d.ts.map +1 -1
- package/dist/api/test-views.js +5 -1
- package/dist/api/test-views.js.map +1 -1
- package/dist/api/transactions.d.ts +6 -0
- package/dist/api/transactions.d.ts.map +1 -1
- package/dist/api/transactions.js +19 -3
- package/dist/api/transactions.js.map +1 -1
- package/dist/api/usage-reports.d.ts.map +1 -1
- package/dist/api/usage-reports.js +3 -3
- package/dist/api/usage-reports.js.map +1 -1
- package/dist/api/webdriver.d.ts +39 -1
- package/dist/api/webdriver.d.ts.map +1 -1
- package/dist/api/webdriver.js +177 -71
- package/dist/api/webdriver.js.map +1 -1
- package/dist/index.js +82 -33
- package/dist/index.js.map +1 -1
- package/dist/tools/agent-tools.js +2 -2
- package/dist/tools/agent-tools.js.map +1 -1
- package/dist/tools/application-tools.d.ts.map +1 -1
- package/dist/tools/application-tools.js +17 -10
- package/dist/tools/application-tools.js.map +1 -1
- package/dist/tools/boilerplate-tools.d.ts +3 -0
- package/dist/tools/boilerplate-tools.d.ts.map +1 -1
- package/dist/tools/boilerplate-tools.js +302 -21
- package/dist/tools/boilerplate-tools.js.map +1 -1
- package/dist/tools/browser-tools.d.ts.map +1 -1
- package/dist/tools/browser-tools.js +8 -5
- package/dist/tools/browser-tools.js.map +1 -1
- package/dist/tools/debug-tools.d.ts.map +1 -1
- package/dist/tools/debug-tools.js +6 -3
- package/dist/tools/debug-tools.js.map +1 -1
- package/dist/tools/device-group-tools.js +5 -5
- package/dist/tools/device-group-tools.js.map +1 -1
- package/dist/tools/device-tools.d.ts.map +1 -1
- package/dist/tools/device-tools.js +5 -4
- package/dist/tools/device-tools.js.map +1 -1
- package/dist/tools/health-tools.d.ts.map +1 -1
- package/dist/tools/health-tools.js +6 -5
- package/dist/tools/health-tools.js.map +1 -1
- package/dist/tools/inspection-tools.d.ts.map +1 -1
- package/dist/tools/inspection-tools.js +122 -22
- package/dist/tools/inspection-tools.js.map +1 -1
- package/dist/tools/meta-tools.d.ts +4 -1
- package/dist/tools/meta-tools.d.ts.map +1 -1
- package/dist/tools/meta-tools.js +87 -58
- package/dist/tools/meta-tools.js.map +1 -1
- package/dist/tools/performance-tools.d.ts.map +1 -1
- package/dist/tools/performance-tools.js +2 -8
- package/dist/tools/performance-tools.js.map +1 -1
- package/dist/tools/project-tools.d.ts.map +1 -1
- package/dist/tools/project-tools.js +38 -19
- package/dist/tools/project-tools.js.map +1 -1
- package/dist/tools/provisioning-profile-tools.d.ts.map +1 -1
- package/dist/tools/provisioning-profile-tools.js +5 -4
- package/dist/tools/provisioning-profile-tools.js.map +1 -1
- package/dist/tools/remediation-tools.d.ts +7 -0
- package/dist/tools/remediation-tools.d.ts.map +1 -0
- package/dist/tools/remediation-tools.js +50 -0
- package/dist/tools/remediation-tools.js.map +1 -0
- package/dist/tools/reporting-tools.d.ts.map +1 -1
- package/dist/tools/reporting-tools.js +393 -147
- package/dist/tools/reporting-tools.js.map +1 -1
- package/dist/tools/repository-tools.d.ts.map +1 -1
- package/dist/tools/repository-tools.js +5 -4
- package/dist/tools/repository-tools.js.map +1 -1
- package/dist/tools/reservation-tools.js +2 -2
- package/dist/tools/reservation-tools.js.map +1 -1
- package/dist/tools/resources.js +2 -2
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/test-run-tools.d.ts +3 -0
- package/dist/tools/test-run-tools.d.ts.map +1 -0
- package/dist/tools/test-run-tools.js +284 -0
- package/dist/tools/test-run-tools.js.map +1 -0
- package/dist/tools/test-view-tools.d.ts.map +1 -1
- package/dist/tools/test-view-tools.js +11 -11
- package/dist/tools/test-view-tools.js.map +1 -1
- package/dist/tools/toolset-tools.d.ts +8 -0
- package/dist/tools/toolset-tools.d.ts.map +1 -0
- package/dist/tools/toolset-tools.js +40 -0
- package/dist/tools/toolset-tools.js.map +1 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -1
- package/dist/tools/transaction-tools.js +17 -7
- package/dist/tools/transaction-tools.js.map +1 -1
- package/dist/tools/usage-report-tools.d.ts.map +1 -1
- package/dist/tools/usage-report-tools.js +43 -15
- package/dist/tools/usage-report-tools.js.map +1 -1
- package/dist/tools/user-tools.js +2 -2
- package/dist/tools/user-tools.js.map +1 -1
- package/dist/tools/web-inspection-tools.d.ts.map +1 -1
- package/dist/tools/web-inspection-tools.js +45 -33
- package/dist/tools/web-inspection-tools.js.map +1 -1
- package/dist/tools/workflow-tools.js +1 -1
- package/dist/types/digital-ai.d.ts +19 -1
- package/dist/types/digital-ai.d.ts.map +1 -1
- package/dist/utils/access-level.d.ts +39 -0
- package/dist/utils/access-level.d.ts.map +1 -0
- package/dist/utils/access-level.js +111 -0
- package/dist/utils/access-level.js.map +1 -0
- package/dist/utils/browser-name.d.ts +2 -0
- package/dist/utils/browser-name.d.ts.map +1 -0
- package/dist/utils/browser-name.js +19 -0
- package/dist/utils/browser-name.js.map +1 -0
- package/dist/utils/command-payload.d.ts +19 -0
- package/dist/utils/command-payload.d.ts.map +1 -0
- package/dist/utils/command-payload.js +13 -0
- package/dist/utils/command-payload.js.map +1 -0
- package/dist/utils/csv.d.ts +6 -0
- package/dist/utils/csv.d.ts.map +1 -1
- package/dist/utils/csv.js +28 -2
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/download-command.d.ts.map +1 -1
- package/dist/utils/download-command.js +5 -4
- package/dist/utils/download-command.js.map +1 -1
- package/dist/utils/locality.d.ts +7 -0
- package/dist/utils/locality.d.ts.map +1 -1
- package/dist/utils/locality.js +19 -0
- package/dist/utils/locality.js.map +1 -1
- package/dist/utils/maestro-flow.d.ts +38 -0
- package/dist/utils/maestro-flow.d.ts.map +1 -0
- package/dist/utils/maestro-flow.js +114 -0
- package/dist/utils/maestro-flow.js.map +1 -0
- package/dist/utils/metric-semantics.d.ts +22 -0
- package/dist/utils/metric-semantics.d.ts.map +1 -0
- package/dist/utils/metric-semantics.js +24 -0
- package/dist/utils/metric-semantics.js.map +1 -0
- package/dist/utils/pagination.d.ts +11 -0
- package/dist/utils/pagination.d.ts.map +1 -1
- package/dist/utils/pagination.js +16 -0
- package/dist/utils/pagination.js.map +1 -1
- package/dist/utils/path-guard.js +1 -1
- package/dist/utils/path-guard.js.map +1 -1
- package/dist/utils/profile-loader.d.ts +4 -2
- package/dist/utils/profile-loader.d.ts.map +1 -1
- package/dist/utils/profile-loader.js +5 -4
- package/dist/utils/profile-loader.js.map +1 -1
- package/dist/utils/remediation.d.ts +113 -0
- package/dist/utils/remediation.d.ts.map +1 -0
- package/dist/utils/remediation.js +392 -0
- package/dist/utils/remediation.js.map +1 -0
- package/dist/utils/report-ref.d.ts +23 -0
- package/dist/utils/report-ref.d.ts.map +1 -0
- package/dist/utils/report-ref.js +31 -0
- package/dist/utils/report-ref.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +2 -1
- package/dist/utils/response-formatter.d.ts.map +1 -1
- package/dist/utils/response-formatter.js +32 -21
- package/dist/utils/response-formatter.js.map +1 -1
- package/dist/utils/test-orchestrator.d.ts +102 -0
- package/dist/utils/test-orchestrator.d.ts.map +1 -0
- package/dist/utils/test-orchestrator.js +236 -0
- package/dist/utils/test-orchestrator.js.map +1 -0
- package/dist/utils/test-status.d.ts +48 -0
- package/dist/utils/test-status.d.ts.map +1 -0
- package/dist/utils/test-status.js +92 -0
- package/dist/utils/test-status.js.map +1 -0
- package/dist/utils/tool-catalog.d.ts +6 -0
- package/dist/utils/tool-catalog.d.ts.map +1 -0
- package/dist/utils/tool-catalog.js +15 -0
- package/dist/utils/tool-catalog.js.map +1 -0
- package/dist/utils/toolsets.d.ts +79 -0
- package/dist/utils/toolsets.d.ts.map +1 -0
- package/dist/utils/toolsets.js +156 -0
- package/dist/utils/toolsets.js.map +1 -0
- package/dist/utils/upload-command.d.ts.map +1 -1
- package/dist/utils/upload-command.js +5 -4
- package/dist/utils/upload-command.js.map +1 -1
- package/dist/utils/usage-report-guard.d.ts +7 -0
- package/dist/utils/usage-report-guard.d.ts.map +1 -1
- package/dist/utils/usage-report-guard.js +18 -1
- package/dist/utils/usage-report-guard.js.map +1 -1
- package/dist/utils/usage-report-summary.d.ts +12 -0
- package/dist/utils/usage-report-summary.d.ts.map +1 -1
- package/dist/utils/usage-report-summary.js +25 -6
- package/dist/utils/usage-report-summary.js.map +1 -1
- package/package.json +40 -4
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle +6 -1
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +6 -1
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +2 -2
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +2 -2
- package/resources/boilerplate/Android-Native/java TestNG/gradle +1 -1
- package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +1 -1
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle +6 -1
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +6 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle +1 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +1 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +2 -2
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +2 -2
- package/resources/test-orchestrator/agent.json +19 -0
|
@@ -1,59 +1,160 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getTestById, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
2
|
+
import { getTestById, getTestByUuid, shareTestReport, getRootCauseAnalysis, RCA_MAX_ATTEMPTS, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, downloadTestVideo, getTestVideoInfo, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
3
3
|
import { serverFsDownloadNotice, serverFsOutputParam, commandGeneratorNotice, localPlatformParamNotice } from '../utils/locality.js';
|
|
4
|
-
import {
|
|
4
|
+
import { checkDeleteAllowed, serverSortAvailable } from '../api/access-level.js';
|
|
5
5
|
import { checkDestructiveGuard } from '../utils/destructive-guard.js';
|
|
6
6
|
import { validateOutputPath } from '../utils/path-guard.js';
|
|
7
7
|
import { buildDownloadCommand } from '../utils/download-command.js';
|
|
8
8
|
import { formatTestReport, formatTestReportList, formatFailureSummary, formatTestAttachments, formatGroupedTestReports, formatProjectTestSummary, } from '../utils/response-formatter.js';
|
|
9
9
|
import { outputFormatParam, respond } from '../utils/output-format.js';
|
|
10
|
+
import { commandPayload } from '../utils/command-payload.js';
|
|
11
|
+
import { parseReportRef } from '../utils/report-ref.js';
|
|
12
|
+
import { countsFromPivotRow, tallyStatuses, passRate, statusOutcome, unknownStatusCount, PASS_RATE_BASIS } from '../utils/test-status.js';
|
|
10
13
|
export function registerReportingTools(server) {
|
|
11
14
|
// ─── get_test_report ───────────────────────────────────────────────────────
|
|
12
|
-
server.tool('get_test_report', 'Retrieve a full test execution report by
|
|
13
|
-
'Provide
|
|
14
|
-
'
|
|
15
|
-
'NOTE: Step-level detail is not available
|
|
15
|
+
server.tool('get_test_report', 'Retrieve a full test execution report by UUID, numeric test ID, or the report URL printed in tearDown (digitalai:reportUrl — e.g. .../reporter/video-report/<uuid>). ' +
|
|
16
|
+
'Provide ONE of uuid, testId or reportUrl. PREFER uuid (or the report URL): UUIDs are global, while numeric test IDs are only unique per project and can resolve to a different test in another project. ' +
|
|
17
|
+
'uuid and test_id are both returned by list_test_reports and find_latest_test_for_name. ' +
|
|
18
|
+
'NOTE: Step-level detail is not available on this endpoint — the backend API does not support it here. ' +
|
|
16
19
|
'To get steps, use get_test_by_report_id with the report_api_id from a live session. ' +
|
|
17
20
|
'For failure diagnosis use the cause/errorCategory/errorDetail fields in this response, or get_test_log for the full Appium log.', {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
uuid: z.string().optional().describe('The test execution UUID (uuid field from list results). Preferred — globally unique.'),
|
|
22
|
+
testId: z.number().int().optional().describe('The numeric test ID (test_id field from list results, e.g. 377918). Unique only within a project — prefer uuid.'),
|
|
23
|
+
reportUrl: z.string().optional().describe('The report URL printed by tearDown (digitalai:reportUrl), e.g. .../reporter/video-report/<uuid> or an older ...?test_id=<n> link. The identifier is extracted automatically.'),
|
|
20
24
|
outputFormat: outputFormatParam,
|
|
21
|
-
}, async ({ testId, reportUrl, outputFormat }) => {
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
}, async ({ uuid, testId, reportUrl, outputFormat }) => {
|
|
26
|
+
const given = [uuid, testId, reportUrl].filter((v) => v != null && v !== '').length;
|
|
27
|
+
if (given === 0) {
|
|
28
|
+
return { content: [{ type: 'text', text: 'Provide one of uuid, testId or reportUrl.' }], isError: true };
|
|
29
|
+
}
|
|
30
|
+
if (given > 1) {
|
|
31
|
+
return { content: [{ type: 'text', text: 'Provide only ONE of uuid, testId or reportUrl — they could point at different reports.' }], isError: true };
|
|
32
|
+
}
|
|
33
|
+
const ref = parseReportRef(uuid ?? reportUrl ?? testId);
|
|
34
|
+
if (!ref) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: `Could not find a report UUID or numeric test ID in: ${uuid ?? reportUrl}. Use list_test_reports or find_latest_test_for_name to look the test up.` }],
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const report = ref.kind === 'uuid' ? await getTestByUuid(ref.uuid) : await getTestById(ref.testId);
|
|
42
|
+
return respond(outputFormat, report, formatTestReport(report));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// ─── share_test_report ─────────────────────────────────────────────────────
|
|
49
|
+
server.tool('share_test_report', 'Create a PUBLIC link to a test report that anyone can open WITHOUT logging in — the report page, its data (including ' +
|
|
50
|
+
'key-value pairs/capabilities) and its video. Links expire 14 days after first creation; sharing the same report again ' +
|
|
51
|
+
'returns the same link and does NOT extend it. There is no revoke: the only way to disable a link early is to delete the ' +
|
|
52
|
+
'report (delete_test_reports). Requires confirmPublicShare: true — without it, this returns a preview of what would be ' +
|
|
53
|
+
'exposed and shares nothing. Only share when the user explicitly asked for a public/shareable link. ' +
|
|
54
|
+
'Fails if public sharing is disabled for the report\'s project.', {
|
|
55
|
+
uuid: z.string().optional().describe('Test execution UUID (uuid field from list_test_reports / get_test_report).'),
|
|
56
|
+
reportUrl: z.string().optional().describe('The report URL (e.g. .../reporter/video-report/<uuid>). Must contain the UUID.'),
|
|
57
|
+
confirmPublicShare: z
|
|
58
|
+
.boolean()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Must be true to create the public link. Omit to preview what would be shared.'),
|
|
61
|
+
outputFormat: outputFormatParam,
|
|
62
|
+
}, async ({ uuid, reportUrl, confirmPublicShare, outputFormat }) => {
|
|
63
|
+
if ((uuid ? 1 : 0) + (reportUrl ? 1 : 0) !== 1) {
|
|
64
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid or reportUrl.' }], isError: true };
|
|
65
|
+
}
|
|
66
|
+
const ref = parseReportRef(uuid ?? reportUrl);
|
|
67
|
+
if (ref?.kind !== 'uuid') {
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: 'text', text: 'Sharing needs the report UUID (numeric test IDs are not accepted). Get it from list_test_reports or get_test_report (uuid field), or pass the .../video-report/<uuid> URL.' }],
|
|
70
|
+
isError: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
// Fetch first: confirms the report exists and is visible to this credential, and shows what would be exposed.
|
|
75
|
+
const report = await getTestByUuid(ref.uuid);
|
|
76
|
+
const what = `"${report.name}" (${report.status}, ${report.start_time}${report.projectName ? `, project ${report.projectName}` : ''})`;
|
|
77
|
+
if (report.sharingEnabled === false) {
|
|
30
78
|
return {
|
|
31
|
-
content: [{
|
|
32
|
-
type: 'text',
|
|
33
|
-
text: `The report URL contains a UUID, not a numeric test ID. The Digital.ai reporter API does not support UUID-based lookup.\n\n` +
|
|
34
|
-
`Use the numeric test ID from the "Report Test ID" line printed in tearDown (digitalai:reportTestId capability):\n` +
|
|
35
|
-
` get_test_report(testId: <the number from "Report Test ID">)\n\n` +
|
|
36
|
-
`Or find it via: list_test_reports or find_latest_test_for_name.`,
|
|
37
|
-
}],
|
|
79
|
+
content: [{ type: 'text', text: `Public sharing is disabled for ${what}'s project. A project admin must enable report sharing in the Reporter project settings first.` }],
|
|
38
80
|
isError: true,
|
|
39
81
|
};
|
|
40
82
|
}
|
|
41
|
-
|
|
83
|
+
if (confirmPublicShare !== true) {
|
|
42
84
|
return {
|
|
43
|
-
content: [{
|
|
44
|
-
|
|
85
|
+
content: [{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: `⚠️ Preview — nothing has been shared.\n\n` +
|
|
88
|
+
`This would create a PUBLIC link to ${what}. Anyone with the link can, without logging in:\n` +
|
|
89
|
+
` • open the report page and its video\n` +
|
|
90
|
+
` • read the report data, including all key-value pairs / capabilities\n` +
|
|
91
|
+
`The link lasts 14 days and cannot be revoked except by deleting the report.\n\n` +
|
|
92
|
+
`To proceed, call share_test_report again with confirmPublicShare: true.`,
|
|
93
|
+
}],
|
|
45
94
|
};
|
|
46
95
|
}
|
|
96
|
+
const share = await shareTestReport(ref.uuid);
|
|
97
|
+
const structured = { uuid: ref.uuid, testId: report.test_id, name: report.name, publicUrl: share.publicUrl, expires: share.expires };
|
|
98
|
+
const human = `🔗 Public link for ${what}:\n${share.publicUrl}\n\n` +
|
|
99
|
+
`Expires: ${share.expires} (14 days after it was first shared — re-sharing does not extend it).\n` +
|
|
100
|
+
`Anyone with this link can view the report, its data and its video without logging in. ` +
|
|
101
|
+
`To disable it early, delete the report (delete_test_reports).`;
|
|
102
|
+
return respond(outputFormat, structured, human);
|
|
47
103
|
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
104
|
+
catch (e) {
|
|
105
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
// ─── get_root_cause_analysis ───────────────────────────────────────────────
|
|
109
|
+
server.tool('get_root_cause_analysis', 'Read the platform\'s AI Root Cause Analysis for a failed test report: the hypothesis, the supporting evidence ' +
|
|
110
|
+
'(log lines with source, time and findings), the analysis status and attempts used, plus the reporter\'s own error ' +
|
|
111
|
+
'classification (errorCategory / errorClassification / cause). Read-only — it never starts an analysis. ' +
|
|
112
|
+
'Analyses are started from the video report in the Reporter UI; they cover Appium Server tests only and allow ' +
|
|
113
|
+
'3 failed attempts per test. ineligibleReason explains when an analysis cannot be run. ' +
|
|
114
|
+
'To find analysed reports: list_test_reports with filter rca.status = COMPLETED.', {
|
|
115
|
+
uuid: z.string().optional().describe('Test execution UUID. Preferred.'),
|
|
116
|
+
reportUrl: z.string().optional().describe('Report URL (e.g. .../reporter/video-report/<uuid>).'),
|
|
117
|
+
testId: z.number().int().optional().describe('Numeric test id — unique only within a project; prefer uuid.'),
|
|
118
|
+
outputFormat: outputFormatParam,
|
|
119
|
+
}, async ({ uuid, reportUrl, testId, outputFormat }) => {
|
|
120
|
+
if ([uuid, reportUrl, testId].filter((v) => v != null && v !== '').length !== 1) {
|
|
121
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid, reportUrl or testId.' }], isError: true };
|
|
53
122
|
}
|
|
54
123
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
124
|
+
const ref = parseReportRef(uuid ?? reportUrl ?? testId);
|
|
125
|
+
if (!ref)
|
|
126
|
+
return { content: [{ type: 'text', text: `Could not find a report UUID or test id in: ${uuid ?? reportUrl}.` }], isError: true };
|
|
127
|
+
const a = await getRootCauseAnalysis(ref);
|
|
128
|
+
const lines = [
|
|
129
|
+
`🔎 Root Cause Analysis — "${a.name}" (${a.testStatus}${a.framework ? `, ${a.framework}` : ''}${a.projectName ? `, project ${a.projectName}` : ''})`,
|
|
130
|
+
` Status: ${a.status}` +
|
|
131
|
+
(a.attemptCount != null ? ` · attempts used ${a.attemptCount}/${RCA_MAX_ATTEMPTS}` : '') +
|
|
132
|
+
(a.serviceEnabled === false ? ' · RCA disabled on this cloud' : ''),
|
|
133
|
+
];
|
|
134
|
+
if (a.hypothesis)
|
|
135
|
+
lines.push('', ` Hypothesis: ${a.hypothesis}`);
|
|
136
|
+
if (a.evidence.length) {
|
|
137
|
+
lines.push('', ' Evidence:');
|
|
138
|
+
for (const e of a.evidence) {
|
|
139
|
+
lines.push(` • ${[e.source, e.time].filter(Boolean).join(' @ ')}`);
|
|
140
|
+
if (e.log)
|
|
141
|
+
lines.push(` log: ${e.log}`);
|
|
142
|
+
if (e.findings)
|
|
143
|
+
lines.push(` → ${e.findings}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!a.hypothesis && a.status !== 'completed') {
|
|
147
|
+
lines.push('', a.status === 'none'
|
|
148
|
+
? ' No analysis has been run for this report.'
|
|
149
|
+
: ` No result: the last analysis attempt ended "${a.status}".`);
|
|
150
|
+
}
|
|
151
|
+
const c = a.classification;
|
|
152
|
+
if (c.errorCategory || c.errorClassification || c.cause) {
|
|
153
|
+
lines.push('', ` Reporter classification: ${[c.errorCategory, c.errorClassification].filter(Boolean).join(' / ')}${c.cause ? ` — ${c.cause}` : ''}`);
|
|
154
|
+
}
|
|
155
|
+
if (a.ineligibleReason)
|
|
156
|
+
lines.push('', ` ℹ️ ${a.ineligibleReason}`);
|
|
157
|
+
return respond(outputFormat, a, lines.join('\n'));
|
|
57
158
|
}
|
|
58
159
|
catch (e) {
|
|
59
160
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
@@ -80,7 +181,7 @@ export function registerReportingTools(server) {
|
|
|
80
181
|
}
|
|
81
182
|
if (UUID_RE.test(reportApiId)) {
|
|
82
183
|
return {
|
|
83
|
-
content: [{ type: 'text', text: `Error: "${reportApiId}" is a test UUID, not a report_api_id.
|
|
184
|
+
content: [{ type: 'text', text: `Error: "${reportApiId}" is a test UUID, not a report_api_id. Use get_test_report(uuid: "${reportApiId}") instead. The report_api_id is a different identifier returned only when starting a manual or web-control session.` }],
|
|
84
185
|
isError: true,
|
|
85
186
|
};
|
|
86
187
|
}
|
|
@@ -133,6 +234,7 @@ export function registerReportingTools(server) {
|
|
|
133
234
|
'"user" (email, exact match — for "my reports" use the email from get_my_account_info), ' +
|
|
134
235
|
'"has_attachment" ("Y"/"N"), ' +
|
|
135
236
|
'"success" (boolean true/false), ' +
|
|
237
|
+
'"accessibility_report" (JSON boolean true/false, NOT the string "true" — that 400s; true = runs with an Axe accessibility scan), ' +
|
|
136
238
|
'"test_id" (number), ' +
|
|
137
239
|
'"project_id" (number), ' +
|
|
138
240
|
'"device.os" ("Android"/"iOS" — case-sensitive), ' +
|
|
@@ -144,7 +246,7 @@ export function registerReportingTools(server) {
|
|
|
144
246
|
operator: z.string().describe('Comparison operator. Supported: "=" (equality), ">" ">=" "<" "<=" (numeric/date), "contains" (substring for name). ' +
|
|
145
247
|
'CSRF-blocked operators: "!=", "like", "startsWith", "in". ' +
|
|
146
248
|
'Note: "success" must use boolean value with "="; string "true" is CSRF-blocked.'),
|
|
147
|
-
value: z.union([z.string(), z.number(), z.boolean()]).describe('Filter value. Use boolean true/false for "success", numbers for numeric fields, strings for text fields.'),
|
|
249
|
+
value: z.union([z.string(), z.number(), z.boolean()]).describe('Filter value. Use boolean true/false for "success" and "accessibility_report", numbers for numeric fields, strings for text fields.'),
|
|
148
250
|
}))
|
|
149
251
|
.optional()
|
|
150
252
|
.describe('Server-side filters. Multiple filters are ANDed. ' +
|
|
@@ -180,9 +282,8 @@ export function registerReportingTools(server) {
|
|
|
180
282
|
const targetLimit = limit ?? 50;
|
|
181
283
|
if (startDate || endDate) {
|
|
182
284
|
// Client-side date filtering — server-side start_time filter is CSRF-blocked for all key types.
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
const isSortedFetch = getActiveKeyType() === 'jwt';
|
|
285
|
+
// Fetch sorted descending so we can stop as soon as we pass the startDate cutoff. If the platform
|
|
286
|
+
// refuses sort for this credential the response says so (sortApplied=false) and we scan every page.
|
|
186
287
|
const startTs = startDate ? new Date(startDate).getTime() : 0;
|
|
187
288
|
const endTs = endDate ? new Date(endDate).getTime() : Date.now();
|
|
188
289
|
// When a total is requested, keep scanning past targetLimit to count
|
|
@@ -196,19 +297,30 @@ export function registerReportingTools(server) {
|
|
|
196
297
|
let fetchPage = 1;
|
|
197
298
|
let done = false;
|
|
198
299
|
while (!done && (wantTotal || matched.length < targetLimit)) {
|
|
300
|
+
const wantSort = serverSortAvailable();
|
|
199
301
|
const batch = await listTests({
|
|
200
302
|
limit: 500,
|
|
201
303
|
page: fetchPage,
|
|
202
304
|
returnTotalCount: false,
|
|
203
|
-
...(
|
|
305
|
+
...(wantSort && { sort: [{ property: 'start_time', descending: true }] }),
|
|
204
306
|
...(searchValue && { searchValue }),
|
|
205
307
|
...(filter && { filter }),
|
|
206
308
|
...(keys && { keys }),
|
|
207
309
|
}, projectId, projectName);
|
|
310
|
+
if (wantSort && batch.sortApplied === false && fetchPage > 1) {
|
|
311
|
+
// Sort refused partway through a sorted scan: unsorted page N is not a continuation of sorted
|
|
312
|
+
// pages 1..N-1. Restart from page 1 — the refusal is remembered, so the rescan is unsorted throughout.
|
|
313
|
+
matched.length = 0;
|
|
314
|
+
matchedCount = 0;
|
|
315
|
+
scanned = 0;
|
|
316
|
+
fetchPage = 1;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
208
319
|
const records = batch.data ?? [];
|
|
209
320
|
if (records.length === 0)
|
|
210
321
|
break;
|
|
211
322
|
scanned += records.length;
|
|
323
|
+
const isSortedFetch = batch.sortApplied === true;
|
|
212
324
|
for (const r of records) {
|
|
213
325
|
const t = new Date(r.start_time).getTime();
|
|
214
326
|
// Early-exit is only valid when results are sorted descending by start_time.
|
|
@@ -258,7 +370,13 @@ export function registerReportingTools(server) {
|
|
|
258
370
|
const result = await listTests(request, projectId, projectName);
|
|
259
371
|
const reports = result.data ?? [];
|
|
260
372
|
const countLine = result.count !== undefined ? `Total matching: ${result.count}\n\n` : '';
|
|
261
|
-
|
|
373
|
+
// A requested sort the platform refused must never be presented as sorted output.
|
|
374
|
+
const sortRefused = !!sort && result.sortApplied === false;
|
|
375
|
+
const sortWarning = sortRefused
|
|
376
|
+
? 'The platform refused server-side sort for this credential — these results are in platform order, NOT the order requested. ' +
|
|
377
|
+
'For newest-first results use find_latest_test_for_name / list_active_test_executions, or pass startDate/endDate (scanned and ordered client-side).'
|
|
378
|
+
: undefined;
|
|
379
|
+
return respond(outputFormat, { reports, total: result.count, ...(sortRefused && { sortApplied: false, warning: sortWarning }) }, (sortWarning ? `⚠️ ${sortWarning}\n\n` : '') + countLine + formatTestReportList(reports));
|
|
262
380
|
}
|
|
263
381
|
catch (e) {
|
|
264
382
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
@@ -269,6 +387,7 @@ export function registerReportingTools(server) {
|
|
|
269
387
|
'Use groupBy to specify which fields to group on — e.g. ["device.os"] returns one row per OS. ' +
|
|
270
388
|
'Use pivotBy to add per-status columns (passedCount, failedCount, etc.) instead of separate rows. ' +
|
|
271
389
|
'Useful for dashboards: pass/fail by OS, by test name, by environment, etc. ' +
|
|
390
|
+
'Shared vs dedicated devices: groupBy ["device.pool.actual"] with pivotBy ["status"] (platform 26.7+; null = not recorded, e.g. browser tests or older runs). ' +
|
|
272
391
|
'Note: null OS values represent browser/Selenium sessions. ' +
|
|
273
392
|
'When groupBy includes "device.os", the MCP normalises case variants ("ANDROID"/"IOS") to ' +
|
|
274
393
|
'"Android"/"iOS" and merges their counts, so you always receive at most 3 rows: Android, iOS, null.', {
|
|
@@ -313,20 +432,25 @@ export function registerReportingTools(server) {
|
|
|
313
432
|
for (const row of result.data) {
|
|
314
433
|
const rawOs = row['device.os'];
|
|
315
434
|
const normOs = rawOs == null ? null : (OS_NORM[(String(rawOs)).toLowerCase()] ?? String(rawOs));
|
|
316
|
-
|
|
435
|
+
// Key on EVERY group-by field (OS normalised). Keying on the OS alone collapsed multi-field groupings —
|
|
436
|
+
// ["device.os","status"] merged Passed and Failed into one row per OS.
|
|
437
|
+
const key = JSON.stringify(groupBy.map((f) => (f === 'device.os' ? normOs : row[f] ?? null)));
|
|
317
438
|
if (!merged[key]) {
|
|
318
439
|
merged[key] = { ...row, 'device.os': normOs };
|
|
319
440
|
}
|
|
320
441
|
else {
|
|
321
|
-
// Sum all numeric count fields
|
|
442
|
+
// Sum all numeric count fields (group-by fields are never summed)
|
|
322
443
|
for (const [k, v] of Object.entries(row)) {
|
|
323
|
-
if (typeof v === 'number' && k
|
|
444
|
+
if (typeof v === 'number' && !groupBy.includes(k)) {
|
|
324
445
|
merged[key][k] = (merged[key][k] ?? 0) + v;
|
|
325
446
|
}
|
|
326
447
|
}
|
|
327
448
|
}
|
|
328
449
|
}
|
|
329
|
-
|
|
450
|
+
const rows = Object.values(merged);
|
|
451
|
+
// `count` is the number of groups — after merging it must describe the rows actually returned (UAT 2026-10-09:
|
|
452
|
+
// count 5 with 3 rows).
|
|
453
|
+
result = { ...result, data: rows, ...(result.count != null ? { count: rows.length } : {}) };
|
|
330
454
|
}
|
|
331
455
|
return respond(outputFormat, result, formatGroupedTestReports(result));
|
|
332
456
|
}
|
|
@@ -376,7 +500,7 @@ export function registerReportingTools(server) {
|
|
|
376
500
|
}
|
|
377
501
|
});
|
|
378
502
|
// ─── delete_test_reports ───────────────────────────────────────────────────
|
|
379
|
-
server.tool('delete_test_reports', 'Permanently delete one or more test execution records by their numeric IDs. This cannot be undone. Requires confirmDeletion: true. Cloud Admin only
|
|
503
|
+
server.tool('delete_test_reports', 'Permanently delete one or more test execution records by their numeric IDs. This cannot be undone. Requires confirmDeletion: true. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). PREFERRED cleanup method whenever the IDs are already known (e.g. from a filtered list_test_reports call) — more precise than name or date matching.', {
|
|
380
504
|
ids: z
|
|
381
505
|
.array(z.number().int())
|
|
382
506
|
.min(1)
|
|
@@ -388,8 +512,9 @@ export function registerReportingTools(server) {
|
|
|
388
512
|
projectId: z.number().int().optional().describe('Ignored — reporter API CSRF-blocks numeric projectId. Use projectName instead.'),
|
|
389
513
|
projectName: z.string().optional().describe('Exact project name (from list_projects) to scope the delete to a specific reporter instance.'),
|
|
390
514
|
}, async ({ ids, confirmDeletion, projectId, projectName }) => {
|
|
391
|
-
|
|
392
|
-
|
|
515
|
+
const denied = await checkDeleteAllowed(projectName);
|
|
516
|
+
if (denied) {
|
|
517
|
+
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
393
518
|
}
|
|
394
519
|
if (confirmDeletion !== true) {
|
|
395
520
|
if (ids.length <= 50) {
|
|
@@ -438,7 +563,7 @@ export function registerReportingTools(server) {
|
|
|
438
563
|
}
|
|
439
564
|
});
|
|
440
565
|
// ─── delete_test_reports_by_name ──────────────────────────────────────────
|
|
441
|
-
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead — no name-matching ambiguity. Cloud Admin
|
|
566
|
+
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead — no name-matching ambiguity. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). IMPORTANT: always pass projectName (exact project name from list_projects) when using Cloud Admin access — without it the search spans the default reporter scope and tests from separate project reporter instances will not appear. The numeric projectId param is CSRF-blocked on reporter endpoints and is silently ignored.', {
|
|
442
567
|
name: z
|
|
443
568
|
.string()
|
|
444
569
|
.optional()
|
|
@@ -459,8 +584,9 @@ export function registerReportingTools(server) {
|
|
|
459
584
|
projectId: z.number().int().optional().describe('Ignored — the reporter API CSRF-blocks numeric projectId. Use projectName instead.'),
|
|
460
585
|
projectName: z.string().optional().describe('Exact project name (from list_projects) to scope the search. Required when the target project has its own reporter instance separate from the default scope.'),
|
|
461
586
|
}, async ({ name, nameContains, confirmDeletion, maxPreviewResults, projectId, projectName }) => {
|
|
462
|
-
|
|
463
|
-
|
|
587
|
+
const denied = await checkDeleteAllowed(projectName);
|
|
588
|
+
if (denied) {
|
|
589
|
+
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
464
590
|
}
|
|
465
591
|
try {
|
|
466
592
|
if (!name && !nameContains) {
|
|
@@ -539,23 +665,78 @@ export function registerReportingTools(server) {
|
|
|
539
665
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
540
666
|
}
|
|
541
667
|
});
|
|
668
|
+
// ─── download_test_video ───────────────────────────────────────────────────
|
|
669
|
+
server.tool('download_test_video', 'Download only the session video (.mp4) of a test execution — no ZIP, no logs — or just one byte range of it. ' +
|
|
670
|
+
'infoOnly: true returns the size without downloading. Byte ranges let you fetch a large recording in pieces, resume ' +
|
|
671
|
+
'a cut-off download, or grab the start/end of a long session. Use download_test_attachments when you also need the logs.' +
|
|
672
|
+
serverFsDownloadNotice(), {
|
|
673
|
+
report: z.string().describe('Report UUID (preferred — numeric ids collide across projects), numeric test id, or the report URL (e.g. .../reporter/video-report/<uuid>).'),
|
|
674
|
+
localPath: z.string().optional().describe('Where to write the .mp4 (required unless infoOnly). ' + serverFsOutputParam()),
|
|
675
|
+
infoOnly: z.boolean().optional().describe('Return the video size and type without downloading it.'),
|
|
676
|
+
startByte: z.number().int().min(0).optional().describe('First byte of a partial download (0-based). With endByte for a fixed range; alone for "from here to the end" (e.g. resuming).'),
|
|
677
|
+
endByte: z.number().int().min(0).optional().describe('Last byte of a partial download, inclusive. Needs startByte.'),
|
|
678
|
+
lastBytes: z.number().int().min(1).optional().describe('Download only the final N bytes. Do not combine with startByte/endByte.'),
|
|
679
|
+
outputFormat: outputFormatParam,
|
|
680
|
+
}, async ({ report, localPath, infoOnly, startByte, endByte, lastBytes, outputFormat }) => {
|
|
681
|
+
const ref = parseReportRef(report);
|
|
682
|
+
if (!ref)
|
|
683
|
+
return { content: [{ type: 'text', text: `Error: "${report}" is not a report UUID, numeric test id or report URL.` }], isError: true };
|
|
684
|
+
const fail = (msg) => ({ content: [{ type: 'text', text: `Error: ${msg}` }], isError: true });
|
|
685
|
+
if (lastBytes != null && (startByte != null || endByte != null))
|
|
686
|
+
return fail('use either lastBytes or startByte/endByte, not both.');
|
|
687
|
+
if (endByte != null && startByte == null)
|
|
688
|
+
return fail('endByte needs startByte.');
|
|
689
|
+
if (startByte != null && endByte != null && endByte < startByte)
|
|
690
|
+
return fail('endByte must not be before startByte.');
|
|
691
|
+
const range = lastBytes != null ? `bytes=-${lastBytes}` : startByte != null ? `bytes=${startByte}-${endByte ?? ''}` : undefined;
|
|
692
|
+
const idNote = ref.kind === 'testId' ? ' Numeric ids are only unique per project — prefer the UUID.' : '';
|
|
693
|
+
try {
|
|
694
|
+
if (infoOnly) {
|
|
695
|
+
const info = await getTestVideoInfo(ref);
|
|
696
|
+
const mb = info.totalBytes != null ? `${(info.totalBytes / (1024 * 1024)).toFixed(1)} MB` : 'unknown size';
|
|
697
|
+
return respond(outputFormat, { ...info, rangeRequests: true }, `🎬 Video: ${mb} (${info.totalBytes ?? '?'} bytes, ${info.contentType ?? 'unknown type'}). Byte ranges are supported.${idNote}`);
|
|
698
|
+
}
|
|
699
|
+
if (!localPath)
|
|
700
|
+
return fail('localPath is required unless infoOnly is true.');
|
|
701
|
+
const pathErr = validateOutputPath(localPath);
|
|
702
|
+
if (pathErr)
|
|
703
|
+
return fail(pathErr);
|
|
704
|
+
const r = await downloadTestVideo(ref, localPath, range);
|
|
705
|
+
const what = r.partial ? `bytes ${r.contentRange?.replace(/^bytes\s*/, '') ?? range}` : 'full video';
|
|
706
|
+
return respond(outputFormat, { ...r, localPath }, `✅ ${what} (${r.bytesWritten} bytes${r.totalBytes != null ? ` of ${r.totalBytes}` : ''}) written to: ${localPath}` +
|
|
707
|
+
(r.partial ? '\nA partial file is a fragment, not a playable video on its own unless it starts at byte 0 and the player tolerates truncation.' : '') +
|
|
708
|
+
idNote);
|
|
709
|
+
}
|
|
710
|
+
catch (e) {
|
|
711
|
+
const msg = e.message;
|
|
712
|
+
if (/\[416\]/.test(msg))
|
|
713
|
+
return fail(`the requested range is outside the video. Call with infoOnly: true to get its size. (${msg})`);
|
|
714
|
+
return fail(msg);
|
|
715
|
+
}
|
|
716
|
+
});
|
|
542
717
|
// ─── get_test_attachments_download_command ─────────────────────────────────
|
|
543
718
|
server.tool('get_test_attachments_download_command', 'Generates a ready-to-run curl or PowerShell command for downloading a test execution\'s full attachment ZIP (session video .mp4, Appium/device logs) directly to the user\'s local machine. ' +
|
|
544
719
|
commandGeneratorNotice('download_test_attachments', 'download') + ' ' +
|
|
545
720
|
'For text logs only, get_test_log is simpler (returns log text inline, no command). This is the path for the BINARY artifacts (video).\n\n' +
|
|
546
721
|
'WARNING: The generated command embeds the active access key in plaintext. Instruct the user to run it immediately and not save or share the output.', {
|
|
547
722
|
uuid: z.string().describe('Test execution UUID (uuid field from get_test_report or list_test_reports).'),
|
|
548
|
-
localPath: z.string().optional().
|
|
723
|
+
localPath: z.string().optional().describe('Path on the user\'s local machine to save the file. Default: "test-attachments.zip" (or "test-video.mp4" for artifact "video") in the current directory.'),
|
|
724
|
+
artifact: z
|
|
725
|
+
.enum(['zip', 'video'])
|
|
726
|
+
.optional()
|
|
727
|
+
.default('zip')
|
|
728
|
+
.describe('"zip" (default): the full attachment ZIP (video + logs). "video": only the session .mp4 — smaller, no unzip.'),
|
|
549
729
|
localPlatform: z.enum(['windows', 'macos', 'linux']).describe('Platform of the machine that will run the command. ' + localPlatformParamNotice()),
|
|
550
730
|
outputFormat: outputFormatParam,
|
|
551
|
-
}, async ({ uuid, localPath, localPlatform, outputFormat }) => {
|
|
731
|
+
}, async ({ uuid, localPath, artifact, localPlatform, outputFormat }) => {
|
|
732
|
+
const video = artifact === 'video';
|
|
552
733
|
const result = buildDownloadCommand({
|
|
553
|
-
path: `/reporter/api/reports/${uuid}
|
|
554
|
-
localPath: localPath ?? 'test-attachments.zip',
|
|
734
|
+
path: `/reporter/api/reports/${uuid}/${video ? 'video' : 'attachments'}`,
|
|
735
|
+
localPath: localPath ?? (video ? 'test-video.mp4' : 'test-attachments.zip'),
|
|
555
736
|
localPlatform,
|
|
556
|
-
notes: ['The downloaded file is a ZIP — unzip it to access the .mp4 video and the appium/device/ws logs.'],
|
|
737
|
+
notes: [video ? 'The downloaded file is the session video (.mp4).' : 'The downloaded file is a ZIP — unzip it to access the .mp4 video and the appium/device/ws logs.'],
|
|
557
738
|
});
|
|
558
|
-
return respond(outputFormat,
|
|
739
|
+
return respond(outputFormat, commandPayload(result), result.humanText);
|
|
559
740
|
});
|
|
560
741
|
// ─── get_test_log ──────────────────────────────────────────────────────────
|
|
561
742
|
server.tool('get_test_log', 'Retrieve log content from a test execution directly as text — no file download required. ' +
|
|
@@ -618,12 +799,16 @@ export function registerReportingTools(server) {
|
|
|
618
799
|
}
|
|
619
800
|
});
|
|
620
801
|
// ─── list_test_attachments ─────────────────────────────────────────────────
|
|
621
|
-
server.tool('list_test_attachments', 'Show attachment metadata (file names, types, sizes) for a test execution. Takes the
|
|
622
|
-
|
|
802
|
+
server.tool('list_test_attachments', 'Show attachment metadata (file names, types, sizes) for a test execution. Takes the uuid (preferred — globally unique) or the numeric testId. Call this before download_test_attachments to confirm attachments exist — download_test_attachments then takes the uuid shown in the output.', {
|
|
803
|
+
uuid: z.string().optional().describe('Test execution UUID (uuid field from list_test_reports). Preferred.'),
|
|
804
|
+
testId: z.number().int().optional().describe('Numeric test ID (test_id from list_test_reports). Unique only within a project — prefer uuid.'),
|
|
623
805
|
outputFormat: outputFormatParam,
|
|
624
|
-
}, async ({ testId, outputFormat }) => {
|
|
806
|
+
}, async ({ uuid, testId, outputFormat }) => {
|
|
807
|
+
if ((uuid ? 1 : 0) + (testId != null ? 1 : 0) !== 1) {
|
|
808
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid or testId.' }], isError: true };
|
|
809
|
+
}
|
|
625
810
|
try {
|
|
626
|
-
const report = await getTestById(testId);
|
|
811
|
+
const report = uuid ? await getTestByUuid(uuid) : await getTestById(testId);
|
|
627
812
|
const structured = {
|
|
628
813
|
testId: report.test_id,
|
|
629
814
|
uuid: report.uuid,
|
|
@@ -646,8 +831,8 @@ export function registerReportingTools(server) {
|
|
|
646
831
|
outputFormat: outputFormatParam,
|
|
647
832
|
}, async ({ name, projectId, projectName, outputFormat }) => {
|
|
648
833
|
try {
|
|
649
|
-
// listTestsSortedDesc guarantees newest-first for
|
|
650
|
-
//
|
|
834
|
+
// listTestsSortedDesc guarantees newest-first for every role — if sort is refused, a plain sorted
|
|
835
|
+
// listTests call would silently
|
|
651
836
|
// return an arbitrary record instead of the latest.
|
|
652
837
|
const result = await listTestsSortedDesc({ limit: 1, page: 1, searchValue: name }, projectId, projectName);
|
|
653
838
|
if (!result.data || result.data.length === 0) {
|
|
@@ -660,7 +845,7 @@ export function registerReportingTools(server) {
|
|
|
660
845
|
}
|
|
661
846
|
});
|
|
662
847
|
// ─── get_project_test_summary ──────────────────────────────────────────────
|
|
663
|
-
server.tool('get_project_test_summary', 'Return a
|
|
848
|
+
server.tool('get_project_test_summary', 'Return a pass/fail summary for a project. Status counts cover all six reporter statuses (Passed, Failed, Error, Incomplete, Skipped, Healed) and are all-time totals — the reporter API does not support date-range filtering for aggregate counts. Error = the test ended abnormally (crash, infrastructure, session ended early — since platform 26.9 these are no longer Incomplete). Pass rate = (Passed+Healed)/(Passed+Healed+Failed+Error). Top failing and top erroring test names are filtered to the requested time window client-side from the most recent 200 of each.', {
|
|
664
849
|
startDate: z
|
|
665
850
|
.string()
|
|
666
851
|
.optional()
|
|
@@ -676,58 +861,70 @@ export function registerReportingTools(server) {
|
|
|
676
861
|
try {
|
|
677
862
|
const defaultStart = new Date(Date.now() - 48 * 60 * 60 * 1000).toISOString();
|
|
678
863
|
const resolvedStart = startDate ?? defaultStart;
|
|
679
|
-
//
|
|
680
|
-
//
|
|
681
|
-
//
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
864
|
+
// All six status counts in ONE call: grouped with pivotBy ["status"] and no groupBy returns a single row
|
|
865
|
+
// { passedCount, failedCount, errorCount, incompleteCount, skippedCount, healedCount, _count_ } (verified live
|
|
866
|
+
// 2026-10-09). The previous per-status listTests calls only asked for Passed/Failed/Incomplete, so Error,
|
|
867
|
+
// Skipped and Healed never reached the total — and since 26.9 every crash/infrastructure abort is Error.
|
|
868
|
+
// Recent Failed and Error records are fetched alongside for the windowed top-N names.
|
|
869
|
+
const recent = (status) => listTestsSortedDesc({ limit: 200, page: 1, returnTotalCount: false, filter: [{ property: 'status', operator: '=', value: status }] }, projectId, projectName);
|
|
870
|
+
const [grouped, failedResult, errorResult, byPool] = await Promise.all([
|
|
871
|
+
getGroupedTests({ pivotBy: ['status'] }, projectId, projectName),
|
|
872
|
+
recent('Failed'),
|
|
873
|
+
recent('Error'),
|
|
874
|
+
// device.pool.actual (platform 26.7+): which pool each mobile automation test actually ran on. Shared-device
|
|
875
|
+
// flakiness is a common question; one grouped call answers it. Best-effort — the summary stands without it.
|
|
876
|
+
getGroupedTests({ groupBy: ['device.pool.actual'], pivotBy: ['status'] }, projectId, projectName).catch(() => null),
|
|
686
877
|
]);
|
|
687
|
-
const
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
878
|
+
const counts = countsFromPivotRow(grouped?.data?.[0]);
|
|
879
|
+
const devicePools = (byPool?.data ?? [])
|
|
880
|
+
.filter((r) => r['device.pool.actual'] != null) // null = not recorded (non-mobile tests, or before 26.7)
|
|
881
|
+
.map((r) => { const c = countsFromPivotRow(r); return { pool: String(r['device.pool.actual']), total: c.total, failed: c.failed, error: c.error, passRate: passRate(c) }; })
|
|
882
|
+
.sort((a, b) => b.total - a.total);
|
|
883
|
+
// Apply the date window client-side on the most recent 200 of each
|
|
692
884
|
// (start_time filter via API key triggers CSRF — filter locally instead).
|
|
693
885
|
const endTs = endDate ? new Date(endDate).getTime() : Date.now();
|
|
694
886
|
const startTs = new Date(resolvedStart).getTime();
|
|
695
|
-
const
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
const
|
|
887
|
+
const topNames = (records) => {
|
|
888
|
+
const nameCounts = {};
|
|
889
|
+
for (const r of records) {
|
|
890
|
+
const t = new Date(r.start_time).getTime();
|
|
891
|
+
if (t >= startTs && t <= endTs)
|
|
892
|
+
nameCounts[r.name] = (nameCounts[r.name] ?? 0) + 1;
|
|
893
|
+
}
|
|
894
|
+
return Object.entries(nameCounts)
|
|
895
|
+
.sort((a, b) => b[1] - a[1])
|
|
896
|
+
.slice(0, 5)
|
|
897
|
+
.map(([name, count]) => `${name} (${count}x)`);
|
|
898
|
+
};
|
|
899
|
+
const topFailures = topNames(failedResult.data ?? []);
|
|
900
|
+
const topErrors = topNames(errorResult.data ?? []);
|
|
708
901
|
const windowLabel = endDate
|
|
709
902
|
? `${resolvedStart} → ${endDate}`
|
|
710
903
|
: startDate
|
|
711
904
|
? `${resolvedStart} → now`
|
|
712
905
|
: `last 48 hours`;
|
|
713
|
-
const
|
|
906
|
+
const unknown = unknownStatusCount(counts);
|
|
714
907
|
const structured = {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
passRate: parseFloat(passRate),
|
|
908
|
+
...counts,
|
|
909
|
+
...(unknown > 0 ? { otherStatus: unknown } : {}),
|
|
910
|
+
passRate: passRate(counts),
|
|
911
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
720
912
|
topFailures,
|
|
913
|
+
topErrors,
|
|
721
914
|
window: windowLabel,
|
|
915
|
+
...(devicePools.length ? { byDevicePool: devicePools } : {}),
|
|
722
916
|
};
|
|
723
|
-
|
|
917
|
+
const poolLines = devicePools.length
|
|
918
|
+
? ['', ' By device pool (mobile automation, platform 26.7+):', ...devicePools.map((p) => ` ${p.pool.padEnd(10)} ${String(p.total).padStart(8)} tests · pass rate ${p.passRate == null ? 'n/a' : `${p.passRate}%`} · ${p.failed} failed · ${p.error} error`)]
|
|
919
|
+
: [];
|
|
920
|
+
return respond(outputFormat, structured, formatProjectTestSummary(counts, windowLabel, topFailures, topErrors) + poolLines.join('\n'));
|
|
724
921
|
}
|
|
725
922
|
catch (e) {
|
|
726
923
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
727
924
|
}
|
|
728
925
|
});
|
|
729
926
|
// ─── delete_test_reports_before_date ──────────────────────────────────────
|
|
730
|
-
server.tool('delete_test_reports_before_date', 'Permanently delete all test execution records started before a given date. Fetches matching IDs automatically then deletes them. Requires confirmDeletion: true. This cannot be undone. Cloud Admin only
|
|
927
|
+
server.tool('delete_test_reports_before_date', 'Permanently delete all test execution records started before a given date. Fetches matching IDs automatically then deletes them. Requires confirmDeletion: true. This cannot be undone. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled).', {
|
|
731
928
|
beforeDate: z
|
|
732
929
|
.string()
|
|
733
930
|
.describe('ISO 8601 cutoff date. All tests with start_time before this date will be deleted, e.g. "2024-01-01T00:00:00Z".'),
|
|
@@ -738,8 +935,9 @@ export function registerReportingTools(server) {
|
|
|
738
935
|
projectId: z.number().int().optional().describe('Scope to this project ID.'),
|
|
739
936
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
740
937
|
}, async ({ beforeDate, confirmDeletion, projectId, projectName }) => {
|
|
741
|
-
|
|
742
|
-
|
|
938
|
+
const denied = await checkDeleteAllowed(projectName);
|
|
939
|
+
if (denied) {
|
|
940
|
+
return { content: [{ type: 'text', text: denied }], isError: true };
|
|
743
941
|
}
|
|
744
942
|
try {
|
|
745
943
|
// The reporter API does not support start_time filter via API key (CSRF restriction).
|
|
@@ -785,10 +983,17 @@ export function registerReportingTools(server) {
|
|
|
785
983
|
.optional()
|
|
786
984
|
.default(50)
|
|
787
985
|
.describe('Maximum number of active executions to return (default: 50).'),
|
|
986
|
+
maxAgeHours: z
|
|
987
|
+
.number()
|
|
988
|
+
.min(1)
|
|
989
|
+
.max(168)
|
|
990
|
+
.optional()
|
|
991
|
+
.default(12)
|
|
992
|
+
.describe('Ignore Incomplete records that started longer ago than this — they are abandoned or never-finalised runs, not running ones (default 12; test runs time out after 4 h by default).'),
|
|
788
993
|
projectId: z.number().int().optional().describe('Scope to this project ID.'),
|
|
789
994
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
790
995
|
outputFormat: outputFormatParam,
|
|
791
|
-
}, async ({ limit, projectId, projectName, outputFormat }) => {
|
|
996
|
+
}, async ({ limit, maxAgeHours, projectId, projectName, outputFormat }) => {
|
|
792
997
|
try {
|
|
793
998
|
// Active executions are Incomplete records with null duration.
|
|
794
999
|
// We fetch more than needed since not all Incomplete records are still running.
|
|
@@ -798,11 +1003,22 @@ export function registerReportingTools(server) {
|
|
|
798
1003
|
returnTotalCount: false,
|
|
799
1004
|
filter: [{ property: 'status', operator: '=', value: 'Incomplete' }],
|
|
800
1005
|
}, projectId, projectName);
|
|
801
|
-
|
|
1006
|
+
// Incomplete + null duration also matches runs that were abandoned or never finalised — the UAT (2026-10-09)
|
|
1007
|
+
// found every "active" execution was 3+ days old. Anything older than maxAgeHours is not running now.
|
|
1008
|
+
const ageCutoff = Date.now() - (maxAgeHours ?? 12) * 3600_000;
|
|
1009
|
+
const unfinished = (result.data ?? []).filter(r => r.duration === null);
|
|
1010
|
+
const recent = unfinished.filter(r => new Date(r.start_time).getTime() >= ageCutoff);
|
|
1011
|
+
const staleExcluded = unfinished.length - recent.length;
|
|
1012
|
+
const active = recent.slice(0, limit ?? 50);
|
|
1013
|
+
const staleNote = staleExcluded > 0
|
|
1014
|
+
? ` ${staleExcluded} older Incomplete record(s) were ignored as stale (started more than ${maxAgeHours ?? 12} h ago — abandoned or never finalised).`
|
|
1015
|
+
: '';
|
|
802
1016
|
if (active.length === 0) {
|
|
803
|
-
return respond(outputFormat, { count: 0, executions: [] },
|
|
1017
|
+
return respond(outputFormat, { count: 0, executions: [], staleExcluded, maxAgeHours: maxAgeHours ?? 12 }, `No active test executions found.${staleNote}`);
|
|
804
1018
|
}
|
|
805
1019
|
const structured = {
|
|
1020
|
+
staleExcluded,
|
|
1021
|
+
maxAgeHours: maxAgeHours ?? 12,
|
|
806
1022
|
count: active.length,
|
|
807
1023
|
executions: active.map(r => ({
|
|
808
1024
|
testId: r.test_id,
|
|
@@ -820,7 +1036,7 @@ export function registerReportingTools(server) {
|
|
|
820
1036
|
const elapsedSec = Math.floor((elapsedMs % 60000) / 1000);
|
|
821
1037
|
lines.push(` • ${r.name}`, ` Test ID: ${r.test_id} UUID: ${r.uuid}`, ` Started: ${r.start_time} Elapsed: ${elapsedMin}m ${elapsedSec}s`, ` Project: ${r.project_id}`, '');
|
|
822
1038
|
}
|
|
823
|
-
lines.push(
|
|
1039
|
+
lines.push(`Note: "active" is inferred from Incomplete status + null duration within the last ${maxAgeHours ?? 12} h. A test that finished very recently may appear here until the reporter updates.${staleNote}`);
|
|
824
1040
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
825
1041
|
}
|
|
826
1042
|
catch (e) {
|
|
@@ -867,18 +1083,16 @@ export function registerReportingTools(server) {
|
|
|
867
1083
|
if (runs.length === 0) {
|
|
868
1084
|
return respond(outputFormat, { found: false }, `No executions found for test name containing "${testName}".`);
|
|
869
1085
|
}
|
|
870
|
-
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
return '⚠️';
|
|
881
|
-
}).join(' ');
|
|
1086
|
+
// Classify by status, not `success` — success is false for Healed (verified live), true only for Passed.
|
|
1087
|
+
const c = tallyStatuses(runs);
|
|
1088
|
+
const passed = c.passed + c.healed;
|
|
1089
|
+
const failed = c.failed;
|
|
1090
|
+
const error = c.error;
|
|
1091
|
+
const other = runs.length - passed - failed - error;
|
|
1092
|
+
const rate = passRate(c);
|
|
1093
|
+
// Sparkline: ✅ = Passed/Healed, ❌ = Failed, 💥 = Error, ⚠️ = other — newest last
|
|
1094
|
+
const icon = (s) => (s === 'Error' ? '💥' : { pass: '✅', fail: '❌', other: '⚠️' }[statusOutcome(s)]);
|
|
1095
|
+
const spark = [...runs].reverse().map(r => icon(r.status)).join(' ');
|
|
882
1096
|
// Consecutive streak from the most recent run
|
|
883
1097
|
const latestStatus = runs[0].status;
|
|
884
1098
|
let streak = 0;
|
|
@@ -892,8 +1106,9 @@ export function registerReportingTools(server) {
|
|
|
892
1106
|
const structured = {
|
|
893
1107
|
testName: runs[0].name,
|
|
894
1108
|
runs: runs.length,
|
|
895
|
-
passed, failed, other,
|
|
896
|
-
passRate:
|
|
1109
|
+
passed, failed, error, other,
|
|
1110
|
+
passRate: rate,
|
|
1111
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
897
1112
|
latestStatus: runs[0].status,
|
|
898
1113
|
latestRun: runs[0].start_time,
|
|
899
1114
|
streak,
|
|
@@ -906,8 +1121,8 @@ export function registerReportingTools(server) {
|
|
|
906
1121
|
};
|
|
907
1122
|
const lines = [
|
|
908
1123
|
`📋 Stability report: "${runs[0].name}"`,
|
|
909
|
-
` Runs examined: ${runs.length} | Pass rate: ${
|
|
910
|
-
` ${passed} passed · ${failed} failed · ${other} other`,
|
|
1124
|
+
` Runs examined: ${runs.length} | Pass rate: ${rate == null ? 'n/a' : `${rate}%`} | Latest: ${runs[0].status}${streakLabel}`,
|
|
1125
|
+
` ${passed} passed · ${failed} failed · ${error} error · ${other} other`,
|
|
911
1126
|
``,
|
|
912
1127
|
` Trend (oldest → newest):`,
|
|
913
1128
|
` ${spark}`,
|
|
@@ -915,8 +1130,7 @@ export function registerReportingTools(server) {
|
|
|
915
1130
|
` Most recent ${Math.min(5, runs.length)} runs:`,
|
|
916
1131
|
...runs.slice(0, 5).map(r => {
|
|
917
1132
|
const dur = r.duration != null ? `${(r.duration / 1000).toFixed(1)}s` : 'n/a';
|
|
918
|
-
|
|
919
|
-
return ` ${icon} ${r.status} — ${r.start_time} (${dur})`;
|
|
1133
|
+
return ` ${icon(r.status)} ${r.status} — ${r.start_time} (${dur})`;
|
|
920
1134
|
}),
|
|
921
1135
|
];
|
|
922
1136
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
@@ -947,11 +1161,10 @@ export function registerReportingTools(server) {
|
|
|
947
1161
|
const os = String(row['device.os'] ?? '');
|
|
948
1162
|
if (!name || (os !== 'Android' && os !== 'iOS'))
|
|
949
1163
|
continue;
|
|
950
|
-
const
|
|
951
|
-
const total = Number(row['_count_'] ?? (Number(row['passedCount'] ?? 0) + Number(row['failedCount'] ?? 0) + Number(row['incompleteCount'] ?? 0) + Number(row['errorCount'] ?? 0)));
|
|
1164
|
+
const c = countsFromPivotRow(row);
|
|
952
1165
|
if (!map[name])
|
|
953
1166
|
map[name] = {};
|
|
954
|
-
map[name][os] = {
|
|
1167
|
+
map[name][os] = { rate: passRate(c) ?? 0, total: c.total };
|
|
955
1168
|
}
|
|
956
1169
|
// Find divergent tests
|
|
957
1170
|
const divergent = Object.entries(map)
|
|
@@ -963,8 +1176,8 @@ export function registerReportingTools(server) {
|
|
|
963
1176
|
.map(([name, platforms]) => {
|
|
964
1177
|
const a = platforms.Android;
|
|
965
1178
|
const i = platforms.iOS;
|
|
966
|
-
const androidPct = a.
|
|
967
|
-
const iosPct = i.
|
|
1179
|
+
const androidPct = a.rate;
|
|
1180
|
+
const iosPct = i.rate;
|
|
968
1181
|
return {
|
|
969
1182
|
name,
|
|
970
1183
|
androidPassRate: parseFloat(androidPct.toFixed(1)),
|
|
@@ -1014,27 +1227,52 @@ export function registerReportingTools(server) {
|
|
|
1014
1227
|
const cutoffTs = Date.now() - lookbackDays * 86400000;
|
|
1015
1228
|
const records = [];
|
|
1016
1229
|
let fetchPage = 1;
|
|
1230
|
+
let scanned = 0;
|
|
1231
|
+
let scanCapped = false;
|
|
1017
1232
|
let done = false;
|
|
1018
1233
|
while (!done && records.length < maxRecords) {
|
|
1234
|
+
const wantSort = serverSortAvailable();
|
|
1019
1235
|
const batch = await listTests({ limit: 500, page: fetchPage, returnTotalCount: false,
|
|
1020
|
-
sort: [{ property: 'start_time', descending: true }] }, projectId, projectName);
|
|
1236
|
+
...(wantSort && { sort: [{ property: 'start_time', descending: true }] }) }, projectId, projectName);
|
|
1237
|
+
if (wantSort && batch.sortApplied === false && fetchPage > 1) {
|
|
1238
|
+
// Sort refused partway through: unsorted page N is not a continuation of sorted pages 1..N-1.
|
|
1239
|
+
records.length = 0;
|
|
1240
|
+
scanned = 0;
|
|
1241
|
+
fetchPage = 1;
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1021
1244
|
const rows = batch.data ?? [];
|
|
1022
1245
|
if (rows.length === 0)
|
|
1023
1246
|
break;
|
|
1247
|
+
scanned += rows.length;
|
|
1248
|
+
const isSorted = batch.sortApplied === true;
|
|
1024
1249
|
for (const r of rows) {
|
|
1025
1250
|
const ts = new Date(r.start_time).getTime();
|
|
1251
|
+
// Early-exit is only valid on server-sorted data; otherwise skip out-of-window rows and keep scanning.
|
|
1026
1252
|
if (ts < cutoffTs) {
|
|
1027
|
-
|
|
1028
|
-
|
|
1253
|
+
if (isSorted) {
|
|
1254
|
+
done = true;
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
continue;
|
|
1029
1258
|
}
|
|
1030
1259
|
records.push({ status: r.status, start_time: r.start_time });
|
|
1260
|
+
// The record cap ended the scan before the cutoff was reached: older days in the window were never read.
|
|
1261
|
+
// (UAT 2026-10-09: a 14-day trend stopped at 5,000 records on day 6 and reported scanCapped: false.)
|
|
1031
1262
|
if (records.length >= maxRecords) {
|
|
1263
|
+
scanCapped = true;
|
|
1032
1264
|
done = true;
|
|
1033
1265
|
break;
|
|
1034
1266
|
}
|
|
1035
1267
|
}
|
|
1036
1268
|
if (rows.length < 500)
|
|
1037
1269
|
done = true;
|
|
1270
|
+
// Unsorted fallback has no early-exit: maxRecords bounds the rows FETCHED (as documented), and the
|
|
1271
|
+
// caller is told the window may be incomplete.
|
|
1272
|
+
if (!done && !isSorted && scanned >= maxRecords) {
|
|
1273
|
+
scanCapped = true;
|
|
1274
|
+
done = true;
|
|
1275
|
+
}
|
|
1038
1276
|
fetchPage++;
|
|
1039
1277
|
}
|
|
1040
1278
|
if (records.length === 0) {
|
|
@@ -1052,45 +1290,53 @@ export function registerReportingTools(server) {
|
|
|
1052
1290
|
}
|
|
1053
1291
|
return d.toISOString().slice(0, 10);
|
|
1054
1292
|
};
|
|
1293
|
+
const grouped = {};
|
|
1294
|
+
for (const r of records)
|
|
1295
|
+
(grouped[bucketKey(r.start_time)] ??= []).push(r);
|
|
1296
|
+
// passed = Passed + Healed; Error (abnormal end — crash/infrastructure, 26.9+) is its own column, not "other".
|
|
1055
1297
|
const buckets = {};
|
|
1056
|
-
for (const
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
buckets[key].total++;
|
|
1061
|
-
if (r.status === 'Passed')
|
|
1062
|
-
buckets[key].passed++;
|
|
1063
|
-
else if (r.status === 'Failed')
|
|
1064
|
-
buckets[key].failed++;
|
|
1065
|
-
else
|
|
1066
|
-
buckets[key].other++;
|
|
1298
|
+
for (const [key, rs] of Object.entries(grouped)) {
|
|
1299
|
+
const c = tallyStatuses(rs);
|
|
1300
|
+
const passed = c.passed + c.healed;
|
|
1301
|
+
buckets[key] = { total: c.total, passed, failed: c.failed, error: c.error, other: c.total - passed - c.failed - c.error, passRate: passRate(c) };
|
|
1067
1302
|
}
|
|
1068
1303
|
const sorted = Object.entries(buckets).sort(([a], [b]) => a.localeCompare(b));
|
|
1304
|
+
// Earliest record actually read — when the scan was capped, days before this are missing, not empty.
|
|
1305
|
+
const coveredFrom = records.reduce((min, r) => (r.start_time < min ? r.start_time : min), records[0].start_time);
|
|
1069
1306
|
const structured = {
|
|
1070
1307
|
bucketBy,
|
|
1071
1308
|
lookbackDays,
|
|
1072
1309
|
recordsScanned: records.length,
|
|
1073
1310
|
cappedAt: records.length >= maxRecords ? maxRecords : null,
|
|
1311
|
+
// true whenever maxRecords ended the scan before the lookback window was fully covered
|
|
1312
|
+
scanCapped,
|
|
1313
|
+
windowComplete: !scanCapped,
|
|
1314
|
+
coveredFrom: scanCapped ? coveredFrom : new Date(cutoffTs).toISOString(),
|
|
1074
1315
|
buckets: sorted.map(([date, b]) => ({
|
|
1075
1316
|
date,
|
|
1076
1317
|
total: b.total,
|
|
1077
1318
|
passed: b.passed,
|
|
1078
1319
|
failed: b.failed,
|
|
1320
|
+
error: b.error,
|
|
1079
1321
|
other: b.other,
|
|
1080
|
-
passRate: b.
|
|
1322
|
+
passRate: b.passRate,
|
|
1081
1323
|
})),
|
|
1324
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
1082
1325
|
};
|
|
1083
1326
|
const lines = [
|
|
1084
1327
|
`📅 Test execution trend (${bucketBy === 'week' ? 'weekly' : 'daily'}, last ${lookbackDays} days — ${records.length} records scanned)\n`,
|
|
1085
|
-
` ${'Date'.padEnd(12)} ${'Total'.padStart(6)} ${'Passed'.padStart(7)} ${'Failed'.padStart(7)} ${'Pass%'.padStart(7)}`,
|
|
1086
|
-
` ${'─'.repeat(
|
|
1328
|
+
` ${'Date'.padEnd(12)} ${'Total'.padStart(6)} ${'Passed'.padStart(7)} ${'Failed'.padStart(7)} ${'Error'.padStart(7)} ${'Pass%'.padStart(7)}`,
|
|
1329
|
+
` ${'─'.repeat(52)}`,
|
|
1087
1330
|
...sorted.map(([date, b]) => {
|
|
1088
|
-
const pct = b.
|
|
1089
|
-
return ` ${date.padEnd(12)} ${String(b.total).padStart(6)} ${String(b.passed).padStart(7)} ${String(b.failed).padStart(7)} ${pct.padStart(7)}`;
|
|
1331
|
+
const pct = b.passRate == null ? '—' : b.passRate.toFixed(1);
|
|
1332
|
+
return ` ${date.padEnd(12)} ${String(b.total).padStart(6)} ${String(b.passed).padStart(7)} ${String(b.failed).padStart(7)} ${String(b.error).padStart(7)} ${pct.padStart(7)}`;
|
|
1090
1333
|
}),
|
|
1334
|
+
`\n Passed includes Healed. Pass% = (Passed+Healed)/(Passed+Healed+Failed+Error).`,
|
|
1091
1335
|
];
|
|
1092
|
-
if (
|
|
1093
|
-
lines.push(`\n ⚠️
|
|
1336
|
+
if (scanCapped) {
|
|
1337
|
+
lines.push(`\n ⚠️ INCOMPLETE WINDOW: the scan stopped at maxRecords (${maxRecords}) and only covers ${coveredFrom.slice(0, 10)} onward — ` +
|
|
1338
|
+
`days before that are MISSING from this trend, not days with zero executions. ` +
|
|
1339
|
+
`Increase maxRecords (max 25,000) or reduce lookbackDays for the full ${lookbackDays}-day window.`);
|
|
1094
1340
|
}
|
|
1095
1341
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
1096
1342
|
}
|