Problem/Motivation

Proposed resolution

Tests that have been moved out of scope of this issue:

TourTest: #2767275: Convert web tests to browser tests for tour module
Base class is worked on in TourTest. This test should either be converted in that issue or split into a separate issue and postponed on the tour issue.

RowUITest: #2809553: Convert AJAX part of \Drupal\views_ui\Tests\RowUITest to BrowserTestBase
This test requires a JavascriptTestBase conversion.

PreviewTest:#2863563: Convert PreviewTest WebTestBase to BrowserTestBase and JavascriptTestBase
This test requires a partial JavascriptTestBase conversion and requires a new ViewTestBase class for JavascriptTestBase. Split of into a separate issue so we can postpone it on the JTB base class (#2754171: Create a Views and ViewsUI FunctionalJavascriptTestBase class)

ExposedFormUITest:#2864610: Convert ExposedFormUITest in views_ui module to BrowserTestBase
The tests keeps failing on the radio buttons and need more work to get fixed. Moved out of scope to get this issue in quicker.

ViewEditTest:#2864613: Convert ViewEditTest in views_ui module to BrowserTestBase
The tests keeps failing on the language test and need more work to get fixed. Moved out of scope to get this issue in quicker.

Remaining tasks

- Get everything to pass
- Create sub-issues for problematic tests
- Wait for #2862947: Incorrect field assertions in AssertLegacyTrait to get committed.
- Either wait for the views conversion to get in or merge with that patch. (#2863267: Convert web tests of views)

CommentFileSizeAuthor
#115 2747167-115.patch62.33 KBmichielnugter
#115 interdiff-112-115.txt2.65 KBmichielnugter
#112 2747167-112.patch61.22 KBmichielnugter
#112 interdiff-107-112.txt2.68 KBmichielnugter
#107 2747167-107.patch60.99 KBmichielnugter
#107 interdiff-104-107.txt2.69 KBmichielnugter
#104 2747167-104.patch60.91 KBmichielnugter
#104 interdiff-95-104.txt2.12 KBmichielnugter
#101 2747167-101.patch92.11 KBmichielnugter
#101 interdiff-99-101.txt2.65 KBmichielnugter
#99 2747167-99.patch93.66 KBmichielnugter
#99 interdiff-95-99.txt34.26 KBmichielnugter
#96 2747167-95.patch60.27 KBmichielnugter
#96 interdiff-91-95.txt2.36 KBmichielnugter
#92 2747167-91.patch60.41 KBmichielnugter
#91 interdiff-88-91.patch7.79 KBmichielnugter
#91 interdiff-88-91.txt7.79 KBmichielnugter
#88 2747167-88.patch61.25 KBmichielnugter
#88 interdiff-83-88.txt1.37 KBmichielnugter
#83 2747167-83.patch60.86 KBmichielnugter
#83 interdiff-78-83.txt436 bytesmichielnugter
#78 2747167-78.patch60.33 KBmichielnugter
#77 2747167-77.patch68.72 KBmichielnugter
#77 interdiff-73-77.txt1023 bytesmichielnugter
#73 2747167-73.patch68.67 KBmichielnugter
#73 interdiff-70-73.txt5.2 KBmichielnugter
#70 2747167-70.patch67.94 KBmichielnugter
#70 interdiff-65-70.txt8.83 KBmichielnugter
#65 2747167-65.patch77 KBmichielnugter
#65 interdiff-61-65.txt15.09 KBmichielnugter
#61 2747167-61.patch80.43 KBmichielnugter
#60 2747167-60.patch404.27 KBmichielnugter
#57 2747167-57.patch59.33 KBmichielnugter
#51 interdiff-2747167-43-50.txt12.9 KBmac_weber
#51 views-unit_tests-2747167-50.patch47.6 KBmac_weber
#43 2747167-39.patch51.63 KBmichielnugter
#39 2747167-39.patch405.6 KBmichielnugter
#38 2747167-38.patch51.71 KBmichielnugter
#38 interdiff-36-38.txt2.74 KBmichielnugter
#36 2747167-36.patch48.34 KBjofitz
#26 convert_web_tests_of-2747167-26.patch388.04 KBmglaman
#26 interdiff-2747167-26-18.txt14.1 KBmglaman
#25 interdiff-2747167-24-18.txt969 bytesmglaman
#25 convert_web_tests_of-2747167-25.patch389.01 KBmglaman
#19 2747167-19.patch41.45 KBlendude
#19 interdiff-2747167-18-19.txt603 byteslendude
#18 2747167-18.patch40.76 KBlendude
#18 interdiff-2747167-15-18.txt6.38 KBlendude
#15 2747167-15.patch47.51 KBdawehner
#12 interdiff.txt770 bytesdawehner
#12 2747167-12.patch58.24 KBdawehner
#6 2747167-6.patch60.59 KBdawehner
#6 interdiff.txt2.81 KBdawehner
#5 interdiff.txt32.49 KBdawehner
#5 2747167-5.patch60.15 KBdawehner
#4 interdiff.txt27.93 KBdawehner
#4 2747167-4.patch51.47 KBdawehner
#2 2747167-2.patch25.3 KBdawehner

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Title: Convert web tests of views_ui » Convert web tests of views_ui (round 1)
Status: Active » Needs review
StatusFileSize
new25.3 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2747167-2.patch, failed testing.

dawehner’s picture

Title: Convert web tests of views_ui (round 1) » Convert web tests of views_ui
Status: Needs work » Needs review
StatusFileSize
new51.47 KB
new27.93 KB

Tons of test failures still

dawehner’s picture

StatusFileSize
new60.15 KB
new32.49 KB

Fix a couple of ones.

dawehner’s picture

StatusFileSize
new2.81 KB
new60.59 KB

The last submitted patch, 4: 2747167-4.patch, failed testing.

The last submitted patch, 5: 2747167-5.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 6: 2747167-6.patch, failed testing.

klausi’s picture

  1. +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
    @@ -58,6 +58,7 @@ public function testCacheData() {
    +    file_put_contents('/tmp/foo.html', $this->getSession()->getPage()->getHtml());
    

    debug statement that should be removed?

  2. +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
    @@ -13,6 +14,8 @@
     class DefaultViewsTest extends UITestBase {
     
    +  use BlockCreationTrait;
    +
    

    we use that block creation trait on so many browser tests, i think it should be on BrowserTestBase.

  3. +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
    @@ -181,12 +196,98 @@ protected function assertTitle($expected_title) {
    +   *   Use $this->assertSession()->LinkByHref() instead.
    

    should be ->linkByHref()

  4. +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
    @@ -181,12 +196,98 @@ protected function assertTitle($expected_title) {
    +   *   Use $this->assertSession()->LinkByHref() instead.
    

    same here

  5. +++ b/core/tests/Drupal/Tests/BrowserTestBase.php
    @@ -899,6 +919,11 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) {
    +      // Provide support for 1, 0 for checkboxes instead of TRUE and FALSE.
    +      if (strpos($name, 'name[') === 0) {
    +        $value = (bool) $value;
    +      }
    

    should we really do this? Maybe we should fix all invocations to use proper TRUE/FALSE values? We should have at least @todo here to remove this behavior once all invocations are fixed.

dawehner’s picture

we use that block creation trait on so many browser tests, i think it should be on BrowserTestBase.

Well, the trait is part of block module, does it really belong into the generic testing framework?

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new58.24 KB
new770 bytes

Just rebasing and fixing the feedback

Status: Needs review » Needs work

The last submitted patch, 12: 2747167-12.patch, failed testing.

The last submitted patch, 12: 2747167-12.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new47.51 KB

Just a reroll for now

Status: Needs review » Needs work

The last submitted patch, 15: 2747167-15.patch, failed testing.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new6.38 KB
new40.76 KB

Changes to webassert got committed, reroll without those changes.

lendude’s picture

StatusFileSize
new603 bytes
new41.45 KB
+++ a/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -795,11 +795,6 @@
-      // Provide support for 1, 0 for checkboxes instead of TRUE and FALSE.
-      if (strpos($name, 'name[') === 0) {
-        $value = (bool) $value;
-      }
-

Oops this needed to stay in

The last submitted patch, 18: 2747167-18.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: 2747167-19.patch, failed testing.

dawehner’s picture

Oops this needed to stay in

Do you want to move this into a dedicate issue with some explicit test coverage?

lendude’s picture

Do you want to move this into a dedicate issue with some explicit test coverage?

Just looking at the code now and it turn out that this was already added in #2750941: Additional BC assertions from WebTestBase to BrowserTestBase, so Oops, it needs to stay out!

So #18 is the one to build on.

Current HEAD has:

      // Provide support for the values '1' and '0' for checkboxes instead of
      // TRUE and FALSE.
      // @todo Get rid of supporting 1/0 by converting all tests cases using
      // this to boolean values.
      $field_type = $field->getAttribute('type');
      if ($field_type === 'checkbox') {
        $value = (bool) $value;
      }
dawehner’s picture

Ah perfect, thank you for clarifying.

mglaman’s picture

Assigned: Unassigned » mglaman
StatusFileSize
new389.01 KB
new969 bytes

Giving this a re-roll.

First thing was getting errors over \Drupal\Tests\views_ui\Functional\UITestBase::drupalGet not matching parent.

mglaman’s picture

Assigned: mglaman » Unassigned
Status: Needs work » Needs review
StatusFileSize
new14.1 KB
new388.04 KB

This won't fix everything, but should get us closer.

Status: Needs review » Needs work

The last submitted patch, 26: convert_web_tests_of-2747167-26.patch, failed testing.

dawehner’s picture

Nice to get this patch going again!

+++ b/core/modules/views_ui/tests/src/Functional/XssTest.php
@@ -18,7 +18,6 @@ class XssTest extends UITestBase {
   public function testViewsUi() {
     $this->drupalGet('admin/structure/views');
-    $this->assertEscaped('<script>alert("foo");</script>, <marquee>test</marquee>', 'The view tag is properly escaped.');
     // The view tag is properly escaped.
     $this->assertEscaped('<script>alert("foo");</script>, <marquee>test</marquee>');

This reads a bit dangerous!

mglaman’s picture

This reads a bit dangerous!

I removed that line because it's tested twice. I might have had a borked merge, patch needed re-roll.

dawehner’s picture

I removed that line because it's tested twice. I might have had a borked merge, patch needed re-roll.

Ah gotcha, well, than this sounds still like an unnecessary change :)

mglaman’s picture

Assigned: Unassigned » mglaman

Picking this back up at DrupalCon Dublin.

dawehner’s picture

@mglaman
Feel free to post any progress, no matter how small.

dawehner’s picture

This particular issue could massively profit from #2809181: Provide forward compatibility layer for BrowserTestBase::xpath

mglaman’s picture

Assigned: mglaman » Unassigned

@dawehner, shoot :/ I forgot I had even attempted to pick this up. Drupal Commerce beta ate my time and I don't think I made headway. I think we need some of the other initiative issues to land, like #2784537: Add legacy assertFieldByXPath()/assertNoFieldByXPath() method for browser tests as well to make this simpler.

Unassigning for now.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new48.34 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, 36: 2747167-36.patch, failed testing.

michielnugter’s picture

StatusFileSize
new2.74 KB
new51.71 KB

Work in progress patch, some namespace and constructor fixes to make some more tests working.

michielnugter’s picture

StatusFileSize
new405.6 KB

Reroll for array() to [] conversion.

lendude’s picture

@michielnugter bit of a jump in patch file size

gaurav.kapoor’s picture

Assigned: Unassigned » gaurav.kapoor
gaurav.kapoor’s picture

Assigned: gaurav.kapoor » Unassigned

Was trying to build upon #36 and #38 , but none of the patch applies properly.

michielnugter’s picture

StatusFileSize
new51.63 KB

@lendude: I forgot the -M tag..

@gaurav.kapoor: I'm planning to work on this issue this week and next week during the Sevilla Dev Days. If you prefer to work on this issue instead, ping me any time on irc or post a message here to let me know so I can work on other issues..

gaurav.kapoor’s picture

@michielnugter : all yours.

dawehner’s picture

Status: Needs work » Needs review

@michielnugter Please ping me if you need any help. Let's run the tests in the meantime.

The last submitted patch, 25: convert_web_tests_of-2747167-25.patch, failed testing.

The last submitted patch, 38: 2747167-38.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 43: 2747167-39.patch, failed testing.

klausi’s picture

  1. +++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php
    @@ -173,8 +173,7 @@ public function testCustomOptionTemplate() {
    -      $this->setRawContent($output);
    -      $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template');
    +      $this->assertTrue(strpos($output, 'llama') !== FALSE);
    

    let's use $this->assertContains() instead the strpos().

  2. +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
    @@ -42,7 +41,7 @@ public function testDefaultViews() {
    -    $this->clickViewsOperationLink(t('Enable'), '/glossary/');
    +    $this->clickViewsOperationLink('Enable', '/glossary/');
    

    unrelated change. This has nothing to do with the conversion, so we need to keep the wrong t() call in place for now.

  3. +++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
    @@ -57,10 +57,9 @@ protected function checkFeedViewUi($view_name) {
    +        $options[] = (string) $input_node->getAttribute('value');
    

    The (string) cast can be removed, getAttribute() will always return a string.

  4. +++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
    @@ -73,12 +72,12 @@ protected function checkFeedViewUi($view_name) {
    -    $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
    +    $this->assertSession()->elementExists('xpath', '//*[@id="views-feed-1-displays"]');
    

    this change removes the check for the contents, but we should keep it somehow.

  5. +++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
    @@ -73,12 +72,12 @@ protected function checkFeedViewUi($view_name) {
    -    $this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');
    +    $this->assertSession()->elementExists('xpath', '//*[@id="views-feed-1-displays"]');
    

    same here.

  6. +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
    @@ -285,15 +285,15 @@ public function testActionLinks() {
    -    $this->assertFieldByXpath('//input[@type="submit"]', 'Duplicate ' . $display_title);
    -    $this->assertFieldByXpath('//input[@type="submit"]', 'Delete ' . $display_title);
    -    $this->assertFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title);
    -    $this->assertNoFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title);
    +    $this->assertSession()->elementExists('xpath', '//input[@type="submit"]');
    +    $this->assertSession()->elementExists('xpath', '//input[@type="submit"]');
    +    $this->assertSession()->elementExists('xpath', '//input[@type="submit"]');
    +    $this->assertSession()->elementNotExists('xpath', '//input[@type="submit"]');
    

    this conversion should not be necessary. The assertFieldByXpath method exists now and should work, right?

  7. +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
    @@ -285,15 +285,15 @@ public function testActionLinks() {
    -    $this->assertFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title);
    -    $this->assertNoFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title);
    +    $this->assertSession()->elementExists('xpath', '//input[@type="submit"]');
    +    $this->assertSession()->elementNotExists('xpath', '//input[@type="submit"]');
    

    same here.

  8. +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
    @@ -32,7 +32,7 @@ class ExposedFormUITest extends UITestBase {
    -  protected function setUp() {
    +  protected function setUp($import_test_views = TRUE) {
    

    why do we change this everywhere?

  9. +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
    @@ -39,27 +39,27 @@ public function testFieldUI() {
    -    $this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.');
    +    $this->assertNoLinkByHref($edit_groupby_url);
    

    I know our assertNoLinkByHref() method ignores the other parameters, but we should change as little as possible in this conversion patch.

  10. +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
    @@ -67,12 +67,13 @@ public function testFieldUI() {
    -    $this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.');
    +    $this->assertLinkByHref($edit_groupby_url);
    

    same here

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new60.75 KB

Progess! Because the list is quite long I decided to to categorize the tests first. What's working with minimal effort and what's not.

Non-working tests
AnalyzeTest.php
CachedDataUITest.php
CustomBooleanTest.php
DisplayAttachmentTest.php
DisplayCRUDTest.php
DisplayPathTest.php
DisplayTest.php
ExposedFormUITest.php
FilterBooleanWebTest.php
FilterNumericWebTest.php
HandlerTest.php
OverrideDisplaysTest.php
PreviewTest.php
RowUITest.php
SettingsTest.php
TaxonomyIndexTidUiTest.php
TokenizeAreaUITest.php
ViewsUITourTest.php
ViewTestBase.php
WizardTest.php
XssTest.php

Working tests
AccessRoleUITest.php
AreaEntityUITest.php
ArgumentValidatorTest.php
ConfigTranslationViewListUiTest.php
ContentTranslationViewsUITest.php
DefaultViewsTest.php
DisplayExtenderUITest.php
DisplayFeedTest.php
DuplicateTest.php
FieldUITest.php
FilterUITest.php
GroupByTest.php
NewViewConfigSchemaTest.php
QueryTest.php
RearrangeFieldsTest.php
RedirectTest.php
ReportFieldsTest.php
ReportTest.php
StorageTest.php
StyleTableTest.php
StyleUITest.php
TranslatedViewTest.php
UITestBase.php
UnsavedPreviewTest.php
ViewEditTest.php
ViewsListTest.php

Gone work some more on this. Will have to postpone on the Tour functional tests and views functional tests, view UI tests are using these bases.

mac_weber’s picture

StatusFileSize
new47.6 KB
new12.9 KB
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
+++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
@@ -3,7 +3,7 @@
 namespace Drupal\taxonomy\Tests\Views;
 
 use Drupal\views\Tests\ViewTestData;
-use Drupal\views_ui\Tests\UITestBase;
+use Drupal\Tests\views_ui\Functional\UITestBase;
 
 /**
  * Tests views taxonomy parent plugin UI.

I added this missing change.

--- a/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php
+++ b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php
@@ -12,7 +12,7 @@ class OverrideDisplaysTest extends UITestBase {
   protected function setUp() {
     parent::setUp();
 
-    $this->drupalPlaceBlock('page_title_block');
+    $this->placeBlock('page_title_block');
   }
 
   /**

I reverted this change.

I applied all suggestions from #49.

Tests are still failing on /core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php, line 96. I could not find a substitute for method attributes() in class \Behat\Mink\Element\NodeElement.

mac_weber’s picture

It seems we sent the patches at the same time.
The error you are getting at TaxonomyIndexTidUiTest.php will be fixed with the first snippet in my comment at #51

The last submitted patch, , failed testing.

Status: Needs review » Needs work

The last submitted patch, 51: views-unit_tests-2747167-50.patch, failed testing.

michielnugter’s picture

Assigned: Unassigned » michielnugter
Status: Needs work » Needs review

@Mac_Weber

I'll merge the patches later this morning and continue working on it at the Sevilla Dev Days. I have @lendude sitting next to me so any question I'll have I can have a quick answer to :)

michielnugter’s picture

Status: Needs review » Needs work
michielnugter’s picture

StatusFileSize
new59.33 KB

Merged changes and got another working.

Non-working tests
CachedDataUITest.php
CustomBooleanTest.php
DisplayAttachmentTest.php
DisplayCRUDTest.php
DisplayPathTest.php
DisplayTest.php
ExposedFormUITest.php
FilterBooleanWebTest.php
FilterNumericWebTest.php
HandlerTest.php
OverrideDisplaysTest.php
PreviewTest.php
RowUITest.php
SettingsTest.php
TaxonomyIndexTidUiTest.php
TokenizeAreaUITest.php
ViewsUITourTest.php
ViewTestBase.php
WizardTest.php
XssTest.php

Working tests
AnalyzeTest.php
AccessRoleUITest.php
AreaEntityUITest.php
ArgumentValidatorTest.php
ConfigTranslationViewListUiTest.php
ContentTranslationViewsUITest.php
DefaultViewsTest.php
DisplayExtenderUITest.php
DisplayFeedTest.php
DuplicateTest.php
FieldUITest.php
FilterUITest.php
GroupByTest.php
NewViewConfigSchemaTest.php
QueryTest.php
RearrangeFieldsTest.php
RedirectTest.php
ReportFieldsTest.php
ReportTest.php
StorageTest.php
StyleTableTest.php
StyleUITest.php
TranslatedViewTest.php
UITestBase.php
UnsavedPreviewTest.php
ViewEditTest.php
ViewsListTest.php

michielnugter’s picture

Status: Needs work » Postponed
Related issues: +#2862947: Incorrect field assertions in AssertLegacyTrait

Postponed on #2862947: Incorrect field assertions in AssertLegacyTrait.

As discussed offline with @klausi the issue will not be postponed on the Tour test. It will be removed from the scope of this issue and moved into the scope of the Tour conversion issue (#2767275: Convert web tests to browser tests for tour module).

michielnugter’s picture

Issue tags: +DevDaysSeville
michielnugter’s picture

StatusFileSize
new404.27 KB

Update:

Down to the following 'needs work'
DisplayTest.php
ExposedFormUITest.php
FilterNumericWebTest.php
PreviewTest.php
RowUITest.php
WizardTest.php
XssTest.php

michielnugter’s picture

StatusFileSize
new80.43 KB

Alright, after a lot of work I have all but a few that I moved out of scope passing.

WizardTest: #2863267: Convert web tests of views
Base class is in the views module and @lendude is working on that.

TourTest: #2767275: Convert web tests to browser tests for tour module
Base class is worked on in TourTest. This test should either be converted in that issue or split into a separate issue and postponed on the tour issue.

RowUITest: #2809553: Convert AJAX part of \Drupal\views_ui\Tests\RowUITest to BrowserTestBase
This test requires a JavascriptTestBase conversion.

PreviewTest:#2863563: Convert PreviewTest WebTestBase to BrowserTestBase and JavascriptTestBase
This test requires a partial JavascriptTestBase conversion and requires a new ViewTestBase class for JavascriptTestBase. Split of into a separate issue so we can postpone it on the JTB base class (#2754171: Create a Views and ViewsUI FunctionalJavascriptTestBase class)

Some starting notes on the conversion:

  • I tried to stick as close to the original tests as possible, I never changed anything to improve the tests
  • I removed several t()'s because they make the test fail
  • setUp() needs a param to work
  • The contextual test is JavascriptTestBase now because it tested Javascript. The way it's opened is by adding a class because it cannot work in PhantomJS currently (see #2821724: Create Javascript Tests for Contextual Links).
michielnugter’s picture

Status: Postponed » Needs review

Note: patch contains other 'stuff' (#2862947: Incorrect field assertions in AssertLegacyTrait and ViewTestBase) that needs to be removed before it can be committed.

Status: Needs review » Needs work

The last submitted patch, 61: 2747167-61.patch, failed testing.

dawehner’s picture

@michielnugter
Thank you for your amazing work here!! A general comment, things like #2747167-61: Convert first part of web tests of views_ui should be also added to the issue summary. This makes it much easier for someone to come in and understand the patch, as they have probably read the issue summary upfront.

  1. +++ b/core/modules/views_ui/tests/src/Functional/AnalyzeTest.php
    @@ -25,27 +25,18 @@ class AnalyzeTest extends ViewTestBase {
    -    $this->assertText(t('View analysis'));
    +    $this->assertSession()->titleEquals('View analysis | Drupal');
     
    

    This is a nice improvement

  2. +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
    @@ -64,7 +64,7 @@ public function testCacheData() {
         $this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
     
    -    // Test that a deleted view has no tempstore data.
    +    // Test that a deleted view has no 4tempstore data.
    

    This is kind of an unneeded change ;)

  3. +++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php
    @@ -173,8 +173,7 @@ public function testCustomOptionTemplate() {
    -      $this->setRawContent($output);
    -      $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template');
    +      $this->assertContains('llama', (string) $output);
    

    Nice improvement!

  4. +++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
    @@ -94,7 +93,7 @@ public function testDefaultViews() {
    -    $this->clickViewsOperationLink(t('Duplicate'), '/glossary');
    +    $this->clickViewsOperationLink('Duplicate', '/glossary');
         $random_name = strtolower($this->randomMachineName());
         $this->drupalPostForm(NULL, ['id' => $random_name], t('Duplicate'));
         $this->assertUrl("admin/structure/views/view/$random_name", [], 'The custom view name got saved.');
    @@ -104,13 +103,13 @@ public function testDefaultViews() {
    
    @@ -104,13 +103,13 @@ public function testDefaultViews() {
         // listing page.
         // @todo Test this behavior with templates instead.
         $this->drupalGet('admin/structure/views');
    -    $this->clickViewsOperationLink(t('Disable'), '/glossary/');
    +    $this->clickViewsOperationLink('Disable', '/glossary/');
         // $this->assertUrl('admin/structure/views');
         // $this->assertNoLinkByHref($edit_href);
         // The easiest way to verify it appears on the disabled views listing page
         // is to try to click the "enable" link from there again.
         $this->drupalGet('admin/structure/views');
    -    $this->clickViewsOperationLink(t('Enable'), '/glossary/');
    +    $this->clickViewsOperationLink('Enable', '/glossary/');
         $this->assertUrl('admin/structure/views');
         $this->assertLinkByHref($edit_href);
     
    @@ -127,7 +126,7 @@ public function testDefaultViews() {
    
    @@ -127,7 +126,7 @@ public function testDefaultViews() {
         // Test deleting a view.
         $this->drupalLogin($this->fullAdminUser);
         $this->drupalGet('admin/structure/views');
    -    $this->clickViewsOperationLink(t('Delete'), '/glossary/');
    +    $this->clickViewsOperationLink('Delete', '/glossary/');
         // Submit the confirmation form.
         $this->drupalPostForm(NULL, [], t('Delete'));
         // Ensure the view is no longer listed.
    @@ -140,7 +139,7 @@ public function testDefaultViews() {
    
    @@ -140,7 +139,7 @@ public function testDefaultViews() {
     
         // Delete all duplicated Glossary views.
         $this->drupalGet('admin/structure/views');
    -    $this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
    +    $this->clickViewsOperationLink('Delete', 'duplicate_of_glossary');
         // Submit the confirmation form.
         $this->drupalPostForm(NULL, [], t('Delete'));
     
    @@ -148,7 +147,7 @@ public function testDefaultViews() {
    
    @@ -148,7 +147,7 @@ public function testDefaultViews() {
         $this->assertResponse(200);
     
         $this->drupalGet('admin/structure/views');
    -    $this->clickViewsOperationLink(t('Delete'), $random_name);
    +    $this->clickViewsOperationLink('Delete', $random_name);
         // Submit the confirmation form.
         $this->drupalPostForm(NULL, [], t('Delete'));
    
    @@ -178,7 +177,7 @@ public function testSplitListing() {
         // Enable the view.
    -    $this->clickViewsOperationLink(t('Enable'), '/test_view_status/');
    

    I wonder whether we could minimize the patch size by applying a string casting inside clickViewsOperationLink

  5. +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
    @@ -158,9 +160,14 @@ public function testMenuOptions() {
    +    $menu_options = array_map(function($Element) {
    +      return $Element->getText();
    

    Nitpick: Let's use $element instead of $Element

  6. +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
    @@ -235,6 +197,9 @@ public function testViewStatus() {
    +    // Reset cache to apply the changes above.
    +    $this->resetAll();
    +
    
    @@ -254,6 +219,9 @@ public function testDisplayTitleInButtonsXss() {
     
    +      // Reset cache to apply the changes above.
    +      $this->resetAll();
    +
    
    @@ -317,6 +285,10 @@ public function testHideDisplayOverride() {
    +
    +    // Reset cache to apply the changes above.
    +    $this->resetAll();
    

    Do you understand why this was not needed before?

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new15.09 KB
new77 KB

Thanks very much for the review and kind words!

1,3: Thanks!
2: I inject random 4's into my patches to see if everyone is paying attention ;)
4: Used a string cast, also works!
5: Done!
6: Let's see if the testbot requires them, removed them in this patch. We're having simlar problems in #2863268: Convert web tests to browser tests for tracker module and it only fails on php 7.1.

Furthermore:
- Restored original base classes to make the non-converted tests work
- Still can't get 2 tests to work. One with language problems and 1 with radio buttons. I can't get radio buttons to work, anyone know a place where there are working radio buttons in a BrowserTestBase?

Status: Needs review » Needs work

The last submitted patch, 65: 2747167-65.patch, failed testing.

michielnugter’s picture

Issue summary: View changes

I've been discussing with @lendude offline.

Views and views_ui are important to get in fast because a lot of other conversions will be blocked without them. We both have a small set of tests that are giving us a lot of trouble. I propose to split these off into separate issues so we can get the views and views_ui conversions in.

Does this sound like a good idea and should I start splitting them off?

klausi’s picture

Title: Convert web tests of views_ui » Convert first part of web tests of views_ui

Yes, I think that makes sense to make progress here.

michielnugter’s picture

Ok, cool! Thanks for the reply. I'll split the problematic tests into separate issues and make sure the rest pass on all php versions.

michielnugter’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new8.83 KB
new67.94 KB

Created new issues for the 2 remaining tests (Updated IS here):
#2864610: Convert ExposedFormUITest in views_ui module to BrowserTestBase
#2864613: Convert ViewEditTest in views_ui module to BrowserTestBase

Will post my work-in-progress there.

New patch excludes these tests, let's see what it does now.

dawehner’s picture

How convinced are you about these changes?

  1. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
    @@ -0,0 +1,117 @@
    +  }
    +}
    

    Nitpick: Requires an additional new line :P

  2. +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
    @@ -410,16 +421,25 @@ protected function assertNoLinkByHref($href) {
    diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    
    diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    index 8f50914..1fe011a 100644
    
    index 8f50914..1fe011a 100644
    --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    
    --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    
    +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -175,7 +175,7 @@ public function testLegacyFieldAsserts() {
    
    @@ -175,7 +175,7 @@ public function testLegacyFieldAsserts() {
     
         // Test that the assertion fails correctly if no value is passed in.
         try {
    -      $this->assertNoFieldById('description');
    +      $this->assertNoFieldById('edit-description');
           $this->fail('The "description" field, with no value was not found.');
         }
         catch (ExpectationException $e) {
    @@ -184,7 +184,7 @@ public function testLegacyFieldAsserts() {
    
    @@ -184,7 +184,7 @@ public function testLegacyFieldAsserts() {
     
         // Test that the assertion fails correctly if a NULL value is passed in.
         try {
    -      $this->assertNoFieldById('name', NULL);
    +      $this->assertNoFieldById('edit-name', NULL);
           $this->fail('The "name" field was not found.');
         }
         catch (ExpectationException $e) {
    

    Oh so the test coverage was actually broken? Negative assertions are always tricky.

Status: Needs review » Needs work

The last submitted patch, 70: 2747167-70.patch, failed testing.

michielnugter’s picture

StatusFileSize
new5.2 KB
new68.67 KB

Fixed some incorrect namespaces and the nitpick.

Yeah the negative assertions were broken, really difficult to get those right. The actual fix is in #2862947: Incorrect field assertions in AssertLegacyTrait btw, this patch contains a rough version to make the tests pass. These changes should be removed before commit. The ViewTestBase must also be removed and should use the one @lendude is making in in the views conversion.

michielnugter’s picture

Status: Needs work » Needs review

@dawehner
I feel confident on the made changes. They are minimal in every step and were all required to get it to run on phpunit.

lendude’s picture

The ViewTestBase must also be removed and should use the one @lendude is making in in the views conversion.

Yeah the one in #2863267: Convert web tests of views contains some additional tweaks for BrowserTestBase compatibility.

Status: Needs review » Needs work

The last submitted patch, 73: 2747167-73.patch, failed testing.

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new1023 bytes
new68.72 KB

Some wrong namespaces now fixed. Hope it passes, if it does I'll create a clean patch without additions to merge it with views tests.

michielnugter’s picture

StatusFileSize
new60.33 KB

Green never looked better :) Man it feels good to have this one pass.

Patch without extra's, this one will fail and is only for merging into the views conversion or to be committed after views and the improvement for AssertLegacyTrait is in.

Status: Needs review » Needs work

The last submitted patch, 78: 2747167-78.patch, failed testing.

jofitz’s picture

@michielnugter would you mind summarising the issue IDs this requires and marking this as postponed for now. Feels good to be so close to getting this first chunk in!

michielnugter’s picture

Issue summary: View changes
Status: Needs work » Postponed

Updated the IS and postponed the issue.

jofitz’s picture

@michielnugter++

michielnugter’s picture

Issue summary: View changes
StatusFileSize
new436 bytes
new60.86 KB

Updated patch with deprecation warning on the old UITestbase.

michielnugter’s picture

Issue summary: View changes

Moved the WizardTest out of the views scope and into a separate issue: #2867777: Convert views WizardTestBase tests to phpunit.

IS has been updated.

michielnugter’s picture

Issue tags: +phpunit initiative
michielnugter’s picture

Status: Postponed » Needs review

Let's see what this does now views is in :)

Status: Needs review » Needs work

The last submitted patch, 83: 2747167-83.patch, failed testing.

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB
new61.25 KB

Right, slight API changes from the used patch and the one that landed for the field assertions. These are now fixed and the test should go green..

lendude’s picture

Some feedback/nits:

  1. +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
    @@ -25,7 +25,7 @@ class ConfigTranslationViewListUiTest extends UITestBase {
    +  protected function setUp($import_test_views = TRUE) {
         parent::setUp();
    

    $import_test_views should be passed to the parent, this is missed on a number of tests

  2. +++ b/core/modules/user/tests/src/Functional/AccessRoleUITest.php
    --- a/core/modules/views_ui/src/Tests/UITestBase.php
    +++ b/core/modules/views_ui/src/Tests/UITestBase.php
    
    +++ b/core/modules/views_ui/src/Tests/UITestBase.php
    +++ b/core/modules/views_ui/src/Tests/UITestBase.php
    @@ -2,6 +2,8 @@
    
    @@ -2,6 +2,8 @@
     
     namespace Drupal\views_ui\Tests;
     
    +@trigger_error('\Drupal\views_ui\Tests\UITestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\views_ui\Functional\UITestBase', E_USER_DEPRECATED);
    +
    

    missing @deprecated

  3. +++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php
    @@ -16,6 +16,7 @@ class DisplayAttachmentTest extends UITestBase {
    +   * .
    

    ?

  4. +++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
    @@ -69,10 +68,11 @@ public function testFieldUI() {
    +    // @todo Get this test working under BrowserTestBase.
    +//    $edit_handler_url = '/admin/structure/views/ajax/handler-group/test_view/default/field/name';
    +//    $this->drupalGet($edit_handler_url);
    +//    $data = Json::decode($this->getRawContent());
    +//    $this->assertEqual($data[3]['dialogOptions']['title'], 'Configure aggregation settings for field Views test: Name');
    

    if we have a follow up for this, can we add it to the comment? And in the views conversion I did $data = Json::decode($this->getSession()->getPage()->getContent()); and that seemed to do the trick.

michielnugter’s picture

Status: Needs review » Needs work

Thanks for the review, back to needs work for that.

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new7.79 KB
new7.79 KB

And fixed!

Thanks for the hint on FieldTestUI, worked perfectly!

michielnugter’s picture

StatusFileSize
new60.41 KB

Grr, wrong file..

interdiff contains a remove because I rolled the last patch with --find-copies.

The last submitted patch, 91: interdiff-88-91.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 92: 2747167-91.patch, failed testing.

lendude’s picture

Nittiest of nits:

+++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
@@ -69,9 +69,10 @@ public function testFieldUI() {
+    // @todo Get this test working under BrowserTestBase.

Think we got this to work now! So no need for the @todo

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new2.36 KB
new60.27 KB

Made a bit of a mess I think with my previous patch. I seem to have added deprecation warnings on the new UITestBase class and reverted some of the made changes.

New patch should do everything right and I removed the @todo line :)

lendude’s picture

Applied the patch and checked that everything gets moved to the right spot and the deprecations are on the right classes. All looks good. Only thing I can think of is moving WizardTest back into scope here. The base class is available now and it passes when simply moved.

michielnugter’s picture

Issue summary: View changes
Status: Needs review » Needs work

Sounds like a good plan, I'll work on this sometime today.

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new34.26 KB
new93.66 KB

Lots of things changed since the last attempt at ExposedFormUITest and ViewEditTest, lets see if they pass now as well.

Status: Needs review » Needs work

The last submitted patch, 99: 2747167-99.patch, failed testing.

michielnugter’s picture

StatusFileSize
new2.65 KB
new92.11 KB

Right, still failing (among other fails?).

This one only contains the WizardTest extra since #95 and if ok should be able to get committed.

michielnugter’s picture

Status: Needs work » Needs review
lendude’s picture

Status: Needs review » Needs work

@michielnugter stop doing too many things at once :)

Pretty sure #101 patch contains a couple of extra lines you didn't want in there, about 30kb worth of them :D

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new2.12 KB
new60.91 KB

Let's see how I do without the massive headache.. :)

Still don't completely understand the interdiff for UiTestBase but that one keeps beeing weird, it's the same as an older version as far as I can tell.

lendude’s picture

+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -1,11 +1,16 @@
+@trigger_error('\Drupal\views_ui\Tests\UITestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.x. Instead, use \Drupal\Tests\views_ui\Functional\UITestBase', E_USER_DEPRECATED);

This now needs to go inside the setUp method, see #2876145: ConfigTranslationViewListUiTest is a WTB test in the Functional namespace

dawehner’s picture

+++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php
@@ -116,8 +116,8 @@ public function testEditUI() {
     $this->assertEqual(count($xpath), 1, 'The views sql is shown.');
-    $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
-    $this->assertTrue(strpos($xpath[0], "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
+    $this->assertFalse(strpos($xpath[0]->getText(), 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
+    $this->assertTrue(strpos($xpath[0]->getText(), "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');

We could use assertContains here. Any thoughts about it?

michielnugter’s picture

StatusFileSize
new2.69 KB
new60.99 KB

Fixed #105

#106:
Even though it's not ideal in this way this is the smallest change possible. the goal for the conversions up till now has been to keep the changes to a minimum to ease the review and commit process. Not 100% sure here as I already changed this line of code, should we completely fix each line in the tests to not use deprecated methods and the proper ones or stick with the minimum change policy?

dawehner’s picture

Not 100% sure here as I already changed this line of code, should we completely fix each line in the tests to not use deprecated methods and the proper ones or stick with the minimum change policy?

I guess I just don't care much enough about that :) We can indeed always come back later and improve things.

Should we postpone this issue for now onto the other one, where we figure out how to actually deprecate test classes?

michielnugter’s picture

Status: Needs review » Postponed

I guess I just don't care much enough about that :) We can indeed always come back later and improve things.

I care up to the level that I know what to do on reviews and conversions. I'm strongly towards not changing if it's not needed to make the conversions low impact, I'm not going to set anything back to Needs review though. We'll have to do the fun initiative to remove all deprecated code some other time, the current BrowserTestBase tests are full of deprecated code usage..

Should we postpone this issue for now onto the other one, where we figure out how to actually deprecate test classes?

Agree, let's settle that policy first.

dawehner’s picture

We'll have to do the fun initiative to remove all deprecated code some other time, the current BrowserTestBase tests are full of deprecated code usage..

You are right, this is totally fair.

michielnugter’s picture

Issue tags: +Needs followup

As discussed in #2876145: ConfigTranslationViewListUiTest is a WTB test in the Functional namespace the following test needs to either be moved into scope for this issue or a follow-up must be created to convert the ConfigTranslationViewListUiTest test to WebTestBase. Adding Needs followup tag for now.

michielnugter’s picture

Status: Postponed » Needs review
Issue tags: -Needs followup
StatusFileSize
new2.68 KB
new61.22 KB

Turned out that ConfigTranslationViewListUiTest was already in this patch :) Deprecation policy was settled and in line with the current state of this issue.

Needed a re-roll now though as the file was moved.

I think it's ready to go, one final review before RTBC and test-bot run would be very much appreciated :)

lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Manually checked the patch again.

All moves look good. Follow ups have been opened for the remaining 5 tests. Base class deprecation is good. Lets do this!

Removed the wizardtest from the IS since it's in scope now.

lendude’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, jumped the gun, I think we missed \Drupal\taxonomy\Tests\Views\TaxonomyParentUITest

michielnugter’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB
new62.33 KB

And it's back.

Interdiff still contains garbage, it really doesn't like the --find-copies.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Rechecked, \Drupal\views_ui\Tests\UITestBase now only gets used by 4 classes, and we have followups for all of them.

The rest is still good.

dawehner’s picture

Nice work!

  • catch committed 1105324 on 8.4.x
    Issue #2747167 by michielnugter, dawehner, Lendude, mglaman, Mac_Weber,...
catch’s picture

Version: 8.4.x-dev » 8.3.x-dev

This looks great, really happy to see this one ready.

Committed/pushed to 8.4.x, thanks!

8.3.x patch release today, so leaving RTBC against 8.3.x for cherry-pick either late today or more likely tomorrow.

lendude’s picture

@catch thanks so much for committing!

And thanks everybody that put time into this one. Really great to see another big chunk go in.

michielnugter’s picture

@catch++

Thanks for the commit! Awesome to see it finally getting in after so much work!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 115: 2747167-115.patch, failed testing. View results

lendude’s picture

Queued the patch for 8.3.x

michielnugter’s picture

Status: Needs work » Reviewed & tested by the community

Stil green then, back to rtbc

catch’s picture

Status: Reviewed & tested by the community » Fixed

Cherry-picked to 8.3.x, thanks!

  • catch committed 9229cac on 8.3.x
    Issue #2747167 by michielnugter, dawehner, Lendude, mglaman, Mac_Weber,...

Status: Fixed » Closed (fixed)

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