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

Zoom Out: Hide inserters behind the experiment flag #61866

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/block-editor/src/components/block-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ export default function BlockTools( {
name="__unstable-block-tools-after"
ref={ blockToolbarAfterRef }
/>
{ isZoomOutMode && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
) }
{ window.__experimentalEnableZoomedOutPatternsTab &&
Copy link
Member

Choose a reason for hiding this comment

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

Is this how all experiments work? I don't love the window global 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's how we do it elsewhere.

isZoomOutMode && (
<ZoomOutModeInserters
__unstableContentRef={ __unstableContentRef }
/>
) }
</InsertionPointOpenRef.Provider>
</div>
);
Expand Down
22 changes: 21 additions & 1 deletion test/e2e/specs/site-editor/zoom-out.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@
await requestUtils.activateTheme( 'emptytheme' );
} );

test.beforeEach( async ( { admin, editor } ) => {
test.beforeEach( async ( { admin, editor, page } ) => {
await admin.visitAdminPage( 'admin.php', 'page=gutenberg-experiments' );

const zoomedOutCheckbox = page.getByLabel(
'Enable zoomed out view when selecting a pattern category in the main inserter.'
);

await zoomedOutCheckbox.setChecked( true );
await expect( zoomedOutCheckbox ).toBeChecked();
await page.getByRole( 'button', { name: 'Save Changes' } ).click();

await admin.visitSiteEditor();
await editor.canvas.locator( 'body' ).click();
} );

test.afterEach( async ( { admin, page } ) => {
await admin.visitAdminPage( 'admin.php', 'page=gutenberg-experiments' );
const zoomedOutCheckbox = page.getByLabel(
'Enable zoomed out view when selecting a pattern category in the main inserter.'
);
await zoomedOutCheckbox.setChecked( false );
await expect( zoomedOutCheckbox ).not.toBeChecked();
await page.getByRole( 'button', { name: 'Save Changes' } ).click();
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );
Expand All @@ -32,7 +52,7 @@

await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 3 );
await page.getByLabel( 'Add pattern' ).first().click();
await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 2 );

Check failure on line 55 in test/e2e/specs/site-editor/zoom-out.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › site-editor/zoom-out.spec.js:40:2 › Zoom Out › Clicking on inserter while on zoom-out should open the patterns tab on the inserter

1) [chromium] › site-editor/zoom-out.spec.js:40:2 › Zoom Out › Clicking on inserter while on zoom-out should open the patterns tab on the inserter Error: Timed out 5000ms waiting for expect(locator).toHaveCount(expected) Locator: getByLabel('Add pattern') Expected: 2 Received: 0 Call log: - expect.toHaveCount with timeout 5000ms - waiting for getByLabel('Add pattern') - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" - locator resolved to 0 elements - unexpected value "0" 53 | await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 3 ); 54 | await page.getByLabel( 'Add pattern' ).first().click(); > 55 | await expect( page.getByLabel( 'Add pattern' ) ).toHaveCount( 2 ); | ^ 56 | 57 | await expect( 58 | page at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/zoom-out.spec.js:55:52

await expect(
page
Expand Down
Loading