@@ -129,6 +129,20 @@ function buildTestCommand(test: TestItem, executor: string, projectName: string
129129 }
130130}
131131
132+ /**
133+ * Handle AI evaluation report display after tests complete
134+ * @param test - The test item
135+ * @param workingDirectory - The working directory where evaluation-reports are generated
136+ */
137+ async function handleAiEvaluationReport ( test : TestItem , workingDirectory : string ) : Promise < void > {
138+ if ( isAiEvaluations ( test ) ) {
139+ const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
140+ if ( reportUri ) {
141+ await openEvaluationReport ( reportUri ) ;
142+ }
143+ }
144+ }
145+
132146export async function runHandler ( request : TestRunRequest , token : CancellationToken ) {
133147 if ( ! request . include ) {
134148 return ;
@@ -208,12 +222,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
208222 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
209223
210224 reportTestResults ( run , testItems , timeElapsed , projectPath ) . then ( async ( ) => {
211- if ( isAiEvaluations ( test ) ) {
212- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
213- if ( reportUri ) {
214- await openEvaluationReport ( reportUri ) ;
215- }
216- }
225+ await handleAiEvaluationReport ( test , workingDirectory ) ;
217226 endGroup ( test , true , run ) ;
218227 } ) . catch ( ( ) => {
219228 endGroup ( test , false , run ) ;
@@ -223,12 +232,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
223232 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
224233
225234 reportTestResults ( run , testItems , timeElapsed , projectPath ) . then ( async ( ) => {
226- if ( isAiEvaluations ( test ) ) {
227- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
228- if ( reportUri ) {
229- await openEvaluationReport ( reportUri ) ;
230- }
231- }
235+ await handleAiEvaluationReport ( test , workingDirectory ) ;
232236 endGroup ( test , true , run ) ;
233237 } ) . catch ( ( ) => {
234238 endGroup ( test , false , run ) ;
@@ -254,12 +258,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
254258 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
255259
256260 reportTestResults ( run , testItems , timeElapsed , projectPath ) . then ( async ( ) => {
257- if ( isAiEvaluations ( test ) ) {
258- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
259- if ( reportUri ) {
260- await openEvaluationReport ( reportUri ) ;
261- }
262- }
261+ await handleAiEvaluationReport ( test , workingDirectory ) ;
263262 endGroup ( test , true , run ) ;
264263 } ) . catch ( ( ) => {
265264 endGroup ( test , false , run ) ;
@@ -269,12 +268,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
269268 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
270269
271270 reportTestResults ( run , testItems , timeElapsed , projectPath ) . then ( async ( ) => {
272- if ( isAiEvaluations ( test ) ) {
273- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
274- if ( reportUri ) {
275- await openEvaluationReport ( reportUri ) ;
276- }
277- }
271+ await handleAiEvaluationReport ( test , workingDirectory ) ;
278272 endGroup ( test , true , run ) ;
279273 } ) . catch ( ( ) => {
280274 endGroup ( test , false , run ) ;
@@ -301,12 +295,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
301295 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
302296
303297 reportTestResults ( run , testItems , timeElapsed , projectPath , true ) . then ( async ( ) => {
304- if ( isAiEvaluations ( test ) ) {
305- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
306- if ( reportUri ) {
307- await openEvaluationReport ( reportUri ) ;
308- }
309- }
298+ await handleAiEvaluationReport ( test , workingDirectory ) ;
310299 endGroup ( test , true , run ) ;
311300 } ) . catch ( ( ) => {
312301 endGroup ( test , false , run ) ;
@@ -316,12 +305,7 @@ export async function runHandler(request: TestRunRequest, token: CancellationTok
316305 const timeElapsed = calculateTimeElapsed ( startTime , endTime , testItems ) ;
317306
318307 reportTestResults ( run , testItems , timeElapsed , projectPath , true ) . then ( async ( ) => {
319- if ( isAiEvaluations ( test ) ) {
320- const reportUri = await findLatestEvaluationReport ( workingDirectory ) ;
321- if ( reportUri ) {
322- await openEvaluationReport ( reportUri ) ;
323- }
324- }
308+ await handleAiEvaluationReport ( test , workingDirectory ) ;
325309 endGroup ( test , true , run ) ;
326310 } ) . catch ( ( ) => {
327311 endGroup ( test , false , run ) ;
0 commit comments