Problem/Motivation

We recently changed the checkbox widget to be checkboxes that have been added trough js, we're currently doing the same thing for dropdown widget (#2713875: Use GET request for dropdown widget). There is no test for that though.
This test can also be used a base for a test for the dropdown widget in the other issue.

Proposed resolution

Write a functional javascript test to test this.

Remaining tasks

Actually fix the test and extend it to be more specific.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

borisson_ created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, js-test.patch, failed testing.

The last submitted patch, js-test.patch, failed testing.

The last submitted patch, js-test.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
FileSize
451 bytes
4.63 KB
borisson_’s picture

#5 was needed because I forgot the @group annotation.

Status: Needs review » Needs work

The last submitted patch, 5: javascript_test_for-2719065-5.patch, failed testing.

The last submitted patch, 5: javascript_test_for-2719065-5.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
FileSize
2.11 KB
5.35 KB

Status: Needs review » Needs work

The last submitted patch, 9: javascript_test_for-2719065-9.patch, failed testing.

The last submitted patch, 9: javascript_test_for-2719065-9.patch, failed testing.

borisson_’s picture

FileSize
558 bytes
5.3 KB

I spent a big part of yesterday having another look at this, and I can't figure out why there the widget doesn't display links. I really don't know. I did figure out we don't need as many modules installed, changed that.

borisson_’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
862 bytes
5.54 KB
277.4 KB

I figured it out! We needed to add the url_processor_handler processor to the facet for it to work. Test should be green now, woo.

It looks like there's still something wrong with the js though, I'll try to figure that out now.

This also means that this test needs to be expanded.

borisson_’s picture

Issue summary: View changes
FileSize
1.06 KB
6.06 KB
19.65 KB

I expanded the test, this is now looking quite good already. I did see that nothing happens when selecting a checkbox, attached screenshot from inside the test.

Because I don't think the code to take a screenshot should end up on the test-infrastructure, I'll paste it here if someone wants to see what happens.

    $this->getSession()->executeScript('document.body.style.backgroundColor = "#fff";');
    $shot = $this->getSession()->getScreenshot();
    file_put_contents('screenshot.jpg', $shot);

StryKaizer’s picture

FileSize
5.74 KB

Needed reroll, see attachment.

Looks like you can trigger the checkbox by using

$page->findField('item (3)')->click();
borisson_’s picture

FileSize
824 bytes
5.95 KB

Thanks @StryKaizer, that helped!

borisson_’s picture

Issue tags: -Needs tests, -JavaScript +DevDaysMilan
FileSize
2 KB
5.74 KB

Spoke with some testing wizards at dev days, they suggested some improvements for this test. If the bot agrees, I think we can commit this.

  • borisson_ committed 1fbb2b9 on 8.x-1.x
    Issue #2719065 by borisson_, StryKaizer: Javascript test for widget
    
borisson_’s picture

Status: Needs review » Fixed
Lendude’s picture

Spoke with some testing wizards at dev days

:)

+++ b/tests/src/FunctionalJavascript/WidgetJSTest.php
@@ -0,0 +1,187 @@
+    $this->assertTrue(strpos($current_url, 'search-api-test-fulltext?f%5B0%5D=llama%253Aitem') !== FALSE);

Did you look at getting this from the href? Just curious if you tried and ran into something or if you just had enough of this and figured "green is green". Looking really nice now either way.

borisson_’s picture

I did look at getting that from the href, but there was a problem with the encoding being different and even with url encoding both I couldn't get them to match up.

Status: Fixed » Closed (fixed)

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