Skip to content

Commit

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

* Add comment

* Use getSiteSettings and updateSiteSettings
  • Loading branch information
t-hamano authored Dec 26, 2023
1 parent c2a54cd commit 57fc637
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 53 deletions.

This file was deleted.

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

test.describe( 'Comments Form', () => {
let originalCommentStatus;

test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
await requestUtils.deleteAllTemplates( 'wp_template' );
} );

test.beforeEach( async ( { requestUtils } ) => {
const siteSettings = await requestUtils.getSiteSettings();
originalCommentStatus = siteSettings.default_comment_status;
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.updateSiteSettings( {
default_comment_status: originalCommentStatus,
} );
} );

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

test( 'placeholder displays in the site editor even when comments are closed by default', async ( {
admin,
editor,
} ) => {
// Navigate to "Singular" post template
await admin.visitSiteEditor( {
postId: 'emptytheme//singular',
postType: 'wp_template',
canvas: 'edit',
} );

// Insert post comments form
await editor.insertBlock( { name: 'core/post-comments-form' } );

// Ensure the placeholder is there
const postCommentsFormBlock = editor.canvas.locator(
'role=document[name="Block: Comments Form"i]'
);
await expect( postCommentsFormBlock.locator( 'form' ) ).toBeVisible();
} );
} );

1 comment on commit 57fc637

@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 57fc637.
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/7327783777
📝 Reported issues:

Please sign in to comment.