-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate 'Site Title block' e2e tests to Playwright (#55704)
* Migrate 'Site Title block' e2e tests to Playwright * Remove old test files * Fix Typo Co-authored-by: Aki Hamano <[email protected]>
- Loading branch information
Showing
2 changed files
with
46 additions
and
87 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => {} ); | ||
} ); |