From e3d480099fb5db40bd3382891d4123a9d62e6771 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Fri, 14 Jul 2023 13:54:22 -0600 Subject: [PATCH] Add tests --- .../integration/image-processing.test.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/image-processing.test.js b/tests/cypress/integration/image-processing.test.js index ffcf40ecc..854f6b4a7 100644 --- a/tests/cypress/integration/image-processing.test.js +++ b/tests/cypress/integration/image-processing.test.js @@ -193,6 +193,10 @@ describe('Image processing Tests', () => { cy.get( '#enable_image_gen' ).uncheck(); cy.get( '#submit' ).click(); + cy.get( + `.wp-has-current-submenu.wp-menu-open li a:contains("Generate Images")` + ).should( 'not.exist' ); + // Create test post. cy.createPost( { title: 'Test DALL-E post disabled', @@ -241,6 +245,10 @@ describe('Image processing Tests', () => { cy.get( '#openai_dalle_roles_administrator' ).uncheck(); cy.get( '#submit' ).click(); + cy.get( + `.wp-has-current-submenu.wp-menu-open li a:contains("Generate Images")` + ).should( 'not.exist' ); + // Create test post. cy.createPost( { title: 'Test DALL-E post admin disabled', @@ -279,4 +287,30 @@ describe('Image processing Tests', () => { cy.get( '#menu-item-generate' ).should( 'not.exist' ); } ); } ); -}); + + it( 'Can generate image directly in media library', () => { + cy.visit( + '/wp-admin/tools.php?page=classifai&tab=image_processing&provider=openai_dalle' + ); + + cy.get( '#enable_image_gen' ).check(); + cy.get( '#openai_dalle_roles_administrator' ).check(); + cy.get( '#submit' ).click(); + + cy.visit( '/wp-admin/upload.php' ); + cy.get( + `.wp-has-current-submenu.wp-menu-open li a:contains("Generate Images")` + ).click(); + + // Verify tab exists. + cy.get( '#menu-item-generate' ).should( 'exist' ); + + // Click into the tab and submit a prompt. + cy.get( '#menu-item-generate' ).click(); + cy.get( '.prompt-view .prompt' ).type( 'A sunset over the mountains' ); + cy.get( '.prompt-view .button-generate' ).click(); + + // Verify images show up. + cy.get( '.generated-images ul li' ).should( 'have.length', 2 ); + } ); +} );