Skip to content

Conversation

@himanshupathak95
Copy link
Contributor

What?

Closes #36825

Adds E2E test coverage for Navigation block fallback behavior, ensuring the navigation block falls back appropriately when no menus exist and uses the first non-empty menu as a fallback.

Why?

In #36740, functionality was added to provide fallback behavior for the Navigation block, determining what users see when there are no menus or when menus become unavailable. This PR adds dedicated test coverage to ensure this new fallback behavior remains stable and works as expected.

How?

Added two new E2E tests in the navigation.spec.js file:

  • Tests that the block falls back to a Page List when no menus exist
  • Tests that the block uses the first non-empty menu as a fallback

Testing Instructions

  • Run
npm run test:e2e -- editor/blocks/navigation.spec.js
  • Verify that all tests pass

To manually verify the behavior:

  • Create a new post
  • Insert a Navigation block with no menus present - should show Page List
  • Create a menu with content and insert a Navigation block - should show menu-content

@github-actions
Copy link

github-actions bot commented Feb 11, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: getdave <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Block] Navigation Affects the Navigation Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. and removed [Type] Code Quality Issues or PRs that relate to code quality labels Feb 14, 2025
@himanshupathak95 himanshupathak95 force-pushed the add/36825-e2e-test-navigation-block-fallback branch from 74852b3 to 9106f32 Compare May 23, 2025 08:36
@himanshupathak95
Copy link
Contributor Author

Hi @t-hamano, I'd like you to please review this PR at your convenience and let me know if it meets your approval. Thanks.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

If I understand correctly, the fallback behavior is for the frontend, NOT for the editor. In the editor, the Navigation block should always be empty. Furthermore, some assumptions seem incorrect.

Let's take a deeper look at the description in #36740 and organize what and how to test:

Testing

  • Open Site Editor.
  • Remove any existing Nav block.
  • Add Nav block from scratch. Don't add any items!
  • Save your empty Nav block and publish the post.
  • Go to front of site.
  • See that the first of your Navigation Menus is rendered by default even though no Menu has been selected.
  • Remove all of the items from the Navigation Post that is currently being used as the fallback - this should make it ineligible to be used as a fallback.
  • Go to front of site. Check that a different Navigation Post is being used as a fallback.
  • Remove all your Navigation Posts - that's right, ditch them all!
  • Go to front of site. Check that it falls back to the Page List.

@t-hamano
Copy link
Contributor

I looked into this issue again, but I didn't fully understand what the expected behavior of the fallback is in the frontend.

It might be a good idea to discuss what kind of tests are needed before moving forward with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Navigation Affects the Navigation Block [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add e2e test to cover Nav block front end fallbacks

2 participants