Skip to content

Commit

Permalink
Migrate 'preferences' e2e tests to Playwright (#57446)
Browse files Browse the repository at this point in the history
* Migrate 'preferences' e2e tests to Playwright

* Remove old test file

Co-authored-by: Pooja Killekar <41000648+pooja-muchandikar@users.noreply.github.com>

---------

Co-authored-by: Pooja Killekar <41000648+pooja-muchandikar@users.noreply.github.com>
  • Loading branch information
Mamaduka and pooja-muchandikar committed Dec 30, 2023
1 parent 63a6321 commit fc36077
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 62 deletions.
62 changes: 0 additions & 62 deletions packages/e2e-tests/specs/editor/various/preferences.test.js

This file was deleted.

50 changes: 50 additions & 0 deletions test/e2e/specs/editor/various/preferences.spec.js
@@ -0,0 +1,50 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

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

test( 'remembers sidebar dismissal between sessions', async ( {
editor,
page,
} ) => {
await editor.openDocumentSettingsSidebar();

const editorSettings = page.getByRole( 'region', {
name: 'Editor settings',
} );
const activeTab = editorSettings.getByRole( 'tab', { selected: true } );

// Open by default.
await expect( activeTab ).toHaveText( 'Post' );

// Change to "Block" tab.
await editorSettings.getByRole( 'tab', { name: 'Block' } ).click();
await expect( activeTab ).toHaveText( 'Block' );

/**
* Regression test: Reload resets to document tab.
*
* See: https://github.com/WordPress/gutenberg/issues/6377
* See: https://github.com/WordPress/gutenberg/pull/8995
*/
await page.reload();
await expect( activeTab ).toHaveText( 'Post' );

// Dismiss.
await editorSettings
.getByRole( 'button', {
name: 'Close Settings',
} )
.click();
await expect( activeTab ).toBeHidden();

// Remember after reload.
await page.reload();
await expect( activeTab ).toBeHidden();
} );
} );

0 comments on commit fc36077

Please sign in to comment.