Problem/Motivation

In #2938309: Only install Quick Edit when necessary for Settings Tray tests it was determined that installing Quick Edit for tests that don't actually need it caused tests to fail randomly.

That issue moved 'quickedit' from \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::$modules to the methods that actually used it.

This issue is split apart this test class so that other modules aren't installed when needed

Proposed resolution

Move some methods in SettingsTrayBlockFormTest into 2 new classes
QuickEditIntegrationTest and OverriddenConfigurationTest

Remaining tasks

Create the patch & review

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
FileSize
43.22 KB

Here is the patch

To be sure I didn't copy a function and forget to paste it 😱.... I ran grep -r 'public function test' . from inside core/modules/settings_tray/tests/src/FunctionalJavascript

For 8.6.x

./SettingsTrayBlockFormTest.php: public function testBlocks($theme, $block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item) {
./SettingsTrayBlockFormTest.php: public function testQuickEditLinks() {
./SettingsTrayBlockFormTest.php: public function testEditModeEnableDisable() {
./SettingsTrayBlockFormTest.php: public function testCustomBlockLinks() {
./SettingsTrayBlockFormTest.php: public function testValidationMessages() {
./SettingsTrayBlockFormTest.php: public function testOverriddenBlock() {
./SettingsTrayBlockFormTest.php: public function testOverriddenConfigurationRemoved() {

With patch

./OverriddenConfigurationTest.php: public function testOverriddenConfigurationRemoved() {
./OverriddenConfigurationTest.php: public function testOverriddenBlock() {
./QuickEditIntegrationTest.php: public function testQuickEditLinks() {
./QuickEditIntegrationTest.php: public function testCustomBlockLinks() {
./SettingsTrayBlockFormTest.php: public function testBlocks($theme, $block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item) {
./SettingsTrayBlockFormTest.php: public function testEditModeEnableDisable() {
./SettingsTrayBlockFormTest.php: public function testValidationMessages() {

So the same 7 test methods are still there 💫🎉

Status: Needs review » Needs work

The last submitted patch, 2: 2939814-2.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
1.26 KB
43.28 KB

Duh! Forgot @group from new tests

Status: Needs review » Needs work

The last submitted patch, 4: 2939814-4.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
43.27 KB
874 bytes

Double duh!

Apparently you can't just put @group wherever you want

tedbow’s picture

Re-roll after #2938309: Only install Quick Edit when necessary for Settings Tray tests

Basically #2938309 gets reverted because it was temp fix to get the test failure fixed.

tedbow’s picture

Status: Needs review » Needs work

The last submitted patch, 8: 2939814-8.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
43.58 KB

I messed up the reroll in #8 because I didn't add the new files 😰

borisson_’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10
rajeshwari10’s picture

Assigned: rajeshwari10 » Unassigned
Status: Needs work » Needs review
FileSize
44.22 KB

Hi,

Please Review the patch.

Thanks!!

borisson_’s picture

Status: Needs review » Needs work
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
@@ -0,0 +1,164 @@
+class SettingsTrayTestBase extends OffCanvasTestBase {

A lot of lines in this file intented with 4 spaces (at least it looks like that). That should follow drupal's coding standards and be intented with 2 spaces.

There also needs to be a newline at the end of the file.

rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10

Thanks, @borisson_ for reviewing the patch.

I will make changes and update the patch.

Thanks!!

rajeshwari10’s picture

Assigned: rajeshwari10 » Unassigned
Status: Needs work » Needs review
FileSize
43.92 KB

Hi,

Updated the patch.

Please Review.

Thanks!!

borisson_’s picture

This already looks a lot better, thank you. If the tests come back green I'll take a look at the actual code - but it would be better if @tedbow can review this.

PS: Next time, please provide an interdiff as well as a patch to make reviewing easier.

Status: Needs review » Needs work

The last submitted patch, 16: 2939814-16.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
FileSize
51.16 KB

Ok @rajeshwari10 thanks for the patch.

Instead of review the patch though I found it easier to revert the commit that cause the patch not to able to be applied: https://cgit.drupalcode.org/drupal/commit/?id=a2ae6fd09c14bc0993a919b93a...

Apply the from #10 and then undo the above revert.

I also then split out testBlockConfigAccess() which is new since #10 into its own class. This allows not enabling a couple modules in SettingsTrayBlockFormTest

borisson_’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
    @@ -0,0 +1,111 @@
    +    'block',
    +    'system',
    +    'breakpoint',
    +    'toolbar',
    +    'contextual',
    +    'menu_link_content',
    +    'menu_ui',
    +    'settings_tray',
    +    // Add test module to override CSS pointer-events properties because they
    +    // cause test failures.
    +    'settings_tray_test_css',
    

    A lot of the modules defined here can be moved to the base class, as they are repeated over all the classes. I guess at least block, system and settings_tray should move to the base class, perhaps the test_css module as well?

  2. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
    @@ -0,0 +1,111 @@
    +}
    \ No newline at end of file
    

    Needs newline.

  3. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/OverriddenConfigurationTest.php
    @@ -0,0 +1,184 @@
    +    // Add test module to override CSS pointer-events properties because they
    +    // cause test failures.
    

    This comment is the same as the one in configAccessTest, but it looks like it applies to more modules here? Or is that not true? I'm not sure about the need to copy this comment in all the new test classes.

  4. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
    @@ -0,0 +1,164 @@
    +  }
    +
    +
    +  /**
    

    Should be only one blank line.

  5. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
    @@ -0,0 +1,164 @@
    +  }
    +
    +
    +  /**
    

    ^

  6. +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
    @@ -0,0 +1,164 @@
    +    // Remove 'seven' theme. Setting Tray "Edit Mode" will not work with 'seven'
    +    // because it removes all contextual links the off-canvas dialog should.
    

    I think some words are missing here?

tedbow’s picture

Status: Needs work » Needs review
FileSize
3.56 KB
51.1 KB

@borisson_ thanks for the review.

1. I don't thinking moving this into the base class makes sense because each subclass overwrites this property. They don't get merged with the parent so unless multiple subclasses are going to the same exact set of modules as the base class it doesn't make sense. Also core test classes are @internal be default so we only have to worry about core sub classes defined in this module.

2. fixed
3. I have moved the comment to the bottom of the list of modules and now settings_tray_test_css is the last module in all classes with the comment above. Now it should be clear it only applies to the 1 module. I would like to keep the comment on all test classes because there is no $modules property on the base class. So since all of the classes with this comment don't extend each other it would make sense they all should be able to be read without reading the other classes.
4-5. Fixed
6. Shorten up the comment.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, that makes sense. Thanks you for explaining that this doesn't merge, but that it overwrites.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

re #21.1/#22.1 yes they do get merged in.

+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
@@ -0,0 +1,162 @@
+class SettingsTrayTestBase extends OffCanvasTestBase {

This class can have the common $modules for the tests that inherit from it so there's less duplication between the tests. At the very least I think it should have:
block, contextual, settings_tray, settings_tray_test_css

Also I don't think system needs to be in these lists. It is a required module and tonnes of other tests do not list that.

tedbow’s picture

Status: Needs work » Needs review
FileSize
4.23 KB
50.63 KB

re #21.1/#22.1 yes they do get merged in.

🧠💥
Good to know.

I have moved $modules to \Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayTestBase::$modules
I was able remove a bunch of ones from the list that probably shouldn't have been there because they are actually dependencies of settings_tray

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

#23 explained that I was wrong in #22. The problem is fixed in #24, so that means this can go in.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 03241fbe8f to 8.6.x and cc0b6e2bed to 8.5.x. Thanks!

Backported to 8.5.x since this is tests-only.

Added review credit to @borisson_ and myself for reviews that affected the final patch.

  • alexpott committed 03241fb on 8.6.x
    Issue #2939814 by tedbow, rajeshwari10, borisson_, alexpott: Split...

  • alexpott committed cc0b6e2 on 8.5.x
    Issue #2939814 by tedbow, rajeshwari10, borisson_, alexpott: Split...
tedbow’s picture

Thanks @alexpott for committing and the explanation. Much better now

Also thanks to @rajeshwari10 and @borisson_

Status: Fixed » Closed (fixed)

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