The module needs automated tests. Also WebDriver tests to be considered for the Ajax refreshing features.

CommentFileSizeAuthor
#17 interdiff.txt3.66 KBpfrenssen
#17 3111579-17.patch5.12 KBpfrenssen
#15 interdiff_12-15.txt1.73 KBAnonymous (not verified)
#15 3111579-15.patch4.98 KBAnonymous (not verified)
#12 interdiff_5-12.txt2.88 KBAnonymous (not verified)
#12 3111579-12.patch5.24 KBAnonymous (not verified)
#5 interdiff_4-5.txt1.05 KBAnonymous (not verified)
#5 3111579-5.patch5.15 KBAnonymous (not verified)
#4 interdiff_2-4.txt2.49 KBAnonymous (not verified)
#4 3111579-4.patch5.11 KBAnonymous (not verified)
#2 3111579-2.patch5.03 KBAnonymous (not verified)

Comments

claudiu.cristea created an issue. See original summary.

Anonymous’s picture

StatusFileSize
new5.03 KB

Hello,
I have created a simple test that checks if the module is active on "admin/config/system/site-alerts". It checks if we can create an alert message, delete an alert message and if we can place the block and if there is an alert in the block.

pfrenssen’s picture

Status: Active » Needs work

Thanks a lot for working on this! I have enabled automatic testing and ran the test. The result is green, but it generates a number of coding standards errors:

tests/src/Functional/SiteAlertMenuTest.php
line 3	There must be one blank line after the namespace declaration
13	Missing member variable doc comment
48	Doc comment short description must end with a full stop
61	Missing function doc comment
76	Missing function doc comment
77	Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
92	Missing function doc comment
93	Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
96	Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
105	Expected 1 blank line after function; 0 found
106	Expected 1 newline at end of file; 2 found
106	The closing brace for the class must have an empty line before it

I have not yet reviewed the test manually, but let's already fix these before continuing.

Anonymous’s picture

StatusFileSize
new5.11 KB
new2.49 KB

Hello,
thanks for pointing out. Here is fixed patch

Anonymous’s picture

StatusFileSize
new5.15 KB
new1.05 KB

Hey,
sorry I missed 4 lines. This one should fix all issues.

Anonymous’s picture

Status: Needs work » Reviewed & tested by the community
Anonymous’s picture

Status: Reviewed & tested by the community » Needs review
kbrodej’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the patch from #5. All coding issues are fixed.

bcizej’s picture

Status: Reviewed & tested by the community » Needs work

I reviewed the patch and there are few things that stand out:

1. Incorrect group annotation

/**
 * Tests that the Site Alert is working correctly.
 *
 * @group admin_toolbar
 */

2. There are four tests which means that four times a drupal installation and teardown is performed which slows the execution of tests. All four tests could be merged into a single test with assertions in correct order:

- Alerts list assertions
- Alert creation assertions
- Block placement assertions
- Alert deletion assertions
- No block after delete assertions

3. Previous point would also fix the next problem in tests, eg.

  /**
   * {@inheritdoc}
   */
  public function testDeleteAlert() {
    // Creates alert.
    $this->testCreateAlert();
    ...
  }

Tests are calling another test that already ran and succeeded/failed.

Anonymous’s picture

Assigned: Unassigned »
bcizej’s picture

One more thing I found, probably just nitpicking here but lets follow the standards. Each module in the list should be in separate line.

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'site_alert', 'options', 'block',
  ];
Anonymous’s picture

StatusFileSize
new5.24 KB
new2.88 KB

Hello,
here is an updated version of the patch. Thanks for all the feedback.

Anonymous’s picture

Assigned: » Unassigned
Status: Needs work » Needs review
pfrenssen’s picture

Assigned: Unassigned » pfrenssen

Awesome, thanks so much for working on this! Assigning for review.

Anonymous’s picture

StatusFileSize
new4.98 KB
new1.73 KB

Another patch. I just cleaned up my code a bit. Sorry for so many patches. And thanks for reviewing.

Kind regards, Denis

pfrenssen’s picture

Assigned: pfrenssen » Unassigned
Status: Needs review » Needs work
  1. +class SiteAlertMenuTest extends SiteAlertTestBase {
    

    We're not testing any menu's so the name of the test is a bit misleading. Since this is testing the adding and removing of an alert through the web interface a better name would be SiteAlertUiTest.

  2. +  protected static $modules = [
    +    'site_alert',
    +    'options',
    +    'block',
    +  ];
    

    It is no longer needed to explicitly add the dependency on the options module, this has been fixed recently in #3111058: Missing dependency on the Options module.

    +  /**
    +   * A test user with permission to access the administrative toolbar.
    +   *
    +   * @var \Drupal\user\UserInterface
    +   */
    +  protected $adminUser;
    

    This user doesn't have the permission to access the toolbar, so let's change this to A test user with permission to administer site alerts..

  3. +  /**
    +   * Tests that the site alter list page works.
    +   */
    

    This documentation seems to be unrelated to what is being tested, we are not altering any pages in the test. Let's put a description here that explains what this is about, maybe something like Tests the creation and deletion of site alerts through the user interface.

  4. +    $this->assertSession()
    +      ->responseContains('<div id="block-' . $block_id . '">');
    

    We don't need to call $this-assertSession() again, it has already been called before and stored in the $assert variable. Also it is not needed to check the existence of actual HTML snippets since this is brittle; any change in the theming (like adding a class) would break this test. Instead we can use WebAssert::elementExists() to check if the block is on the page.

  5. +    /** @var \Drupal\Tests\WebAssert $assert */
    +    $assert->pageTextContains('This action cannot be undone.');
    

    There are a few cases where this inline declaration of the variable type is left over in the code from earlier iterations. We can remove the duplicates, it is sufficient to keep only the declaration at the moment the variable is instantiated.

  6. +    // Test that there is an empty reaction rule listing.
    +    $assert->pageTextContains('There are no site alert entities yet.');
    

    The comment from this seems to be unrelated, possibly copied from a different test? Also let's add a test to check that this empty text is no longer visible once we created a site alert.

pfrenssen’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new5.12 KB
new3.66 KB

Crossposted with comment #15. Some of my remarks were already addressed, great :)

Here are the rest of the fixes. This will be good to go when tests come back green. I would like to get this in first before any other issues so that we can run the test and check that there are no regressions.

  • pfrenssen committed d26edf5 on 8.x-1.x authored by DenisCi
    Issue #3111579 by DenisCi, pfrenssen, benjamincizej, kbrodej: Implement...
pfrenssen’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.