Comments

naveenvalecha created an issue. See original summary.

naveenvalecha’s picture

Issue summary: View changes
naveenvalecha’s picture

Title: Convert rest of taxonomy web tests to browser tests » Convert web tests to browser tests for taxonomy module Part -2
Status: Postponed » Active
goz’s picture

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.

naveenvalecha’s picture

naveenvalecha’s picture

Issue summary: View changes

updating IS

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.

nlisgo’s picture

Status: Active » Needs review
Issue tags: +Nashville2018

Converting:

  • \Drupal\taxonomy\Tests\TermTranslationTest to \Drupal\Tests\taxonomy\Functional\TermTranslationTest
  • \Drupal\taxonomy\Tests\RssTest to \Drupal\Tests\taxonomy\Functional\RssTest
nlisgo’s picture

StatusFileSize
new1.75 KB

Status: Needs review » Needs work

The last submitted patch, 11: 2887134-11.patch, failed testing. View results

borisson_’s picture

[Composer\DependencyResolver\SolverProblemsException]                                                                         
Problem 1                                                                                                                     
       - The requested package phpunit/phpunit ^7.1 exists as phpunit/phpunit[6.5.8] but these are rejected by your constraint.  

Script Drupal\Core\Composer\Composer::upgradePHPUnit handling the drupal-phpunit-upgrade-check event terminated with an exception
  ERROR: PHPUnit testing framework version 6 or greater is required when running on PHP 7.0 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this.

This was the reason the test failed earlier, I tried to retest to try make this pass, but it gave the same issue.

nlisgo’s picture

I'm not sure how the entry for phpunit was added to composer, I will remove it and resupply the patch.

nlisgo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB

Status: Needs review » Needs work

The last submitted patch, 15: 2887134-15.patch, failed testing. View results

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.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new6.98 KB
new5.92 KB

Golly, what a pain: #2767655-54: Allow WebAssert to inspect also hidden fields :-)

I converted TermTest::testTermReorder() before I realized it's supposed to be a JS test. However, I think I got it and we don't need the JS coverage, unless dragging the items around is important.

In RssTest::testTaxonomyRss() I was unable to get the css selector to work, so I verified that it's an RSS feed by checking the Content-Type header.

Status: Needs review » Needs work

The last submitted patch, 19: 2887134_19.patch, failed testing. View results

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new7.16 KB
new485 bytes

Bad namespace! No biscuit!

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, this is looking great now.

mile23’s picture

Status: Reviewed & tested by the community » Needs work

Thanks. But there are still some tests in taxonomy/src/Tests that we need to convert.

mile23’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new14.06 KB
new4.24 KB

This patch finishes the move. All that remains in taxonomy/src/Tests is a base class and two traits, all deprecated.

It also turns #2969805: Fix "Drupal\taxonomy\Tests\TaxonomyTranslationTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTranslationTestTrait" into a duplicate.

lendude’s picture

Status: Needs review » Needs work

@Mile23++ looking great.

  1. +++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php
    @@ -106,7 +106,8 @@ public function testTaxonomyRss() {
    -    $this->assertTrue(!empty($this->cssSelect('rss[version="2.0"]')), "Feed page is RSS.");
    +    $assert = $this->assertSession();
    +    $assert->responseHeaderContains('Content-Type', 'application/rss+xml');
    

    Not quite a 1:1 conversion, can we check the version too? Did a quick search and I didn't see any other test checking this, so I feel we are loosing a bit of coverage here.

  2. +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php
    @@ -42,15 +43,23 @@ public function testTermIndentation() {
    +    // Because we can't post hidden form elements, we have to change them in
    +    // code here, and then submit.
    +    foreach ($hidden_edit as $field => $value) {
    +      $node = $assert->hiddenFieldExists($field);
    +      $node->setValue($value);
    +    }
    

    nice!

  3. +++ b/core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php
    @@ -125,9 +134,27 @@ protected function setUp() {
    -    $this->drupalGet('node/add/article');
    +    $this->drupalGet(Url::fromRoute('node.add', ['node_type' => 'article']));
    

    Nice refactor, but I'm guessing its unrelated to getting the test to pass?

NW to get an answer on #1

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new14.01 KB
new1.83 KB

Thanks.

Re: #25

1) Lots of hair-pulling about that. It turns out that $session->getContent()->find() only works for HTML, even using an xpath. Must use $session->getDriver()->find().

2) All praise to @berdir. #2767655-54: Allow WebAssert to inspect also hidden fields

3) Reverted.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

