Verified Commit 4fa09fb8 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3274066 by danflanagan8: Node tests should not rely on Classy

parent e562f7ee
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ class NodeAdminTest extends NodeTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * A user with permission to bypass access content.
@@ -104,8 +104,7 @@ public function testContentAdminSort() {
    $this->drupalGet('admin/content');
    foreach ($nodes_query as $delta => $string) {
      // Verify that the node was found in the correct order.
      $this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [
        ':class' => 'views-table',
      $this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery('//table/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [
        ':label' => $string,
      ]));
    }
@@ -121,8 +120,7 @@ public function testContentAdminSort() {
    $this->drupalGet('admin/content', ['query' => ['sort' => 'asc', 'order' => 'title']]);
    foreach ($nodes_query as $delta => $string) {
      // Verify that the node was found in the correct order.
      $this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [
        ':class' => 'views-table',
      $this->assertSession()->elementExists('xpath', $this->assertSession()->buildXPathQuery('//table/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', [
        ':label' => $string,
      ]));
    }
+3 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class NodeDisplayConfigurableTest extends NodeTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
@@ -167,6 +167,8 @@ public function provideThemes() {
    return [
      ['bartik', 'header', TRUE],
      ['claro', 'footer', TRUE],
      // @todo Remove Classy from data provider in
      // https://www.drupal.org/project/drupal/issues/3110137.
      ['classy', 'footer', TRUE],
      // @todo Add coverage for olivero after fixing
      // https://www.drupal.org/project/drupal/issues/3215220.
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class NodeFieldMultilingualTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  protected function setUp(): void {
    parent::setUp();
@@ -140,7 +140,7 @@ public function testMultilingualDisplaySettings() {

    // Check if node body is showed.
    $this->drupalGet('node/' . $node->id());
    $this->assertSession()->elementTextEquals('xpath', "//article[contains(concat(' ', normalize-space(@class), ' '), ' node ')]//div[contains(concat(' ', normalize-space(@class), ' '), 'node__content')]/descendant::p", $node->body->value);
    $this->assertSession()->elementTextEquals('xpath', "//article/div//p", $node->body->value);
  }

}
+3 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ class NodePostSettingsTest extends NodeTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  protected function setUp(): void {
    parent::setUp();
@@ -46,7 +46,7 @@ public function testPagePostInfo() {

    // Check that the post information is displayed.
    $node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
    $this->assertSession()->elementsCount('xpath', '//div[contains(@class, "node__submitted")]', 1);
    $this->assertSession()->pageTextContainsOnce('Submitted by');
    $node->delete();

    // Set "Basic page" content type to display post information.
@@ -63,7 +63,7 @@ public function testPagePostInfo() {
    $this->submitForm($edit, 'Save');

    // Check that the post information is not displayed.
    $this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "node__submitted")]');
    $this->assertSession()->pageTextNotContains('Submitted by');
  }

}
+8 −5
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Component\Utility\Html;
use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait;

/**
 * Tests node title.
@@ -13,6 +14,7 @@
class NodeTitleTest extends NodeTestBase {

  use CommentTestTrait;
  use AssertBreadcrumbTrait;

  /**
   * Modules to enable.
@@ -24,7 +26,7 @@ class NodeTitleTest extends NodeTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * A user with permission to bypass access content.
@@ -70,12 +72,13 @@ public function testNodeTitle() {
    $this->assertEquals($this->xpath($xpath)[0]->getText(), $node->label() . ' | Drupal', 'Page title is equal to node title.');

    // Test breadcrumb in comment preview.
    $this->drupalGet('comment/reply/node/' . $node->id() . '/comment');
    $xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
    $this->assertEquals($this->xpath($xpath)[0]->getText(), $node->label(), 'Node breadcrumb is equal to node title.');
    $this->assertBreadcrumb('comment/reply/node/' . $node->id() . '/comment', [
      '' => 'Home',
      'node/' . $node->id() => $node->label(),
    ]);

    // Verify that node preview title is equal to node title.
    $this->assertSession()->elementTextEquals('xpath', "//article[contains(concat(' ', normalize-space(@class), ' '), ' node--type-{$node->bundle()} ')]/h2/a/span", $node->label());
    $this->assertSession()->elementTextEquals('xpath', "//article/h2/a/span", $node->label());

    // Test node title is clickable on teaser list (/node).
    $this->drupalGet('node');
Loading