Skip to content

Commit 6ae959e

Browse files
fix: update progress messages for LCA status polling and scenario generation
1 parent f0dcf02 commit 6ae959e

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

src/tools/testmanagement-utils/TCG-utils/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export async function pollScenariosTestDetails(
191191
progressToken: context._meta?.progressToken ?? traceId,
192192
progress: count,
193193
total: count,
194-
message: `Fetched ${count} scenarios`,
194+
message: `Generated ${count} scenarios`,
195195
},
196196
});
197197
}

src/tools/testmanagement-utils/poll-lca-status.ts

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,34 @@ export async function pollLCAStatus(
4242
const startTime = Date.now();
4343

4444
// Send initial notification that polling is starting
45-
await context.sendNotification({
46-
method: "notifications/progress",
47-
params: {
48-
progressToken: context._meta?.progressToken ?? `lca-${testCaseId}`,
49-
message: `Generating Low Code Automation...`,
50-
progress: 0,
51-
total: 100,
52-
},
53-
});
45+
const notificationInterval = Math.min(initialWaitMs, pollIntervalMs);
46+
const notificationStartTime = Date.now();
47+
48+
const notificationIntervalId = setInterval(async () => {
49+
const elapsedTime = Date.now() - notificationStartTime;
50+
const progressPercentage = Math.min(
51+
90,
52+
Math.floor((elapsedTime / maxWaitTimeMs) * 90)
53+
);
54+
55+
await context.sendNotification({
56+
method: "notifications/progress",
57+
params: {
58+
progressToken: context._meta?.progressToken ?? `lca-${testCaseId}`,
59+
message: `Generating Low Code Automation Test..`,
60+
progress: progressPercentage,
61+
total: 100,
62+
},
63+
});
64+
65+
if (elapsedTime >= initialWaitMs) {
66+
clearInterval(notificationIntervalId);
67+
}
68+
}, notificationInterval);
5469

5570
// Wait for initial period before starting to poll
5671
await new Promise((resolve) => setTimeout(resolve, initialWaitMs));
57-
58-
// Send notification that active polling has started
59-
await context.sendNotification({
60-
method: "notifications/progress",
61-
params: {
62-
progressToken: context._meta?.progressToken ?? `lca-${testCaseId}`,
63-
message: `Half of the Low Code Automation is done, Wait for some more time...`,
64-
progress: 10,
65-
total: 100,
66-
},
67-
});
72+
clearInterval(notificationIntervalId);
6873

6974
return new Promise((resolve) => {
7075
// Set up timeout to handle max wait time
@@ -133,12 +138,16 @@ export async function pollLCAStatus(
133138
Math.floor((elapsedTime / maxWaitTimeMs) * 90) + 10,
134139
);
135140

141+
// Cycle through different numbers of dots (2, 3, 4, 5, then back to 2)
142+
const dotCount = ((Math.floor(elapsedTime / pollIntervalMs) % 4) + 2);
143+
const dots = '.'.repeat(dotCount);
144+
136145
await context.sendNotification({
137146
method: "notifications/progress",
138147
params: {
139148
progressToken:
140149
context._meta?.progressToken ?? `lca-${testCaseId}`,
141-
message: `Low Code Automation build is still in progress...`,
150+
message: `Generating Low Code Automation Test${dots}`,
142151
progress: progressPercentage,
143152
total: 100,
144153
},

0 commit comments

Comments
 (0)