As I have come to find while writing tests many themes can screw up the testing framework with < span > tags and what not inside the < a > tag. This can be solved by looking for the text directly inside the link element or nested within.

The following will look the same in the browser.

<a>foobar<a>
<a><span>foobar</span></a>

But only the first will work with the assertLink(), assertNoLink(), and clickLink() methods.

Comments

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Needs review
FileSize
2.14 KB
PASSED: [[SimpleTest]]: [MySQL] 22,126 pass(es). View
thedavidmeister’s picture

Version: 7.x-dev » 8.x-dev
Assigned: boombatower » Unassigned
Status: Needs review » Needs work
Issue tags: +Needs tests

This is still an issue in D8.

Patch no longer applies in D7.

curl -0 https://drupal.org/files/issues/855726-nested-text.patch | git apply
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2189  100  2189    0     0   1815      0  0:00:01  0:00:01 --:--:--  2229
error: simpletest/drupal_web_test_case.php: No such file or directory

I feel like this XPath expression that assertLink(), assertNoLink() and clickLink() are all sharing could be centralised rather than duplicating it, but that might be out of scope for this issue.

Could we write tests for this? Assert links in some strings that we know should work but don't because of this bug?

#2094585: [meta] [experimental] Core review bonus for #2072647: #theme 'maintenance_page' should support render arrays in #content.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.

arunkumark’s picture

Issue summary: View changes

Patch no longer applies cleanly.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.

LoMo’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

Re #5; no, indeed, it does not apply at all. The pattern still exists, but is spread around pretty well. Let's try a re-roll and see if it breaks anything... Then maybe some tests. ;-)

I actually made these changes on my 8.4.x-dev local checkout, but I think it should also apply to 8.3.x; I'll leave the version on 8.3.x-dev to verify that, too.

Status: Needs review » Needs work

The last submitted patch, 7: link_handling_should-855726-7.patch, failed testing.

LoMo’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Needs work » Needs review
FileSize
3.88 KB

Ah... found one more since the clickLink() function in WebTestBase changed significantly, but still used the original pattern. And it seems that this doesn't apply on the 8.3.x branch, so I would need to re-roll it slightly differently if it were to be applied there.

Status: Needs review » Needs work

The last submitted patch, 9: link_handling_should-855726-9.patch, failed testing.

LoMo’s picture

Okay, this patch should apply against the 8.3.x-dev branch...

LoMo’s picture

Status: Needs work » Needs review
LoMo’s picture

And this patch should apply on the 8.4.x-dev branch...

Status: Needs review » Needs work

The last submitted patch, 13: link_handling_should-855726-13.patch, failed testing.

LoMo’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

Let's try that again... This is the 8.4.x version. The version for 8.3.x (#11) already passes all tests, so at least doesn't break anything. ;-)

LoMo’s picture

The new test should fail (against 8.4.x-dev)

LoMo’s picture

But it should pass with this patch (adapted from original pattern, since that did not seem to work). Actually, the pattern used in the clickLink() function turned out to work, while the pattern in the assertLink() did not, so I changed all instances to the pattern used by "clickLink(), which happens to be much simpler, but seems to catch all links by label quite well".

LoMo’s picture

And this test patch is for the 8.3.x branch. Tests should fail, but pass in a "complete" patch.

LoMo’s picture

This is the combined patch that should apply and run without failures on the 8.3.x branch.

The last submitted patch, 16: link_handling_should-855726-16-test-only.patch, failed testing.

The last submitted patch, 17: link_handling_should-855726-17-complete.patch, failed testing.

The last submitted patch, 18: link_handling_should-855726-18-test-only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 19: link_handling_should-855726-19-complete.patch, failed testing.