Skip to content

Commit

Permalink
Migrate Is Typing Test to Playwright (#56616)
Browse files Browse the repository at this point in the history
To simplify, the the test method for typing in dropdowns from a toolbar was switched to use an existing block with a dropdown rather than add a dropdown with an input to the toolbar manually.
  • Loading branch information
jeryj authored Nov 29, 2023
1 parent f7d2103 commit e07956d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 101 deletions.
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' );
// 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();
} );
} );

0 comments on commit e07956d

Please sign in to comment.