Unverified Commit cfd82a0e authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3267653 by danflanagan8, mglaman: Comment tests should not rely on Classy

(cherry picked from commit 089cd0b5)
parent 4a0768b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ class CommentAdminTest extends CommentTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  protected function setUp(): void {
    parent::setUp();
+3 −3
Original line number Diff line number Diff line
@@ -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 @@ public function testAnonymous() {
    $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 @@ public function testAnonymous() {
    $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']);
+8 −1
Original line number Diff line number Diff line
@@ -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';

+3 −3
Original line number Diff line number Diff line
@@ -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 @@ public function testCommentFieldDelete() {
    $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.');
  }

+4 −4
Original line number Diff line number Diff line
@@ -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 @@ public function testCommentInterface() {
    $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 @@ public function testViewMode() {
    $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 @@ public function testViewMode() {
    $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>');
  }
Loading