Create a test trait for assertAnnounceContains and assertAnnounceNotContains

Created on 10 October 2019, over 5 years ago
Updated 22 July 2023, over 1 year ago

Problem/Motivation

We're starting to use variants of assertAnnounceContains to assert Drupal.Announce and its integration with Drupal.Message().add().

It would be good to have a test trait or add it to one of the base test classes. This will help us not duplicate code in different tests and standardize the way we're testing for this.

See Drupal\FunctionalJavascriptTests\Ajax\MessageCommandTest

Proposed resolution

Move assertAnnounceContains and assertAnnounceNotContains into it's own trait vs custom solutions for test modules.

Remaining tasks

per #25 update other places to use new trait.

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Needs work

Version

11.0 🔥

Component
PHPUnit 

Last updated 3 days ago

Created by

🇺🇸United States oknate Greater New York City Area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Status changed to Needs review almost 2 years ago
  • 🇺🇸United States smustgrave

    patch #15 no longer applied with
    error: patch failed: core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php:123
    error: core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php: patch does not apply
    error: patch failed: core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php:114
    error: core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php: patch does not apply

  • Status changed to Needs work almost 2 years ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    I found one super small nitpick

    +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/BlockFilterTest.php
    @@ -131,9 +134,7 @@ public function testBlockFilter() {
         $announce_element = $page->find('css', '#drupal-live-announce');
    

    This line can be removed I think? It is only used for the check later in the test.

    Otherwise this change looks great and is rtbc imo.

  • Assigned to dtfabio
  • Status changed to Active almost 2 years ago
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    Custom Commands Failed
  • 🇧🇪Belgium dtfabio Ninove

    I am currently working with @borisson on an internal Calibrate contribution day, I have incorporated his suggestion.

  • 🇧🇪Belgium dtfabio Ninove

    I had added all the changes to the interdiff, my apologies here is the correct file.

  • Status changed to RTBC almost 2 years ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,302 pass
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    Looks like the file was not complete, combined #19 and the interdiff in #23.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,304 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,343 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,366 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    29,366 pass
  • Status changed to Needs review almost 2 years ago
  • 🇬🇧United Kingdom longwave UK

    There are some more tests that look like they could be converted to use the new trait?

    core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
    core/modules/system/tests/src/FunctionalJavascript/ModuleFilterTest.php
    core/modules/system/tests/src/FunctionalJavascript/ModuleUninstallFilterTest.php
    core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php
    core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroViewsBulkOperationsTest.php

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    Searched for

    ->elementTextContains('css', '#drupal-live-announce'

    and found 9 instances

    Search for

    $this->waitForElementTextContains('#drupal-live-announce'

    found 2.

    Guess those could be converted pretty easily here vs a follow up.

  • 🇬🇧United Kingdom longwave UK

    Discussed with @lauriii at Drupal Dev Days when committing 🐛 Disable body-level scrolling when a dialog is open as a modal Fixed .

    We think this should go directly into WebAssert instead of a trait, because we already have a number of status message assertions in WebAssert and we want to encourage people to use this; discovery is harder if this is in a separate trait.

Production build 0.71.5 2024