Issue #3267653 by danflanagan8, mglaman: Comment tests should not rely on Classy
parent
d471b0c346
commit
089cd0b56e
|
@ -18,7 +18,7 @@ class CommentAdminTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
@ -15,7 +15,7 @@ class CommentAnonymousTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
@ -50,7 +50,7 @@ class CommentAnonymousTest extends CommentTestBase {
|
|||
$this->drupalGet($this->node->toUrl());
|
||||
$this->submitForm($edit, 'Preview');
|
||||
// Cannot use assertRaw here since both title and body are in the form.
|
||||
$preview = (string) $this->cssSelect('.preview')[0]->getHtml();
|
||||
$preview = (string) $this->cssSelect('[data-drupal-selector="edit-comment-preview"]')[0]->getHtml();
|
||||
$this->assertStringContainsString($title, $preview, 'Anonymous user can preview comment title.');
|
||||
$this->assertStringContainsString($body, $preview, 'Anonymous user can preview comment body.');
|
||||
|
||||
|
@ -64,7 +64,7 @@ class CommentAnonymousTest extends CommentTestBase {
|
|||
$this->drupalGet($this->node->toUrl());
|
||||
$this->submitForm($edit, 'Preview');
|
||||
// Cannot use assertRaw here since both title and body are in the form.
|
||||
$preview = (string) $this->cssSelect('.preview')[0]->getHtml();
|
||||
$preview = (string) $this->cssSelect('[data-drupal-selector="edit-comment-preview"]')[0]->getHtml();
|
||||
$this->assertStringContainsString($title, $preview, 'Anonymous user can preview comment title.');
|
||||
$this->assertStringContainsString($body, $preview, 'Anonymous user can preview comment body.');
|
||||
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['skip comment approval']);
|
||||
|
|
|
@ -18,7 +18,14 @@ class CommentCSSTest extends CommentTestBase {
|
|||
use GeneratePermutationsTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* The theme to install as the default for testing.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @todo This test's reliance on classes 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/3267890
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class CommentFieldsTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Tests that the default 'comment_body' field is correctly added.
|
||||
|
@ -85,13 +85,13 @@ class CommentFieldsTest extends CommentTestBase {
|
|||
$this->drupalLogin($this->webUser);
|
||||
|
||||
$this->drupalGet('node/' . $node->nid->value);
|
||||
$elements = $this->cssSelect('.field--type-comment');
|
||||
$elements = $this->cssSelect('.comment-form');
|
||||
$this->assertCount(2, $elements, 'There are two comment fields on the node.');
|
||||
|
||||
// Delete the first comment field.
|
||||
FieldStorageConfig::loadByName('node', 'comment')->delete();
|
||||
$this->drupalGet('node/' . $node->nid->value);
|
||||
$elements = $this->cssSelect('.field--type-comment');
|
||||
$elements = $this->cssSelect('.comment-form');
|
||||
$this->assertCount(1, $elements, 'There is one comment field on the node.');
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Set up comments to have subject and preview disabled.
|
||||
|
@ -90,7 +90,7 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
$arguments = [
|
||||
':link' => base_path() . 'comment/' . $comment->id() . '#comment-' . $comment->id(),
|
||||
];
|
||||
$pattern_permalink = '//footer[contains(@class,"comment__meta")]/a[contains(@href,:link) and text()="Permalink"]';
|
||||
$pattern_permalink = '//footer/a[contains(@href,:link) and text()="Permalink"]';
|
||||
$permalink = $this->xpath($pattern_permalink, $arguments);
|
||||
$this->assertNotEmpty($permalink, 'Permalink link found.');
|
||||
|
||||
|
@ -316,7 +316,7 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
$this->postComment($this->node, $comment_text);
|
||||
|
||||
// Comment displayed in 'default' display mode found and has body text.
|
||||
$comment_element = $this->cssSelect('.comment-wrapper');
|
||||
$comment_element = $this->cssSelect('#comment-1');
|
||||
$this->assertNotEmpty($comment_element);
|
||||
$this->assertSession()->responseContains('<p>' . $comment_text . '</p>');
|
||||
|
||||
|
@ -349,7 +349,7 @@ class CommentInterfaceTest extends CommentTestBase {
|
|||
$this->drupalGet($this->node->toUrl());
|
||||
// The comment should exist but without the body text because we used $mode
|
||||
// mode this time.
|
||||
$comment_element = $this->cssSelect('.comment-wrapper');
|
||||
$comment_element = $this->cssSelect('#comment-1');
|
||||
$this->assertNotEmpty($comment_element);
|
||||
$this->assertSession()->responseNotContains('<p>' . $comment_text . '</p>');
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class CommentNodeAccessTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
@ -36,7 +36,7 @@ class CommentNonNodeTest extends BrowserTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* An administrative user with permission to configure comment settings.
|
||||
|
@ -288,7 +288,7 @@ class CommentNonNodeTest extends BrowserTestBase {
|
|||
|
||||
// Test breadcrumb on comment add page.
|
||||
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
|
||||
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
|
||||
$xpath = '//nav[@aria-labelledby="system-breadcrumb"]/ol/li[last()]/a';
|
||||
$this->assertEquals($this->entity->label(), current($this->xpath($xpath))->getText(), 'Last breadcrumb item is equal to node title on comment reply page.');
|
||||
|
||||
// Post a comment.
|
||||
|
@ -298,17 +298,17 @@ class CommentNonNodeTest extends BrowserTestBase {
|
|||
|
||||
// Test breadcrumb on comment reply page.
|
||||
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1->id());
|
||||
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
|
||||
$xpath = '//nav[@aria-labelledby="system-breadcrumb"]/ol/li[last()]/a';
|
||||
$this->assertEquals($comment1->getSubject(), current($this->xpath($xpath))->getText(), 'Last breadcrumb item is equal to comment title on comment reply page.');
|
||||
|
||||
// Test breadcrumb on comment edit page.
|
||||
$this->drupalGet('comment/' . $comment1->id() . '/edit');
|
||||
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
|
||||
$xpath = '//nav[@aria-labelledby="system-breadcrumb"]/ol/li[last()]/a';
|
||||
$this->assertEquals($comment1->getSubject(), current($this->xpath($xpath))->getText(), 'Last breadcrumb item is equal to comment subject on edit page.');
|
||||
|
||||
// Test breadcrumb on comment delete page.
|
||||
$this->drupalGet('comment/' . $comment1->id() . '/delete');
|
||||
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
|
||||
$xpath = '//nav[@aria-labelledby="system-breadcrumb"]/ol/li[last()]/a';
|
||||
$this->assertEquals($comment1->getSubject(), current($this->xpath($xpath))->getText(), 'Last breadcrumb item is equal to comment subject on delete confirm page.');
|
||||
|
||||
// Unpublish the comment.
|
||||
|
|
|
@ -16,7 +16,7 @@ class CommentPagerTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Confirms comment paging works correctly with flat and threaded comments.
|
||||
|
|
|
@ -198,7 +198,7 @@ abstract class CommentTestBase extends BrowserTestBase {
|
|||
*/
|
||||
public function commentExists(CommentInterface $comment = NULL, $reply = FALSE) {
|
||||
if ($comment) {
|
||||
$comment_element = $this->cssSelect('.comment-wrapper ' . ($reply ? '.indented ' : '') . 'article#comment-' . $comment->id());
|
||||
$comment_element = $this->cssSelect(($reply ? '.indented ' : '') . 'article#comment-' . $comment->id());
|
||||
if (empty($comment_element)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class CommentThreadingTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Tests the comment threading.
|
||||
|
@ -137,16 +137,22 @@ class CommentThreadingTest extends CommentTestBase {
|
|||
protected function assertParentLink(int $cid, int $pid): void {
|
||||
// This pattern matches a markup structure like:
|
||||
// @code
|
||||
// <a id="comment-2"></a>
|
||||
// <article>
|
||||
// <p class="parent">
|
||||
// <article id="comment-2">
|
||||
// <p>
|
||||
// In reply to
|
||||
// <a href="...comment-1"></a>
|
||||
// </p>
|
||||
// </article>
|
||||
// @endcode
|
||||
$pattern = "//article[@id='comment-$cid']//p[contains(@class, 'parent')]//a[contains(@href, 'comment-$pid')]";
|
||||
$pattern = "//article[@id='comment-$cid']//p/a[contains(@href, 'comment-$pid')]";
|
||||
|
||||
$this->assertSession()->elementExists('xpath', $pattern);
|
||||
|
||||
// A parent link is always accompanied by the text "In reply to".
|
||||
// If we don't assert this text here, then the assertNoParentLink()
|
||||
// method is not effective.
|
||||
$pattern = "//article[@id='comment-$cid']";
|
||||
$this->assertSession()->elementTextContains('xpath', $pattern, 'In reply to');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,16 +164,9 @@ class CommentThreadingTest extends CommentTestBase {
|
|||
* @internal
|
||||
*/
|
||||
protected function assertNoParentLink(int $cid): void {
|
||||
// This pattern matches a markup structure like:
|
||||
// @code
|
||||
// <a id="comment-2"></a>
|
||||
// <article>
|
||||
// <p class="parent"></p>
|
||||
// </article>
|
||||
// @endcode
|
||||
|
||||
$pattern = "//article[@id='comment-$cid']//p[contains(@class, 'parent')]";
|
||||
$this->assertSession()->elementNotExists('xpath', $pattern);
|
||||
$pattern = "//article[@id='comment-$cid']";
|
||||
// A parent link is always accompanied by the text "In reply to".
|
||||
$this->assertSession()->elementTextNotContains('xpath', $pattern, 'In reply to');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class CommentTitleTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Tests markup for comments with empty titles.
|
||||
|
|
|
@ -22,7 +22,7 @@ class CommentAdminTest extends CommentBrowserTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -19,7 +19,7 @@ class CommentOperationsTest extends CommentTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'classy';
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Tests the operations field plugin.
|
||||
|
@ -29,10 +29,10 @@ class CommentOperationsTest extends CommentTestBase {
|
|||
$this->drupalLogin($admin_account);
|
||||
$this->drupalGet('test-comment-operations');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$operation = $this->cssSelect('.views-field-operations li.edit a');
|
||||
$this->assertCount(1, $operation, 'Found edit operation for comment.');
|
||||
$operation = $this->cssSelect('.views-field-operations li.delete a');
|
||||
$this->assertCount(1, $operation, 'Found delete operation for comment.');
|
||||
// Assert Edit operation is present.
|
||||
$this->assertSession()->elementsCount('xpath', '//td[contains(@class, "views-field-operations")]//li/a[text() = "Edit"]', 1);
|
||||
// Assert Delete operation is present.
|
||||
$this->assertSession()->elementsCount('xpath', '//td[contains(@class, "views-field-operations")]//li/a[text() = "Delete"]', 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue