From 72778ce6b28f2d515475479c7063ad66ebdd5d49 Mon Sep 17 00:00:00 2001
From: Adam Bramley <adam.bramley@previousnext.com.au>
Date: Wed, 5 Mar 2025 12:17:56 +1100
Subject: [PATCH 1/2] Fix NodeCreationTest::testAuthorAutocomplete

---
 .../node/tests/src/Functional/NodeCreationTest.php       | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php
index ed151d7cd882..01acd86110de 100644
--- a/core/modules/node/tests/src/Functional/NodeCreationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php
@@ -261,27 +261,26 @@ public function testAuthoredDate(): void {
    */
   public function testAuthorAutocomplete(): void {
     $admin_user = $this->drupalCreateUser([
-      'administer nodes',
       'create page content',
     ]);
     $this->drupalLogin($admin_user);
 
     $this->drupalGet('node/add/page');
 
-    // Verify that no autocompletion exists without access user profiles.
-    $this->assertSession()->elementNotExists('xpath', '//input[@id="edit-uid-0-value" and contains(@data-autocomplete-path, "user/autocomplete")]');
+    // Verify that no autocompletion exists without administer nodes.
+    $selector = '//input[@id="edit-uid-0-target-id" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/user/default")]';
+    $this->assertSession()->elementNotExists('xpath', $selector);
 
     $admin_user = $this->drupalCreateUser([
       'administer nodes',
       'create page content',
-      'access user profiles',
     ]);
     $this->drupalLogin($admin_user);
 
     $this->drupalGet('node/add/page');
 
     // Ensure that the user does have access to the autocompletion.
-    $this->assertSession()->elementsCount('xpath', '//input[@id="edit-uid-0-target-id" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/user/default")]', 1);
+    $this->assertSession()->elementsCount('xpath', $selector, 1);
   }
 
   /**
-- 
GitLab


From b1565f2cdfe97492e87187ee4f8606e6a02bbcfc Mon Sep 17 00:00:00 2001
From: Adam Bramley <adam.bramley@previousnext.com.au>
Date: Wed, 5 Mar 2025 12:19:55 +1100
Subject: [PATCH 2/2] Add positive assertion

---
 core/modules/node/tests/src/Functional/NodeCreationTest.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php
index 01acd86110de..f0192966a1b5 100644
--- a/core/modules/node/tests/src/Functional/NodeCreationTest.php
+++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php
@@ -266,7 +266,7 @@ public function testAuthorAutocomplete(): void {
     $this->drupalLogin($admin_user);
 
     $this->drupalGet('node/add/page');
-
+    $this->assertSession()->statusCodeEquals(200);
     // Verify that no autocompletion exists without administer nodes.
     $selector = '//input[@id="edit-uid-0-target-id" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/user/default")]';
     $this->assertSession()->elementNotExists('xpath', $selector);
-- 
GitLab