Re #26.1: I think it is because of \Behat\Mink\Element\DocumentElement::getXpath that every xpath gets prefixed by //html

This looks good to me.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 9547959081 to 8.7.x and 917f75bc59 to 8.6.x. Thanks!

  • alexpott committed 9547959 on 8.7.x
    Issue #2887134 by Mile23, nlisgo, naveenvalecha, Lendude: Convert web...

  • alexpott committed 917f75b on 8.6.x
    Issue #2887134 by Mile23, nlisgo, naveenvalecha, Lendude: Convert web...
tacituseu’s picture

This introduced test failures on 8.7.x:
https://www.drupal.org/pift-ci-job/1065875
https://www.drupal.org/pift-ci-job/1065877

Drupal\Tests\taxonomy\Functional\TaxonomyTermIndentationTest
fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-1152.xml:
PHPunit Test failed to complete; Error: PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\taxonomy\Functional\TaxonomyTermIndentationTest
.                                                                   1 / 1 (100%)

Time: 6.11 seconds, Memory: 4.00MB

OK (1 test, 15 assertions)

...
Remaining deprecation notices (1)

  1x: assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.
    1x in TaxonomyTermIndentationTest::testTermIndentation from Drupal\Tests\taxonomy\Functional

  • alexpott committed 0a7af37 on 8.6.x
    Revert "Issue #2887134 by Mile23, nlisgo, naveenvalecha, Lendude:...

  • alexpott committed 7f685d6 on 8.7.x
    Revert "Issue #2887134 by Mile23, nlisgo, naveenvalecha, Lendude:...
alexpott’s picture

Status: Fixed » Needs work

@tacituseu thanks! Reverted from both branches.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new801 bytes
new14.24 KB

Took out the deprecated call.

Not sure how good of an idea it is to do things like #2970052: Fix "assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead" already, since it will make doing minimal conversions harder and harder.

voleger’s picture

Status: Needs review » Reviewed & tested by the community

Changes in #35 addressed #31
Test looks good
+1 for RTBC

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php
@@ -42,15 +43,23 @@ public function testTermIndentation() {
+    // Because we can't post hidden form elements, we have to change them in

No, I don't think we should do this. We are quitting the user perspective, which should be the core of functional tests. My point is that this test should be a JS test. We should do what the user is doing and not hack into the form hidden inputs.

I'm moving back to NR for an evaluation.

lendude’s picture

Status: Needs review » Reviewed & tested by the community

@claudiu.cristea the scope here is not to make the test better, it's to convert it to BrowserTestBase. The original WebTestBase did exactly the same thing except that Simpletest is way less concerned about what a user can and cannot do, so it didn't involve any hacky workarounds to submit hidden fields.

Would it be nice to also have a Javascript test for this? Sure, but that is not the scope of this issue.

Moving back to RTBC per #36

claudiu.cristea’s picture

@Lendude, till now the rule was to make the conversion for such cases. But if we plan to keep this patch simple, at least we need a followup to convert TaxonomyTermIndentationTest into a JS test.

lendude’s picture

mile23’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed dc4adc5723 to 8.7.x and 277a7055e8 to 8.6.x. Thanks!

  • alexpott committed dc4adc5 on 8.7.x
    Issue #2887134 by Mile23, nlisgo, Lendude, naveenvalecha: Convert web...

  • alexpott committed 277a705 on 8.6.x
    Issue #2887134 by Mile23, nlisgo, Lendude, naveenvalecha: Convert web...

Status: Fixed » Closed (fixed)

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