@@ -74,25 +74,53 @@ export class Action {
7474 await expect ( this . page . getByRole ( 'tab' , { name : 'Code' } ) ) . toBeVisible ( ) ;
7575 }
7676
77- async runAction ( ) : Promise < void > {
77+ async runAction ( options ?: { expectedStatus ?: 'Complete' | 'Failed' ; mode ?: string } ) : Promise < void > {
78+ const { expectedStatus, mode } = options ?? { } ;
79+
7880 // Click "Run Action" button in the detail view header
7981 await this . page . getByRole ( 'button' , { name : 'Run Action' } ) . click ( ) ;
8082 // Wait for the run modal to appear
8183 const runModal = this . page . locator ( '#modal-container' ) ;
8284 await expect ( runModal ) . toBeVisible ( ) ;
85+
86+ // If a mode is specified, select it in the variant dropdown
87+ if ( mode ) {
88+ await runModal . getByRole ( 'combobox' , { name : 'mode' } ) . selectOption ( mode ) ;
89+ }
90+
8391 // Click the Run button in the modal footer
8492 await runModal . getByRole ( 'button' , { exact : true , name : 'Run' } ) . click ( ) ;
8593 // Verify we navigated to the run detail view
8694 await expect ( this . page . getByRole ( 'heading' , { name : / R u n # \d + / } ) ) . toBeVisible ( { timeout : 15000 } ) ;
95+
8796 // Wait for a terminal status (Complete or Failed) in the main content area
8897 await expect (
8998 this . page
9099 . getByRole ( 'tabpanel' )
91100 . getByRole ( 'button' , { name : `Complete ${ this . actionName } ` } )
92101 . or ( this . page . getByRole ( 'tabpanel' ) . getByRole ( 'button' , { name : `Failed ${ this . actionName } ` } ) ) ,
93- ) . toBeVisible ( {
94- timeout : 30000 ,
95- } ) ;
102+ ) . toBeVisible ( { timeout : 30000 } ) ;
103+
104+ if ( expectedStatus ) {
105+ const statusMatched = await this . page
106+ . getByRole ( 'tabpanel' )
107+ . getByRole ( 'button' , { name : `${ expectedStatus } ${ this . actionName } ` } ) ;
108+
109+ if ( ! ( await statusMatched . isVisible ( ) ) ) {
110+ if ( expectedStatus === 'Complete' ) {
111+ // If we expect success but see failure, collect and throw the error message from the UI
112+ const errorMessage = await this . page . getByTestId ( 'action-run-error-log' ) . innerText ( ) ;
113+ throw new Error (
114+ `Expected action run to have status "${ expectedStatus } " but it did not. Error message: ${ errorMessage } ` ,
115+ ) ;
116+ } else {
117+ const results = await this . page . getByTestId ( 'action-run-results' ) . innerText ( ) ;
118+ throw new Error (
119+ `Expected action run to have status "${ expectedStatus } " but it did not. Run details: ${ results } ` ,
120+ ) ;
121+ }
122+ }
123+ }
96124 }
97125
98126 async selectActionInSidebar ( ) : Promise < void > {
0 commit comments