Commit 9db20eea761 for woocommerce

commit 9db20eea761f4e15e3357543916850d0e222907b
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date:   Mon Sep 14 11:24:35 2026 +0300

    [tests] Make the post comments E2E spec own the post it tests (#68652)

    test(e2e): Own the post comments fixture

    The WordPress post comments spec navigated to `hello-world/` and
    asserted the heading `Hello world!`. It never created that post. It
    relied on WordPress's default first post still existing, still being
    published, still having comments open, and still being called what a
    fresh install calls it.

    In this repository's shared E2E environment that post is gone. Listing
    posts there returns exactly one, and it is not the default:

        ID  post_title                post_name                 post_status  comment_status
        55  Product Collection block  product-collection-block  publish      open

    So trunk's copy of this spec fails here, at the heading assertion,
    before it ever reaches the comment form. I did not establish which
    part of the suite removes the default post, only that it is absent.

    The spec now creates its own post through the REST API with a unique
    slug, asserts against that post's own title, and deletes it in
    afterAll. That closes the post-existence dependency: the slug it
    navigates to, the title it asserts, the published status and comments
    being open are now all set by the spec.

    It does not make the spec hermetic, and the difference is worth
    keeping straight. It still depends on the shared customer storage
    state, on the active theme rendering a comment form, and on the site's
    discussion settings not holding the comment for moderation. Those were
    unowned before this change and remain unowned after it.

    No coverage moves between layers. One browser title before, one
    after. Every assertion about the comment form itself is unchanged;
    only the heading's target moved, because the post did.

    One thing for later: `fixtures.ts` already exposes a `testPost`
    fixture that generates a title and slug with the shared `random()`
    helper and cleans up by slug, used by `create-post.spec.ts` in this
    same folder. It yields a name rather than creating a post, so it is
    not a drop-in here, but the slug generation and teardown this spec
    hand-rolls could be folded into it.

    Carries the mega-branch commit:
    - de21a3d550 fix(e2e): own the post comments fixture

    Refs TESTOPS-288
    Refs #68046

    Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/testops-288-post-comments-fixture b/plugins/woocommerce/changelog/testops-288-post-comments-fixture
new file mode 100644
index 00000000000..18a2923edca
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-288-post-comments-fixture
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: The WordPress post comments E2E spec now creates and deletes its own post instead of relying on the default Hello world post, which no longer exists in the shared E2E environment.
+
diff --git a/plugins/woocommerce/tests/e2e/tests/wp-core/post-comments.spec.ts b/plugins/woocommerce/tests/e2e/tests/wp-core/post-comments.spec.ts
index ca2fcce375d..e4579815cdd 100644
--- a/plugins/woocommerce/tests/e2e/tests/wp-core/post-comments.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/wp-core/post-comments.spec.ts
@@ -13,7 +13,18 @@ const test = baseTest.extend( {
 	storageState: CUSTOMER_STATE_PATH,
 } );

+const postSlug = `comment-test-${ Date.now() }`;
+let postId: number;
+
 test.beforeAll( async ( { restApi } ) => {
+	const createPostResponse = await restApi.post( `${ WP_API_PATH }/posts`, {
+		title: 'Comment test post',
+		slug: postSlug,
+		status: 'publish',
+		comment_status: 'open',
+	} );
+	postId = createPostResponse.data.id;
+
 	// Jetpack Comments replaces the default WordPress comment form when activated, and will cause this test to fail.
 	// Make sure it's disabled prior to running this test.
 	await test.step( 'disable Jetpack comments if Jetpack is installed and active', async () => {
@@ -43,15 +54,26 @@ test.beforeAll( async ( { restApi } ) => {
 	} );
 } );

+test.afterAll( async ( { restApi } ) => {
+	if ( postId ) {
+		await restApi.delete( `${ WP_API_PATH }/posts/${ postId }`, {
+			force: true,
+		} );
+	}
+} );
+
 test(
 	'logged-in customer can comment on a post',
 	{
 		tag: [ tags.WP_CORE ],
 	},
 	async ( { page } ) => {
-		await page.goto( 'hello-world/' );
+		await page.goto( `${ postSlug }/` );
 		await expect(
-			page.getByRole( 'heading', { name: 'Hello world!', exact: true } )
+			page.getByRole( 'heading', {
+				name: 'Comment test post',
+				exact: true,
+			} )
 		).toBeVisible();

 		await expect( page.getByText( `Logged in as` ) ).toBeVisible();