@@ -19,10 +19,12 @@ import {
1919 setupNonTrackingOrgAndAuth ,
2020 setupNetworkMonitoring ,
2121 validateNoCriticalErrors ,
22+ verifyCommandExists ,
2223 waitForOutputChannelText ,
2324 waitForRunApexTestsProgressNotificationGone
2425} from '@salesforce/playwright-vscode-ext' ;
2526
27+ import packageNls from '../../../package.nls.json' ;
2628import { test } from '../fixtures' ;
2729import { TEST_RUN_TIMEOUT } from '../constants' ;
2830import { CMD_TOGGLE_MAXIMIZED_PANEL } from '../helpers/testExplorerHelpers' ;
@@ -105,6 +107,67 @@ import { CMD_TOGGLE_MAXIMIZED_PANEL } from '../helpers/testExplorerHelpers';
105107 await waitForOutputChannelText ( page , { expectedText : `${ testClassName } .validateSayHello Pass` } ) ;
106108 await waitForOutputChannelText ( page , { expectedText : 'Ended SFDX: Run Apex Tests' } ) ;
107109 await saveScreenshot ( page , 'step.run-single.done.png' ) ;
110+ // Restore panel before next step
111+ await executeCommandWithCommandPalette ( page , CMD_TOGGLE_MAXIMIZED_PANEL ) ;
112+ } ) ;
113+
114+ // The Run All Tests / Run Test code lenses above populated the class/method re-run caches,
115+ // so the "Re-Run Last Run …" palette commands are now reachable. (These commands cache only
116+ // via the code-lens entrypoints, hence this desktop-only spec is their only happy-path home.)
117+ await test . step ( 'clear output before Re-Run Last Run Apex Test Class' , async ( ) => {
118+ await ensureOutputPanelOpen ( page ) ;
119+ await selectOutputChannel ( page , 'Apex Testing' ) ;
120+ await clearOutputChannel ( page ) ;
121+ } ) ;
122+
123+ await test . step ( 're-run last test class via command palette' , async ( ) => {
124+ // sf:has_cached_test_class is set via async setContext after the code-lens run; wait for the
125+ // when-gated command to appear before invoking it.
126+ await verifyCommandExists ( page , packageNls . apex_test_last_class_run_text ) ;
127+ await executeCommandWithCommandPalette ( page , packageNls . apex_test_last_class_run_text ) ;
128+ await saveScreenshot ( page , 'step.rerun-last-class.after-command.png' ) ;
129+ } ) ;
130+
131+ await test . step ( 'verify Re-Run Last Run Apex Test Class output' , async ( ) => {
132+ await waitForRunApexTestsProgressNotificationGone ( page , { timeout : TEST_RUN_TIMEOUT } ) ;
133+ await ensureOutputPanelOpen ( page ) ;
134+ await selectOutputChannel ( page , 'Apex Testing' ) ;
135+ await executeCommandWithCommandPalette ( page , CMD_TOGGLE_MAXIMIZED_PANEL ) ;
136+ await waitForOutputChannelText ( page , { expectedText : '=== Test Summary' , timeout : TEST_RUN_TIMEOUT } ) ;
137+ await waitForOutputChannelText ( page , { expectedText : 'Outcome Passed' } ) ;
138+ await waitForOutputChannelText ( page , { expectedText : 'Tests Ran 1' } ) ;
139+ await waitForOutputChannelText ( page , { expectedText : `${ testClassName } .validateSayHello Pass` } ) ;
140+ await waitForOutputChannelText ( page , { expectedText : 'Ended SFDX: Run Apex Tests' } ) ;
141+ await saveScreenshot ( page , 'step.rerun-last-class.done.png' ) ;
142+ // Restore panel before next step
143+ await executeCommandWithCommandPalette ( page , CMD_TOGGLE_MAXIMIZED_PANEL ) ;
144+ } ) ;
145+
146+ await test . step ( 'clear output before Re-Run Last Run Apex Test Method' , async ( ) => {
147+ await ensureOutputPanelOpen ( page ) ;
148+ await selectOutputChannel ( page , 'Apex Testing' ) ;
149+ await clearOutputChannel ( page ) ;
150+ } ) ;
151+
152+ await test . step ( 're-run last test method via command palette' , async ( ) => {
153+ // sf:has_cached_test_method is set via async setContext after the code-lens run; wait for the
154+ // when-gated command to appear before invoking it.
155+ await verifyCommandExists ( page , packageNls . apex_test_last_method_run_text ) ;
156+ await executeCommandWithCommandPalette ( page , packageNls . apex_test_last_method_run_text ) ;
157+ await saveScreenshot ( page , 'step.rerun-last-method.after-command.png' ) ;
158+ } ) ;
159+
160+ await test . step ( 'verify Re-Run Last Run Apex Test Method output' , async ( ) => {
161+ await waitForRunApexTestsProgressNotificationGone ( page , { timeout : TEST_RUN_TIMEOUT } ) ;
162+ await ensureOutputPanelOpen ( page ) ;
163+ await selectOutputChannel ( page , 'Apex Testing' ) ;
164+ await executeCommandWithCommandPalette ( page , CMD_TOGGLE_MAXIMIZED_PANEL ) ;
165+ await waitForOutputChannelText ( page , { expectedText : '=== Test Summary' , timeout : TEST_RUN_TIMEOUT } ) ;
166+ await waitForOutputChannelText ( page , { expectedText : 'Outcome Passed' } ) ;
167+ await waitForOutputChannelText ( page , { expectedText : 'Tests Ran 1' } ) ;
168+ await waitForOutputChannelText ( page , { expectedText : `${ testClassName } .validateSayHello Pass` } ) ;
169+ await waitForOutputChannelText ( page , { expectedText : 'Ended SFDX: Run Apex Tests' } ) ;
170+ await saveScreenshot ( page , 'step.rerun-last-method.done.png' ) ;
108171 } ) ;
109172
110173 await validateNoCriticalErrors ( test , consoleErrors , networkErrors ) ;
0 commit comments