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

(cherry picked from commit 4fa09fb85c)
merge-requests/1809/merge
Alex Pott 2022-04-15 12:51:58 +01:00
parent 73428d6439
commit 532250841e
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
9 changed files with 36 additions and 24 deletions

View File

@ -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 @@ class NodeAdminTest extends NodeTestBase {
$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 @@ class NodeAdminTest extends NodeTestBase {
$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,
]));
}

View File

@ -23,7 +23,7 @@ class NodeDisplayConfigurableTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
@ -167,6 +167,8 @@ class NodeDisplayConfigurableTest extends NodeTestBase {
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.

View File

@ -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 @@ class NodeFieldMultilingualTest extends BrowserTestBase {
// 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);
}
}

View File

@ -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 @@ class NodePostSettingsTest extends NodeTestBase {
// 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 @@ class NodePostSettingsTest extends NodeTestBase {
$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');
}
}

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\node\Functional;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Component\Utility\Html;
use Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait;
/**
* Tests node title.
@ -13,6 +14,7 @@ use Drupal\Component\Utility\Html;
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 @@ class NodeTitleTest extends NodeTestBase {
$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');

View File

@ -28,7 +28,7 @@ class NodeTypeTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* Ensures that node type functions (node_type_get_*) work correctly.
@ -78,7 +78,7 @@ class NodeTypeTest extends NodeTestBase {
$this->drupalGet('node/add');
$this->assertSession()->responseHeaderContains('X-Drupal-Cache-Tags', 'config:node_type_list');
$this->assertCacheContext('user.permissions');
$elements = $this->cssSelect('dl.node-type-list dt');
$elements = $this->cssSelect('dl dt');
$this->assertCount(3, $elements);
$edit = [
@ -92,7 +92,7 @@ class NodeTypeTest extends NodeTestBase {
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
$this->drupalGet('node/add');
$elements = $this->cssSelect('dl.node-type-list dt');
$elements = $this->cssSelect('dl dt');
$this->assertCount(4, $elements);
}

View File

@ -15,7 +15,7 @@ class NodeViewTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* Tests the html head links.
@ -60,7 +60,7 @@ class NodeViewTest extends NodeTestBase {
$node = $this->drupalCreateNode(['title' => $title]);
$this->drupalGet($node->toUrl());
// Verify that the passed title was returned.
$this->assertSession()->elementTextEquals('xpath', '//span[contains(@class, "field--name-title")]', $title);
$this->assertSession()->elementTextEquals('xpath', '//h1/span', $title);
}
}

View File

@ -45,7 +45,16 @@ class PagePreviewTest extends NodeTestBase {
];
/**
* {@inheritdoc}
* The theme to install as the default for testing.
*
* @var string
*
* @todo The fact that PagePreviewTest::testPagePreview() makes assertions
* related to the node type being used for a body class makes Stark a bad
* fit as a base theme. Change the default theme to Starterkit once it is
* stable.
*
* @see https://www.drupal.org/project/drupal/issues/3274077
*/
protected $defaultTheme = 'classy';

View File

@ -24,7 +24,7 @@ class FrontPageTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
@ -189,7 +189,7 @@ class FrontPageTest extends ViewTestBase {
$this->drupalGet('node');
$this->assertSession()->statusCodeEquals(200);
// Check that the frontpage view was rendered.
$this->assertSession()->responseMatches('/class=".+view-frontpage/');
$this->assertSession()->elementExists('css', '.views-element-container');
}
/**