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 2 end test dynamic allowed blocks #14992

Merged
merged 4 commits into from
Apr 16, 2019

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Apr 15, 2019

Description

This PR adds a simple end 2 end test that makes sure allowed blocks inside a parent block can be changed dynamically depending on some condition e.g: the number of child's the parent contains.

How has this been tested?

We just need to make sure the test cases pass.

Related: #14515

@jorgefilipecosta jorgefilipecosta added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P labels Apr 15, 2019
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

I proposed a different name for the lists of allowed blocks. It took me some time to understand why there are two arrays with 2 blocks where one of the constants says less than two :)

@jorgefilipecosta jorgefilipecosta force-pushed the add/end-2-end-test-dynamic-allowed-blocks branch from 07ac66f to 531ce2c Compare April 16, 2019 10:45
@jorgefilipecosta jorgefilipecosta force-pushed the add/end-2-end-test-dynamic-allowed-blocks branch from 531ce2c to aaf962b Compare April 16, 2019 12:56
@jorgefilipecosta jorgefilipecosta merged commit b080acc into master Apr 16, 2019
@jorgefilipecosta jorgefilipecosta deleted the add/end-2-end-test-dynamic-allowed-blocks branch April 16, 2019 13:37
@youknowriad youknowriad added this to the 5.6 (Gutenberg) milestone May 13, 2019
@aduth
Copy link
Member

aduth commented Jan 20, 2020

I see this test fail intermittently. Do you have any idea why that might be?

I wonder if there might be some issue of race condition where the dynamic changes to the allowed blocks does not update synchronously. I sense this could happen based on how a lot of InnerBlocks implementation relies on synchronizing after some update.

Otherwise, do you have any thoughts on how we could improve the stability of this test? Ideally it's something where we should be able to rely on these changes taking effect immediately, but at worst we could try to update the test to "wait for" some indication that it's been applied.

   ✕ correctly applies dynamic allowed blocks restrictions (3238ms)
  ● Allowed Blocks Setting on InnerBlocks  › correctly applies dynamic allowed blocks restrictions
    expect(received).toEqual(expected)
    Difference:
    - Expected
    + Received
      Array [
    -   "Gallery",
    -   "Video",
    +   "Image",
    +   "List",
      ]
      81 | 		expect(
      82 | 			await getAllBlockInserterItemTitles()
    > 83 | 		).toEqual( [
         | 		  ^
      84 | 			'Gallery',
      85 | 			'Video',
      86 | 		] );
      at Object.toEqual (specs/editor/plugins/inner-blocks-allowed-blocks.test.js:83:5)
          at runMicrotasks (<anonymous>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [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.

4 participants