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

Add end to end tests for the storybook playground block editor #26184

Open
talldan opened this issue Oct 16, 2020 · 4 comments
Open

Add end to end tests for the storybook playground block editor #26184

talldan opened this issue Oct 16, 2020 · 4 comments
Labels
[Package] Block editor /packages/block-editor [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Enhancement A suggestion for improvement.

Comments

@talldan
Copy link
Contributor

talldan commented Oct 16, 2020

Is your feature request related to a problem? Please describe.
A couple of times recently bugs have been introduced in the block editor package that could've been prevented by a small suite of end to end tests:

Both issues were related to some configuration that shouldn't need to be specified but was present in the post editor, an easy mistake to make, but also easy for automated testing to catch.

We've often relied on user reports to solve these bugs, but they could be caught before introduction using end to end tests

The tests would include some basic interactions, adding/removing blocks, changing settings etc...

Potentially some of these tests could even run across multiple editors (post editor, standalone editor, FSE editor, widget, navigation) where the feature is consistent across those editors.

Describe the solution you'd like
Add e2e tests for the storybook example of the Block Editor:
https://wordpress.github.io/gutenberg/?path=/story/playground-block-editor--default

Describe alternatives you've considered
Alternatively, add a basic example within the plugin itself, similar to the demo page which has e2e tests.

@talldan talldan added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Package] Block editor /packages/block-editor labels Oct 16, 2020
@gziolo
Copy link
Member

gziolo commented Oct 31, 2020

Actually, we discussed it several times that a subset of tests could work with Storybook instance only. In particular, the block editor seems to be a perfect fit as it by definition should work more or less the same on WordPress instance, in the mobile app, in the 3rd party app like Storybook. I'm 100% on board with the idea. It should be way much easier to set everything up than for WordPress instance as you don't need Docker 😃

@talldan
Copy link
Contributor Author

talldan commented Nov 2, 2020

On other projects I've worked on similar has been achieved by setting up test suites, which have some basic configuration, something like:

{
  name: 'storybook-tests',
  tests: [
    'editor/various/adding-blocks.test.js',
    // ...,
  ],
  config: {
    EDITOR_URL: 'https://localhost:12345/?path=/story/playground-block-editor--default'
  }
}

Some challenges:

  • the storybook would need to be built and run per branch
  • Lots of assertions we've written use expect( await getEditedPostContent() ).toMatchSnapshot();, which relies on a selector that I believe is specific to the post editor. I wonder what a good alternative could be? Maybe something wp.blocks.serialize( wp.data.select( 'core/block-editor' ).getBlocks() )?

@gziolo
Copy link
Member

gziolo commented Nov 2, 2020

I personally don't like the idea of sharing test suites between different platforms. If the test can be run with Storybook only, then there is no need to repeat it using the full WordPress instance.

@gziolo
Copy link
Member

gziolo commented Nov 24, 2020

I just wanted to reshare some previous work in the same area to give a better overview of what was already explored.

@ellatrix did some very promising explorations to write e2e like tests that use Storybook to run tests related to RichText functionality:

There were also explorations to use visual testing:

We have been playing with snapshot testing for components as well, You can check #18031 where Storyshots integration with Storybook was enabled. It was removed a few months later.

@talldan talldan changed the title Add end to end tests for standalone block editor Add end to end tests for the storybook playground block editor Mar 9, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants