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

Automate the testing of popular blocks in current and edge versions of GB #45048

Merged
merged 18 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
0beed60
Automate the testing of popular blocks in current and edge versions o…
fullofcaffeine Aug 17, 2020
565f67d
Take screenshots
fullofcaffeine Aug 21, 2020
36e202c
Improve code a bit and group sshots in a directory named after the site
fullofcaffeine Aug 25, 2020
13cd9f1
Simplified the assertions by DRYing it in a single re-usable function
fullofcaffeine Aug 25, 2020
0c149b2
Update config with the new test account credentials
fullofcaffeine Aug 25, 2020
08d17d7
Cleanup
fullofcaffeine Aug 25, 2020
b9ea585
Take screenshot of editor blocks and preview for edge sites too
fullofcaffeine Aug 25, 2020
8b3c9ba
Step description improvement
fullofcaffeine Aug 25, 2020
a999037
Use the published page instead of the preview to check content render…
fullofcaffeine Aug 26, 2020
d922a96
Fix code editor text area not being found in headless mode
fullofcaffeine Aug 26, 2020
539728e
Reduce repetition and some other minor improvements
fullofcaffeine Aug 27, 2020
1c52a2d
Use static getters to define block name and title in the test block c…
fullofcaffeine Aug 27, 2020
4ae8d71
Close the tools and options menu after using to avoid it getting on t…
fullofcaffeine Aug 27, 2020
685b7f5
Added check for invalid blocks and grouped other common steps in a re…
fullofcaffeine Aug 28, 2020
fe36a72
Comment-out the invalid block assertion temporarily
fullofcaffeine Aug 28, 2020
6d1857d
Move the file selector for the TiledGalleryBlockComponent to a field …
fullofcaffeine Aug 28, 2020
0044d6a
Simplify a bit more and be explicit about the editor checks
fullofcaffeine Aug 28, 2020
2f206ed
Use static properties for block{Name,Title}
sirreal Aug 28, 2020
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
Binary file modified test/e2e/config/encrypted.enc
Binary file not shown.
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/blog-posts-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class BlogPostsBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Blog Posts';
static blockName = 'a8c/blog-posts';
}

export { BlogPostsBlockComponent };
14 changes: 9 additions & 5 deletions test/e2e/lib/gutenberg/blocks/contact-form-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { By } from 'selenium-webdriver';
import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export class ContactFormBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
super( driver, blockID );
}
class ContactFormBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Form';
static blockName = 'jetpack/contact-form';

async _postInit() {
return await driverHelper.clickWhenClickable( this.driver, By.css( '.components-button.block-editor-block-variation-picker__variation' ) );
return await driverHelper.clickWhenClickable(
this.driver,
By.css( '.components-button.block-editor-block-variation-picker__variation' )
);
}

async openEditSettings() {
Expand Down Expand Up @@ -50,3 +52,5 @@ export class ContactFormBlockComponent extends GutenbergBlockComponent {
);
}
}

export { ContactFormBlockComponent };
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/contact-info-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class ContactInfoBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Contact Info';
static blockName = 'jetpack/contact-info';
}

export { ContactInfoBlockComponent };
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/dynamic-separator-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class DynamicSeparatorBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Dynamic HR';
static blockName = 'coblocks/dynamic-separator';
}

export { DynamicSeparatorBlockComponent };
4 changes: 0 additions & 4 deletions test/e2e/lib/gutenberg/blocks/embeds-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export default class EmbedsBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
super( driver, blockID );
}

async embedUrl( url ) {
await driverHelper.setWhenSettable(
this.driver,
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/gallery-masonry-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class GalleryMasonryBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Masonry';
static blockName = 'coblocks/gallery-masonry';
}

export { GalleryMasonryBlockComponent };
4 changes: 0 additions & 4 deletions test/e2e/lib/gutenberg/blocks/image-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export class ImageBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cleanup is nice, but it distracts from the focus on this PR. There's a lot of cleanup like this that we can probably do in a few tiny, focused PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy that 👍🏻 , I'll keep that in mind.

super( driver, blockID );
}

