-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
4d1636a
to
41f3c11
Compare
@@ -0,0 +1,14 @@ | |||
/** | |||
* External dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left those comments for now as I'm not sure if I'll change these files soon, but will remove in a cleanup before taking this PR out of the draft state.
return codeEditor.sendKeys( Key.CONTROL + 'v' ); | ||
} | ||
|
||
async setBlocksCode( code ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore and will be removed.
); | ||
} | ||
|
||
async getBlocksCode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore and will be removed
|
||
// jetpack/layout-grid | ||
await gEditorComponent.insertLayoutGrid(); | ||
const layoutGridDisplayedInEditor = await gEditorComponent.layoutGridDisplayedInEditor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's quite a bit of repetition here and I don't like it. I'll see how to dry it up later.
6f0bdb0
to
5cc6140
Compare
856a68f
to
790bfa1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start here, this is probably ready for more final reviews? Shall we swap the in progress label?
class BlogPostsBlockComponent extends GutenbergBlockComponent {} | ||
|
||
BlogPostsBlockComponent.blockTitle = 'Blog Posts'; | ||
BlogPostsBlockComponent.blockName = 'a8c/blog-posts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems more idiomatic:
class BlogPostsBlockComponent extends GutenbergBlockComponent {} | |
BlogPostsBlockComponent.blockTitle = 'Blog Posts'; | |
BlogPostsBlockComponent.blockName = 'a8c/blog-posts'; | |
class BlogPostsBlockComponent extends GutenbergBlockComponent { | |
static blockTitle = 'Blog Posts'; | |
static blockName = 'a8c/blog-posts'; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that was the first thing I tried. Unfortunately, I got a syntax error. The tests don't go through a transpiler, so it fallbacks to what node supports, and AFAIK, it still doesn't support static
class variables yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using node 12.18.0
(the one specified in wp-calypso
's .nvmrc
):
./node_modules/.bin/mocha specs/wp-calypso-gutenberg-upgrade-spec.js
file:///home/fullofcaffeine/workspace/code/wp-calypso/test/e2e/lib/gutenberg/blocks/youtube-block-component.js:7
static blockTitle = 'Foo';
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, but it does support static getters:
class YoutubeBlockComponent extends GutenbergBlockComponent {
static get blockTitle() {
return 'foo ';
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll use static getters for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an issue with how this is configured. I believe mocha is using its own parser. In node 12.18.0 it works:
> class A {}
undefined
> class B { a='a';}
undefined
> A.a
undefined
> B.a
undefined
> new B().a
'a'
> A.a='a'
'a'
> A.a
'a'
> class C { static a = 'a' }
undefined
> C.a
'a'
Let's just leave it for this PR. It's not really relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tested it with vanilla node and saw it worked. I tried to figure out what as the culprit in mocha but couldn't find and left it aside. I'm using static getters for now.
I'd be interested to know what is the culprit here. I saw the mocha js binary and AFAIK it uses node as well. That's pretty confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,18 @@ | |||
// TODO some blocks are exported as default and some not... maybe change all of them to export as default? |
There was a problem hiding this comment.
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.
@@ -10,10 +10,6 @@ import * as driverHelper from '../../driver-helper'; | |||
import GutenbergBlockComponent from './gutenberg-block-component'; | |||
|
|||
export class ImageBlockComponent extends GutenbergBlockComponent { | |||
constructor( driver, blockID ) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
class TiledGalleryBlockComponent extends GutenbergBlockComponent { | ||
async uploadImages( filesDetails ) { | ||
const fileInput = this.driver.findElement( | ||
By.xpath( `//*[@id="${ this.blockID.slice( 1 ) }"]/div/div/div[3]/div[2]/input` ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 Oh boy… what's this targeting? Something in the media placeholder? Maybe a dedicated helper would be good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This selects the hidden file input inside the tile gallery. I've moved this to its own instance field with a more descriptive name. Let me know if you had anything else in mind.
@Automattic/good-mountain @Automattic/e2e-test-reviewers Please have a look and let me know what you think. Please do bear in mind that it might seem incomplete - the test data for most of the blocks are not being filled yet (only for two of them) - but that was a deliberate decision taken to allow us to finish the initial groundwork/exploration task earlier instead of having a big/long-running PR (this version already provides some value and we can use it to help us test the next GB version). Also, the assertion for invalid blocks has been commented out for now due to an issue in the |
311e0dd
to
ae084ab
Compare
…ed on the frontendn
- Get rid of repeat block factory methods in the GutenbergEditorComponent class; - Let the block class know about its name and title; - Change the usage of name to more closely match the semantics of the block API (name and title); - Added a step to check for errors in the editor in the edge site; - Added a step to check if all expected blocks are in the editor in the edge site;
Because of because of Automattic/jetpack#16514
…with a name that better describes it
509fec9
to
2f206ed
Compare
Rebased with #45268 merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here! 🚢
I don't see the screenshots artifacts in https://app.circleci.com/pipelines/github/Automattic/wp-e2e-tests-for-branches/36242/workflows/a894971d-692c-4e0e-9951-884404b1774c/jobs/97521/artifacts - is the plan to store them there? We can introduce that in a follow-up, it should be a small change to the CircleCI configuration. |
Hmm, thanks for pointing that out! I just assumed that by saving them to the screenshots folder, everything else would fall into place, but there might be something in CircleCI as you said. I'll take note of that. |
…ons of GB // take 2 (#45278) * Revert "Revert "Automate the testing of popular blocks in current and edge versions of GB (#45048)" (#45277)" This reverts commit 6c5580f. * Update and encrypt fixed settings Make sure it only adds the new Gutenberg upgrade account credentials and nothing else. Co-authored-by: Marcelo Serpa <marcelo.serpa@automattic.com>
Changes proposed in this Pull Request
Repeat that for the most popular themes in wpcom.
Testing instructions
./node_modules/.bin/mocha specs/wp-calypso-gutenberg-upgrade-spec.js
*[0]gutenbergUpgradeUser
. You can verify it (alongside the credentials) by decrypting the config file in this PR and looking for it in yourconfig/local-decrypted.json
file.*[0] Make sure to cd into
test/e2e
first.*[1]
test/e2e/screenshots/
TODO