Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GBonWPCOM e2e tests i0] Setup and fill-in the Slidehow and Gallery Masonry block with sample images #45799

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/e2e/lib/gutenberg/blocks/gallery-masonry-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ class GalleryMasonryBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Masonry';
static blockName = 'coblocks/gallery-masonry';
static blockFrontendSelector = By.css( '.entry-content .wp-block-coblocks-gallery-masonry' );

/**
* Uploads images to the gallery.
*
* NOTE/TODO This is common to a few gallery-like blocks. DRY it using a mixin or common base class.
*
* @param {{imageName: string, fileName: string, file: string}} filesDetails a list of fileDetails
*/
async uploadImages( filesDetails ) {
const fileInputSelector = By.css( `div[id="${ this.blockID.slice( 1 ) }"] input[type=file]` );
WunderBart marked this conversation as resolved.
Show resolved Hide resolved

const fileInput = this.driver.findElement( fileInputSelector );

const files = filesDetails.map( ( f ) => f.file ).join( '\n ' );

fileInput.sendKeys( files );
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
}
}

export { GalleryMasonryBlockComponent };
15 changes: 15 additions & 0 deletions test/e2e/lib/gutenberg/blocks/slideshow-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ class SlideshowBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Slideshow';
static blockName = 'jetpack/slideshow';
static blockFrontendSelector = By.css( '.entry-content .wp-block-jetpack-slideshow' );

/**
* Uploads images to the slideshow.
*
* @param {{imageName: string, fileName: string, file: string}} filesDetails a list of fileDetails
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
*/
async uploadImages( filesDetails ) {
const fileInputSelector = By.css( `div[id="${ this.blockID.slice( 1 ) }"] input[type=file]` );
WunderBart marked this conversation as resolved.
Show resolved Hide resolved

const fileInput = this.driver.findElement( fileInputSelector );

const files = filesDetails.map( ( f ) => f.file ).join( '\n ' );

fileInput.sendKeys( files );
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
}
}

export { SlideshowBlockComponent };
15 changes: 10 additions & 5 deletions test/e2e/lib/gutenberg/blocks/tiled-gallery-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ class TiledGalleryBlockComponent extends GutenbergBlockComponent {
static blockName = 'jetpack/tiled-gallery';
static blockFrontendSelector = By.css( '.entry-content .wp-block-jetpack-tiled-gallery' );

fileInputSelector = By.xpath(
`//*[@id="${ this.blockID.slice( 1 ) }"]/div/div/div[3]/div[2]/input`
);

/**
* Uploads images to the gallery.
*
* @param {{imageName: string, fileName: string, file: string}} filesDetails a list of fileDetails
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
*/
async uploadImages( filesDetails ) {
const fileInput = this.driver.findElement( this.fileInputSelector );
const fileInputSelector = By.xpath(
`//*[@id="${ this.blockID.slice( 1 ) }"]/div/div/div[3]/div[2]/input`
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
);

const fileInput = this.driver.findElement( fileInputSelector );

const files = filesDetails.map( ( f ) => f.file ).join( '\n ' );

Expand Down
4 changes: 3 additions & 1 deletion test/e2e/specs/wp-calypso-gutenberg-upgrade-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const blockInits = new Map()
.set( YoutubeBlockComponent, ( block ) =>
block.embed( 'https://www.youtube.com/watch?v=FhMO5QnRNvo' )
)
.set( DynamicSeparatorBlockComponent, ( block ) => block.resizeBy( 150 ) );
.set( DynamicSeparatorBlockComponent, ( block ) => block.resizeBy( 150 ) )
.set( SlideshowBlockComponent, ( block ) => block.uploadImages( sampleImages ) )
.set( GalleryMasonryBlockComponent, ( block ) => block.uploadImages( sampleImages ) );

/**
* Wrapper that provides an uniform API for creating blocks on the page. It uses the `inits`
Expand Down