From c206e832c2d774d2460a0c68785efa0b6b39bf24 Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Thu, 6 Mar 2025 09:04:48 +0100
Subject: [PATCH] Issue #3511071 by acbramley:
 NodeCreationtest::testAuthorAutocomplete has incorrect selector for falsey
 check

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

diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php
index ed151d7cd882..f0192966a1b5 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")]');
+    $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);
 
     $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