Problem/Motivation

The Simpletest PreviewTest needs to be converted to PHPUnit. The original test has tests that need to be covered in BrowserTestBase and had Ajax related tests that need to go into JavascriptTestBase.

This issue is split off from #2747167: Convert first part of web tests of views_ui.

Proposed resolution

Remaining tasks

Commit issues that this issue requires and is postponed on:
#2747167: Convert first part of web tests of views_ui

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michielnugter created an issue. See original summary.

michielnugter’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
33.12 KB
37.12 KB

Patch with working tests if you apply the issues this one is postponed on. One of the postponed issues is applied to

michielnugter’s picture

Issue summary: View changes

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

Status: Needs review » Needs work

The last submitted patch, 2: 2863563-2-with-2754171.patch, failed testing.

michielnugter’s picture

Component: phpunit » views_ui.module
Issue tags: +phpunit initiative

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

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

Version: 8.5.x-dev » 8.6.x-dev

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

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.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

Issue summary: View changes
Status: Needs work » Needs review
FileSize
36.81 KB

Worked on this in a duplicate issue, lets move it here.

To quote myself for the other issue:
It turns out that ajax in preview doesn't actually work currently! It just shows the commands page when using any ajax link in preview. I can reproduce this in 8.7.x.
Quick test on a 8.5.3 site worked without issue so this might be a recent break.

Works fine when I do a fresh install using Unami, so my dev env was just broken

Status: Needs review » Needs work

The last submitted patch, 10: 2809551-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Lendude’s picture

Status: Needs work » Needs review
FileSize
3.73 KB
37.77 KB

Ok so it helps if you are on the view edit page and not on the preview page when working with the preview with ajax....and the test views actually 'use ajax'.

This is an attempt at a minimal conversion, hence all the helper methods, which we can probably do without.

Status: Needs review » Needs work

The last submitted patch, 12: 2863563-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Lendude’s picture

Status: Needs work » Needs review
FileSize
6.92 KB
41.9 KB

ok so these views are used elsewhere, lets add some new ones.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Great work! Conversion looks good.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php
    @@ -0,0 +1,306 @@
    +
    +
    

    nit two blank lines here

  2. +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/PreviewTest.php
    @@ -0,0 +1,306 @@
    +  /**
    +   * Asserts that an element has a given class.
    +   *
    +   * @param \Behat\Mink\Element\NodeElement $element
    +   *   The element to test.
    +   * @param string $class
    +   *   The class to assert.
    +   * @param string $message
    +   *   (optional) A verbose message to output.
    +   */
    +  protected function assertClass(NodeElement $element, $class, $message = NULL) {
    +    if (!isset($message)) {
    +      $message = "Class .$class found.";
    +    }
    +    $this->assertTrue(strpos($element->getAttribute('class'), $class) !== FALSE, $message);
    +  }
    

    is this worth making a trait or in the base assert? it feels like a useful feature

Lendude’s picture

Thanks for the reviews!

#16.1 fixed
#16.2 nah I don't think so, I think the usual case is that a class is used to find the element you are looking for, so you are indirectly testing for it. Directly testing for the existence of a class is not very common I think. Not often where this is a functional requirement. Also, I think, we should keep the API to a minimum when we can, less to maintain.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Let's see what Lee thinks about #17.2.

borisson_’s picture

#17.2 - this could also be used to add testcoverage for #3013452: no_striping option for table rows is not respected, but only 1 other usecase not be sufficient to move this to a base class.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 97ac5b70c2 to 8.7.x and 5927122ab5 to 8.6.x. Thanks!

diff --git a/core/modules/views_ui/tests/src/Functional/PreviewTest.php b/core/modules/views_ui/tests/src/Functional/PreviewTest.php
index bca8b49185..b76e464c8c 100644
--- a/core/modules/views_ui/tests/src/Functional/PreviewTest.php
+++ b/core/modules/views_ui/tests/src/Functional/PreviewTest.php
@@ -2,9 +2,6 @@
 
 namespace Drupal\Tests\views_ui\Functional;
 
-use Drupal\Component\Serialization\Json;
-use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
-
 /**
  * Tests the UI preview functionality.
  *

Unused use. Fixed on commit.

  • alexpott committed 97ac5b7 on 8.7.x
    Issue #2863563 by Lendude, michielnugter, larowlan: Convert PreviewTest...

  • alexpott committed 5927122 on 8.6.x
    Issue #2863563 by Lendude, michielnugter, larowlan: Convert PreviewTest...

Status: Fixed » Closed (fixed)

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