Skip to content

Commit

Permalink
Migrate 'Site Title block' e2e tests to Playwright (#55704)
Browse files Browse the repository at this point in the history
* Migrate 'Site Title block' e2e tests to Playwright
* Remove old test files
* Fix Typo

Co-authored-by: Aki Hamano <[email protected]>
  • Loading branch information
Mamaduka and t-hamano authored Nov 1, 2023
1 parent a262460 commit 0e88a53
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 87 deletions.
87 changes: 0 additions & 87 deletions packages/e2e-tests/specs/editor/blocks/site-title.test.js

This file was deleted.

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

test.describe( 'Site Title block', () => {
let originalSiteTitle;

test.beforeAll( async ( { requestUtils } ) => {
originalSiteTitle = ( await requestUtils.getSiteSettings() ).title;
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.updateSiteSettings( { title: originalSiteTitle } );
} );

test( 'Can edit the site title as admin', async ( {
admin,
editor,
page,
} ) => {
await admin.createNewPost();
await editor.insertBlock( { name: 'core/site-title' } );

const siteTitleBlock = editor.canvas.getByRole( 'document', {
name: 'Block: Site Title',
} );

// Update the site title
await siteTitleBlock
.getByRole( 'textbox', {
name: 'Site title text',
} )
.fill( 'New Site Title' );

await editor.publishPost();
await page.reload();

await expect( siteTitleBlock ).toBeVisible();
await expect( siteTitleBlock ).toHaveText( 'New Site Title' );
} );

// Reason: The current e2e test setup doesn't provide an easy way to switch between user roles.
// eslint-disable-next-line playwright/expect-expect
test.fixme( 'Cannot edit the site title as editor', async () => {} );
} );

0 comments on commit 0e88a53

Please sign in to comment.