Skip to content

Commit

Permalink
Add e2e test for activating themes in site editor (#60707)
Browse files Browse the repository at this point in the history
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: draganescu <andraganescu@git.wordpress.org>
  • Loading branch information
3 people committed Apr 12, 2024
1 parent 690d933 commit 360a6b8
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/e2e/specs/site-editor/activate-theme.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Activate theme', () => {
test.beforeEach( async ( { admin, page } ) => {
await admin.visitAdminPage( 'themes.php' );
await page.getByLabel( 'Live Preview Emptytheme' ).click();
} );
test.afterEach( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );
test( 'activate block theme when live previewing from sidebar save button', async ( {
admin,
page,
} ) => {
await page
.getByRole( 'button', { name: 'Activate Emptytheme' } )
.click();
await page
.getByRole( 'button', { name: 'Activate', exact: true } )
.click();
await expect(
page.getByRole( 'button', { name: 'Dismiss this notice' } )
).toContainText( 'Site updated' );
await admin.visitAdminPage( 'themes.php' );
await expect( page.getByLabel( 'Customize Emptytheme' ) ).toBeVisible();
} );
test( 'activate block theme when live previewing in edit mode', async ( {
editor,
admin,
page,
} ) => {
// Wait for the loading to complete.
await expect( page.locator( '.edit-site-canvas-loader' ) ).toHaveCount(
0
);
await editor.canvas.locator( 'body' ).click();
await page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Activate Emptytheme' } )
.click();
await page
.getByRole( 'button', { name: 'Activate', exact: true } )
.click();
await expect(
page.getByRole( 'button', { name: 'Dismiss this notice' } )
).toContainText( 'Site updated' );
await admin.visitAdminPage( 'themes.php' );
await expect( page.getByLabel( 'Customize Emptytheme' ) ).toBeVisible();
} );
} );

1 comment on commit 360a6b8

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 360a6b8.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8663534515
📝 Reported issues:

Please sign in to comment.