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

[E2E] Embed block fixes #45345

Merged
merged 6 commits into from
Sep 3, 2020
Merged

Conversation

fullofcaffeine
Copy link
Contributor

@fullofcaffeine fullofcaffeine commented Sep 2, 2020

Changes proposed in this Pull Request

All embed blocks (the ones touched by our E2E tests at least) now follow a similar naming/classification standard. They now all have the same ariaLabel and embed prefix for the .editor-block-list-item CSS class.

This fixes the selectors so that the elements can be found on the page.

Outstanding questions

  • Is it a good idea to have identical aria-labels for these blocks? They are all "embed" blocks, but they serve different purposes.

@matticbot
Copy link
Contributor

@fullofcaffeine fullofcaffeine added the [Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot label Sep 2, 2020
@fullofcaffeine fullofcaffeine force-pushed the fix/gb-8.9-coblocks-2.2.2-e2e branch from 87579ad to 76c1689 Compare September 2, 2020 01:06
@matticbot
Copy link
Contributor

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.

@fullofcaffeine
Copy link
Contributor Author

fullofcaffeine commented Sep 2, 2020

I don't know if it'll be enough to just change the embed blocks to be selected by the same aria-label as I've done in the first commit here. It seems to be used to select them on the page for a scenario where multiple embed blocks are present.

I'm waiting for the tests to finish, but if they continue to fail, we will need to think of another way to select each block or re-organize the scenario so that a single embed block is tested per time, in the editor.

UPDATE: Even if the tests pass, we might still need to rethink these scenarios or ask ourselves if we really want to keep the same aria-label for them.

I've looked at the three blocks in the editor, and they now have pretty much the same markup. To test, open a test edge site and add the following blocks to the page: Instagram, Twitter, and Youtube. Now, inspect their DOM structure in the Elements inspector. You'll see all of them have pretty much the same markup, with the only difference being the ID hash. Screenshot follows:

similar

@ockham
Copy link
Contributor

ockham commented Sep 2, 2020

I've looked at the three blocks in the editor, and they now have pretty much the same markup. To test, open a test edge site and add the following blocks to the page: Instagram, Twitter, and Youtube. Now, inspect their markup in the Elements inspector. You'll see all of them have pretty much the same markup, with the only difference being the ID hash.

Yeah, I remember seeing that when I was working on some oEmbeds related stuff in Gutenberg the other day. I agree that we'll probably want to differentiate more between them. This is something we'll need to address in Gutenberg though, and it likely won't make it into v8.9, so we also need a workaround for our e2e tests.

Edit: The embed block tests are actually passing, it's the tests for embedding a URL that are failing now:

The class name for all of those is wp-block-embed now (which unfortunately isn't enough to differentiate between them when we insert all of them into the same post).

@sirreal sirreal added [Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot and removed [Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot labels Sep 2, 2020
All embed blocks (the ones touched by our E2E tests at least) follow a similar naming/classification standard. They now all have the same ariaLabel and embed prefix for the .editor-block-list-item CSS class.
@fullofcaffeine fullofcaffeine changed the title [E2E] Fix ariaLabel and prefix selector components for embed blocks [E2E] Embed block fixes Sep 2, 2020
@ockham
Copy link
Contributor

ockham commented Sep 2, 2020

I think we can change those selectors to look for and <iframe />s with the title attribute set to

  • Embedded content from instagram.com,
  • Embedded content from twitter, and
  • Embedded content from youtube.com, respectively.

image

image

image

(Those are coming from https://github.com/WordPress/gutenberg/blob/a610923b7728f1192f9745a55390a7abb0df576e/packages/block-library/src/embed/embed-preview.js#L78)

@sirreal sirreal added [Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot and removed [Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot labels Sep 2, 2020
…her than a selector based off the aria-label attribute
@fullofcaffeine
Copy link
Contributor Author

fullofcaffeine commented Sep 3, 2020

I think we can change those selectors to look for and <iframe />s with the title attribute set to

* `Embedded content from instagram.com`,

* `Embedded content from twitter`, and

* `Embedded content from youtube.com`, respectively.

image

image

image

(Those are coming from https://github.com/WordPress/gutenberg/blob/a610923b7728f1192f9745a55390a7abb0df576e/packages/block-library/src/embed/embed-preview.js#L78)

I like that idea, but it seems this changeset is not part of 8.9? I couldn't find this attribute on embed blocks in a test site running 8.9. Am I missing anything?

That being said, I did start working towards this, there's some initial work I committed today. The upgrade test is still failing just when it starts the edge part of the test, possibly related to https://github.com/Automattic/wp-calypso/blob/master/test/e2e/lib/gutenberg/gutenberg-editor-component.js#L203, but I'll look tomorrow (or you can if you're feeling adventurous).

@fullofcaffeine fullofcaffeine force-pushed the fix/gb-8.9-coblocks-2.2.2-e2e branch from 76c1689 to 4a89bf1 Compare September 3, 2020 03:07
@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

Oh, I was thinking we'd need to change the selectors only in the file I was mentioning, https://github.com/Automattic/wp-calypso/blob/38b51c6665cd2029a6fe6d0eca42893e7eefcf1c/test/e2e/specs/wp-calypso-gutenberg-post-editor-spec.js. Let me see if that does the trick.

…ctors other than a selector based off the aria-label attribute"

This reverts commit 4a89bf1.
@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

Yep, that worked 🥳 The 'Click to Tweet' block seems to be the last remaining issue now.

@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

Yep, that worked The 'Click to Tweet' block seems to be the last remaining issue now.

Found the relevant screencast in test artifacts: https://98647-102822243-gh.circle-artifacts.com/2/wp-calypso/test/e2e/screenshots/videos/136-2020-09-03T11-58-44.mpg

Upon attempting to leave the editor, there's a "Leave app? Changes you made may not be saved" alert (even right after saving the post). Screengrab from the screencast:

Bildschirmfoto von 136-2020-09-03T11-58-44 mpg

Seems like dirty state detection is broken 😕

cc/ @david-szabo97 since we've recently touched the UnsavedChangesWarning component a bit (specifically: WordPress/gutenberg#24719); although the warning coming from that component reads differently 🤔

@ntsekouras
Copy link
Member

Yep, that worked 🥳 The 'Click to Tweet' block seems to be the last remaining issue now.

I don't have all the context here, but when working with the embed block variations, I used snapshots to make sure they were correct. (https://github.com/WordPress/gutenberg/blob/87c4dc536f52254975b4b5e192e36f7d98b6f0b7/packages/e2e-tests/specs/editor/various/embedding.test.js#L211)

Since @ockham found a workaround for some of the tests, if the click to edit is still a problem, another approach would be to select the tweet block with key navigation events. Would that apply here?

@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

Yep, that worked 🥳 The 'Click to Tweet' block seems to be the last remaining issue now.

I don't have all the context here, but when working with the embed block variations, I used snapshots to make sure they were correct. (https://github.com/WordPress/gutenberg/blob/87c4dc536f52254975b4b5e192e36f7d98b6f0b7/packages/e2e-tests/specs/editor/various/embedding.test.js#L211)

Since @ockham found a workaround for some of the tests, if the click to edit is still a problem, another approach would be to select the tweet block with key navigation events. Would that apply here?

Thanks Nik. A number of misunderstandings here, I'll try to clarify:

  • The problem with the embeds has been resolved (by changing e2e selectors).
  • The remaining problem is with the "Click to Tweet" block (not the Twitter embed). That block is part of the CoBlocks collection of blocks that we're running on WP.com Furthermore, the failing test is checking for the presence of the rendered block on the frontend (rather than the editor). This seems to happen because we get stuck when attempting to leave the editor because dirty state detection seems broken (see my previous comment).

@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

The reason for the "Changes you made may not be saved" warning after publishing a post that contains a "Click to Tweet" CoBlock seems to be that the block has a url attribute that contains to the current post's URL (plus that URL is also found in the block's content). If the block is inserted into a newly created post (as it is in e2e tests), that url attribute will be set to something like https:\/\/example.com\/2020\/09\/03\/auto-draft\/. If the post is saved, it will be updated to use the post's slug (which is based on the post title), e.g. https:\/\/example.com\/2020\/09\/03\/click-to-tweet-test\/.

This seems rather inherent in the way the block works. In e2e tests, we could fix it by saving the post before publishing and viewing it, so that is already given the same slug as it would get upon publishing.

@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

@ockham
Copy link
Contributor

ockham commented Sep 3, 2020

Filed upstream issue: godaddy-wordpress/coblocks#1663

@fullofcaffeine
Copy link
Contributor Author

fullofcaffeine commented Sep 3, 2020

@ockham Thanks for thoroughly documenting the issue as you worked towards fixing it ❤️

This looks good, let's 🚢 it!

@fullofcaffeine fullofcaffeine merged commit f8a2698 into master Sep 3, 2020
@fullofcaffeine fullofcaffeine deleted the fix/gb-8.9-coblocks-2.2.2-e2e branch September 3, 2020 21:40
fullofcaffeine added a commit that referenced this pull request Sep 3, 2020
fullofcaffeine added a commit that referenced this pull request Sep 3, 2020
fullofcaffeine added a commit that referenced this pull request Sep 3, 2020
fullofcaffeine added a commit that referenced this pull request Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Needs e2e Testing Gutenberg Edge Run e2e tests with a special site that is running the latest Gutenberg plugin snapshot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants