Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Jul 14, 2023
1 parent c084b3d commit e3d4800
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/cypress/integration/image-processing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 );
} );
} );

0 comments on commit e3d4800

Please sign in to comment.