Problem/Motivation
We created Views widget plugin but we're missing tests.
Proposed resolution
Create new test class for functional tests and create test case that clicks through View widget and checks if everything works as expected and entities are selected (events are emitted).
Remaining tasks
- write patch
- review
User interface changes
N/A
API changes
New test class and tests are added.
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | interdiff.txt | 1.11 KB | slashrsm |
| #26 | 2376639_26.patch | 6.72 KB | slashrsm |
| #23 | interdiff.txt | 5.63 KB | slashrsm |
| #23 | 2376639_23.patch | 5.61 KB | slashrsm |
| #21 | write_functional_tests-2376639-21.patch | 1.72 KB | samuel.mortenson |
Comments
Comment #1
slashrsm commentedComment #2
slashrsm commentedComment #3
slashrsm commentedComment #4
devlada commentedworking on this...
Comment #5
marcoscanoFreeing up the issue, please feel free to re-assign it if needed.
Please note that inside the patch uploaded in #2376643-4: Write functional tests for Upload widget there is a work-in-progress of this test, can be used as a starting point.
Comment #6
gaurav.goyal commentedWorking on this.
Comment #7
gaurav.goyal commentedInitial patch for the starting point. Currently, it does not include the actual test case.
Comment #8
gaurav.goyal commentedChanging status to Need review.
Comment #11
gaurav.goyal commentedFixed module names and permissions.
Comment #14
gaurav.goyal commentedUpdated patch. I've created a view and added its configuration file in entity_browser_test module.
Hoping it will come green this time :)
Comment #15
gaurav.goyal commentedComment #16
gaurav.goyal commentedImproved documentation of the patch.
Comment #17
thenchev commentedNo need for this anymore. Look at #2304909: Relax requirement for @file when using OO Class or Interface per file
You can remove system, user, file, field_ui, views, entity_reference
we only have to define what we need the dependencies are loaded automatically.
You can just {@inheritdoc} here.
We probably don't need all of these. Check which are not needed and remove.
Not really needed.
Do we need this?
Instead of creating an entity browser like this you could export it in the configuration synchronization and place it in the test module.
If you export the browser you don't need this just add the permission when you create the user.
also if im not mistaken => 'checks if everything works as expected and entities are selected' We don't cover this part yet.
Comment #18
sylus commentedBecause simpletest will be replaced with PHPUnit in 8.2.x should these tests instead leverage BrowserTestBase? Like the following:
http://cgit.drupalcode.org/video_embed_field/tree/tests/src/FunctionalJa...
Though I guess this would only be for 8.2.x branch? As the notes currently say:
"The main limitation of BrowserTestBase currently is that it cannot use JavaScript and AJAX. If your tests require that, you will need to use the old WebTestBase until JavaScript support is added to BrowserTestBase."
Comment #19
slashrsm commentedThat would make a lot of sense.
Comment #20
slashrsm commentedComment #21
samuel.mortensonBased on the feedback in #17 and that the current patch doesn't actually test the View widget, I've written a minimalist patch using BrowserTestBase (per #18) that just tests the submit functionality of the widget. We can expand upon this later by testing more complex use cases, but this is nice because it scopes the test coverage to the View widget. If people like what I've done here I can roll a similar patch for #2376643: Write functional tests for Upload widget.
Comment #22
samuel.mortensonComment #23
slashrsm commentedLooks great. I added few asserts that ensure that expose filters are not completely broken. Since view uses AJAX for that I needed to convert to javascript test, which also revealed another missing dependency in iframe_selection library. Tests++
Comment #26
slashrsm commentedNice... this revealed another unrelated bug. Dropdown widget selector apparently doesn't work with view exposed filters. Even worse, I suspect that views exposed filters break in case of *any* element on the form with #ajax. This is not scope of this issue so for now just making sure that tests pass and will open separate issue for this bug.
I also suspect that View widget and No display selection display don't work correctly when other submit elements than the main one are on the form. Will also create follow-up for that.
Comment #28
slashrsm commentedOpened #2810751: DropDown widget breaks View widget (and possibly more?). Committed. Thanks!
Comment #29
marcoscano