@@ -133,6 +133,9 @@ export class ComfyPage {
133133 // Inputs
134134 public readonly workflowUploadInput : Locator
135135
136+ // Toasts
137+ public readonly visibleToasts : Locator
138+
136139 // Components
137140 public readonly searchBox : ComfyNodeSearchBox
138141 public readonly menu : ComfyMenu
@@ -159,6 +162,8 @@ export class ComfyPage {
159162 this . resetViewButton = page . getByRole ( 'button' , { name : 'Reset View' } )
160163 this . queueButton = page . getByRole ( 'button' , { name : 'Queue Prompt' } )
161164 this . workflowUploadInput = page . locator ( '#comfy-file-input' )
165+ this . visibleToasts = page . locator ( '.p-toast-message:visible' )
166+
162167 this . searchBox = new ComfyNodeSearchBox ( page )
163168 this . menu = new ComfyMenu ( page )
164169 this . actionbar = new ComfyActionbar ( page )
@@ -397,6 +402,30 @@ export class ComfyPage {
397402 await this . nextFrame ( )
398403 }
399404
405+ async deleteWorkflow (
406+ workflowName : string ,
407+ whenMissing : 'ignoreMissing' | 'throwIfMissing' = 'ignoreMissing'
408+ ) {
409+ // Open workflows tab
410+ const { workflowsTab } = this . menu
411+ await workflowsTab . open ( )
412+
413+ // Action to take if workflow missing
414+ if ( whenMissing === 'ignoreMissing' ) {
415+ const workflows = await workflowsTab . getTopLevelSavedWorkflowNames ( )
416+ if ( ! workflows . includes ( workflowName ) ) return
417+ }
418+
419+ // Delete workflow
420+ await workflowsTab . getPersistedItem ( workflowName ) . click ( { button : 'right' } )
421+ await this . clickContextMenuItem ( 'Delete' )
422+ await this . confirmDialog . delete . click ( )
423+
424+ // Clear toast & close tab
425+ await this . closeToasts ( 1 )
426+ await workflowsTab . close ( )
427+ }
428+
400429 async resetView ( ) {
401430 if ( await this . resetViewButton . isVisible ( ) ) {
402431 await this . resetViewButton . click ( )
@@ -413,7 +442,20 @@ export class ComfyPage {
413442 }
414443
415444 async getVisibleToastCount ( ) {
416- return await this . page . locator ( '.p-toast-message:visible' ) . count ( )
445+ return await this . visibleToasts . count ( )
446+ }
447+
448+ async closeToasts ( requireCount = 0 ) {
449+ if ( requireCount ) await expect ( this . visibleToasts ) . toHaveCount ( requireCount )
450+
451+ // Clear all toasts
452+ const toastCloseButtons = await this . page
453+ . locator ( '.p-toast-close-button' )
454+ . all ( )
455+ for ( const button of toastCloseButtons ) {
456+ await button . click ( )
457+ }
458+ await expect ( this . visibleToasts ) . toHaveCount ( 0 )
417459 }
418460
419461 async clickTextEncodeNode1 ( ) {
0 commit comments