From d8be55751f1eea79539af13cede00c19a54dc15e Mon Sep 17 00:00:00 2001
From: Lauri Eskola <lauri.eskola@acquia.com>
Date: Wed, 17 Aug 2022 14:04:44 +0300
Subject: [PATCH] Issue #3303033 by nod_, bnjmnm: Book tests should not rely on
 Classy

---
 .../book/tests/src/Functional/BookBreadcrumbTest.php   | 10 +++++-----
 .../tests/src/Functional/BookContentModerationTest.php |  2 +-
 core/modules/book/tests/src/Functional/BookTest.php    |  2 +-
 .../book/tests/src/Functional/BookTestTrait.php        |  6 ++----
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
index f762e339e247..4652abd65150 100644
--- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
+++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php
@@ -21,7 +21,7 @@ class BookBreadcrumbTest extends BrowserTestBase {
   /**
    * {@inheritdoc}
    */
-  protected $defaultTheme = 'classy';
+  protected $defaultTheme = 'stark';
 
   /**
    * A book node.
@@ -156,7 +156,7 @@ public function testBreadcrumbTitleUpdates() {
 
     $this->drupalGet($nodes[4]->toUrl());
     // Fetch each node title in the current breadcrumb.
-    $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
+    $links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
     $got_breadcrumb = [];
     foreach ($links as $link) {
       $got_breadcrumb[] = $link->getText();
@@ -171,7 +171,7 @@ public function testBreadcrumbTitleUpdates() {
     $this->submitForm($edit, 'Save');
     $this->drupalGet($nodes[4]->toUrl());
     // Fetch each node title in the current breadcrumb.
-    $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
+    $links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
     $got_breadcrumb = [];
     foreach ($links as $link) {
       $got_breadcrumb[] = $link->getText();
@@ -193,7 +193,7 @@ public function testBreadcrumbAccessUpdates() {
     $this->drupalGet($nodes[3]->toUrl('edit-form'));
     $this->submitForm($edit, 'Save');
     $this->drupalGet($nodes[4]->toUrl());
-    $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
+    $links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
     $got_breadcrumb = [];
     foreach ($links as $link) {
       $got_breadcrumb[] = $link->getText();
@@ -203,7 +203,7 @@ public function testBreadcrumbAccessUpdates() {
     $config = $this->container->get('config.factory')->getEditable('book_breadcrumb_test.settings');
     $config->set('hide', TRUE)->save();
     $this->drupalGet($nodes[4]->toUrl());
-    $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
+    $links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
     $got_breadcrumb = [];
     foreach ($links as $link) {
       $got_breadcrumb[] = $link->getText();
diff --git a/core/modules/book/tests/src/Functional/BookContentModerationTest.php b/core/modules/book/tests/src/Functional/BookContentModerationTest.php
index 2c491b861887..14898777d91e 100644
--- a/core/modules/book/tests/src/Functional/BookContentModerationTest.php
+++ b/core/modules/book/tests/src/Functional/BookContentModerationTest.php
@@ -30,7 +30,7 @@ class BookContentModerationTest extends BrowserTestBase {
   /**
    * {@inheritdoc}
    */
-  protected $defaultTheme = 'classy';
+  protected $defaultTheme = 'stark';
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php
index a7f7063ce892..bd7ddfee5975 100644
--- a/core/modules/book/tests/src/Functional/BookTest.php
+++ b/core/modules/book/tests/src/Functional/BookTest.php
@@ -31,7 +31,7 @@ class BookTest extends BrowserTestBase {
   /**
    * {@inheritdoc}
    */
-  protected $defaultTheme = 'classy';
+  protected $defaultTheme = 'stark';
 
   /**
    * A user with permission to view a book and access printer-friendly version.
diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php
index 2bec801f3467..402ea5949ca2 100644
--- a/core/modules/book/tests/src/Functional/BookTestTrait.php
+++ b/core/modules/book/tests/src/Functional/BookTestTrait.php
@@ -92,7 +92,6 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
     // since it uniquely identifies each call to checkBookNode().
     static $number = 0;
     $this->drupalGet('node/' . $node->id());
-
     // Check outline structure.
     if ($nodes !== NULL) {
       $this->assertSession()->responseMatches($this->generateOutlinePattern($nodes));
@@ -130,7 +129,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
     }
 
     // Fetch links in the current breadcrumb.
-    $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a');
+    $links = $this->xpath('//nav[@aria-labelledby="system-breadcrumb"]/ol/li/a');
     $got_breadcrumb = [];
     foreach ($links as $link) {
       $got_breadcrumb[] = $link->getAttribute('href');
@@ -161,8 +160,7 @@ public function generateOutlinePattern($nodes) {
     foreach ($nodes as $node) {
       $outline .= '(node\/' . $node->id() . ')(.*?)(' . $node->label() . ')(.*?)';
     }
-
-    return '/<nav id="book-navigation-' . $this->book->id() . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
+    return '/<nav role="navigation" aria-labelledby="book-label-' . $this->book->id() . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
   }
 
   /**
-- 
GitLab