async uploadImage( fileDetails ) {
await driverHelper.waitTillPresentAndDisplayed(
this.driver,
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/lib/gutenberg/blocks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// TODO some blocks are exported as default and some not... maybe change all of them to export as default?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency is likely the best approach. Maybe in another PR we change them all to use one or the other.

Slight preference from me for named exports here.

export { BlogPostsBlockComponent } from './blog-posts-block-component';
export { ContactFormBlockComponent } from './contact-form-block-component';
export { ContactInfoBlockComponent } from './contact-info-block-component';
export { DynamicSeparatorBlockComponent } from './dynamic-separator-block-component';
export { GalleryMasonryBlockComponent } from './gallery-masonry-block-component';
export { ImageBlockComponent } from './image-block-component';
export { LayoutGridBlockComponent } from './layout-grid-block-component';
export { RatingStarBlockComponent } from './rating-star-block-component';
export { ShortcodeBlockComponent } from './shortcode-block-component';
export { SlideshowBlockComponent } from './slideshow-block-component';
export { SubscriptionsBlockComponent } from './subscriptions-block-component';
export { TiledGalleryBlockComponent } from './tiled-gallery-block-component';
export { YoutubeBlockComponent } from './youtube-block-component';
export { default as EmbedsBlockComponent } from './embeds-block-component';
export { default as GutenbergBlockComponent } from './gutenberg-block-component';
export { default as MarkdownBlockComponent } from './markdown-block-component';
export { default as SimplePaymentBlockComponent } from './payment-block-component';
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/layout-grid-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class LayoutGridBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Layout Grid';
static blockName = 'jetpack/layout-grid';
}

export { LayoutGridBlockComponent };
4 changes: 0 additions & 4 deletions test/e2e/lib/gutenberg/blocks/markdown-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export default class MarkdownBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
super( driver, blockID );
}

async setContent( content ) {
const inputSelector = By.css( `${ this.blockID } textarea.wp-block-jetpack-markdown__editor` );

Expand Down
4 changes: 0 additions & 4 deletions test/e2e/lib/gutenberg/blocks/payment-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export default class SimplePaymentsBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
super( driver, blockID );
}

async insertPaymentButtonDetails( {
title = 'Button',
description = 'Description',
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/rating-star-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class RatingStarBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Star Rating';
static blockName = 'jetpack/rating-star';
}

export { RatingStarBlockComponent };
4 changes: 0 additions & 4 deletions test/e2e/lib/gutenberg/blocks/shortcode-block-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import * as driverHelper from '../../driver-helper';
import GutenbergBlockComponent from './gutenberg-block-component';

export class ShortcodeBlockComponent extends GutenbergBlockComponent {
constructor( driver, blockID ) {
super( driver, blockID );
}

async enterShortcode( shortcode ) {
const shortcodeSelector = By.css( 'textarea.editor-plain-text' );
await driverHelper.waitTillPresentAndDisplayed( this.driver, shortcodeSelector );
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/slideshow-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class SlideshowBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Slideshow';
static blockName = 'jetpack/slideshow';
}

export { SlideshowBlockComponent };
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/subscriptions-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class SubscriptionsBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Subscription Form';
static blockName = 'jetpack/subscriptions';
}

export { SubscriptionsBlockComponent };
28 changes: 28 additions & 0 deletions test/e2e/lib/gutenberg/blocks/tiled-gallery-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* External dependencies
*/
import { By } from 'selenium-webdriver';

/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class TiledGalleryBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'Tiled Gallery';
static blockName = 'jetpack/tiled-gallery';

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

async uploadImages( filesDetails ) {
const fileInput = this.driver.findElement( this.fileInputSelector );

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

fileInput.sendKeys( files );
}
}

export { TiledGalleryBlockComponent };
11 changes: 11 additions & 0 deletions test/e2e/lib/gutenberg/blocks/youtube-block-component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Internal dependencies
*/
import GutenbergBlockComponent from './gutenberg-block-component';

class YoutubeBlockComponent extends GutenbergBlockComponent {
static blockTitle = 'YouTube';
static blockName = 'core-embed/youtube';
}

export { YoutubeBlockComponent };
Loading