Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate 'site editor export' e2e tests to Playwright #56675

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions packages/e2e-tests/specs/site-editor/site-editor-export.test.js

This file was deleted.

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

test.describe( 'Site Editor Templates Export', () => {
test.beforeAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.activateTheme( 'emptytheme' ),
requestUtils.deleteAllTemplates( 'wp_template' ),
requestUtils.deleteAllTemplates( 'wp_template_part' ),
WunderBart marked this conversation as resolved.
Show resolved Hide resolved
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test( 'clicking export should download emptytheme.zip file', async ( {
admin,
page,
} ) => {
await admin.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
canvas: 'edit',
} );
await page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Options' } )
.click();

const promise = page.waitForEvent( 'download' );
await page.getByRole( 'menuitem', { name: 'Export' } ).click();
const download = await promise;
expect( download.suggestedFilename() ).toBe( 'emptytheme.zip' );
Comment on lines +33 to +36
Copy link
Member Author

Choose a reason for hiding this comment

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

I really like how easy it's to test downloads with PW.

Copy link
Member

Choose a reason for hiding this comment

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

💯, I love it.

} );
} );
Loading