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

Migrate Is Typing Test to Playwright #56616

Merged
merged 3 commits into from
Nov 29, 2023
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
101 changes: 0 additions & 101 deletions packages/e2e-tests/specs/editor/various/is-typing.test.js

This file was deleted.

63 changes: 63 additions & 0 deletions test/e2e/specs/editor/various/is-typing.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'isTyping', () => {
test.beforeEach( async ( { admin } ) => {
await admin.createNewPost();
} );

test( 'should hide the toolbar when typing', async ( { editor, page } ) => {
// Enter to reach paragraph block.
await page.keyboard.press( 'Enter' );
// Insert paragraph
await page.keyboard.type( 'Type' );

const blockToolbar = page.locator(
'role=toolbar[name="Block tools"i]'
);

// Toolbar should not be showing
await expect( blockToolbar ).toBeHidden();

// Moving the mouse shows the toolbar.
await editor.showBlockToolbar();

// Toolbar is visible.
await expect( blockToolbar ).toBeVisible();

// Typing again hides the toolbar
await page.keyboard.type( ' and continue' );

// Toolbar is hidden again
await expect( blockToolbar ).toBeHidden();
} );

test( 'should not close the dropdown when typing in it', async ( {
editor,
page,
} ) => {
// Add a block with a dropdown in the toolbar that contains an input.
await editor.insertBlock( { name: 'core/query' } );

// Tab to Start Blank Button
await page.keyboard.press( 'Tab' );
// Select the Start Blank Button
await page.keyboard.press( 'Enter' );
// Select the First variation
await page.keyboard.press( 'Enter' );
Comment on lines +44 to +49
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Should we just move this setup inside insertBlock to create the block we want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's not worth moving it to insertBlock for this case. I didn't see insertBlock accounting for other special circumstances, so I wouldn't want to change it for this instance.

// Moving the mouse shows the toolbar.
await editor.showBlockToolbar();
// Open the dropdown.
await page.getByRole( 'button', { name: 'Display settings' } ).click();

const itemsPerPageInput = page.getByLabel( 'Items per Page' );
// Make sure we're where we think we are
await expect( itemsPerPageInput ).toBeFocused();
// Type inside the dropdown's input
await page.keyboard.type( '00' );
// The input should still be visible.
await expect( itemsPerPageInput ).toBeVisible();
} );
} );
Loading