- Issue created by @scott_euser
- Merge request !7594Add SettingsCommand if views ajax controller finds attached settings in the View render array β (Open) created by scott_euser
- Issue was unassigned.
- Status changed to Needs review
6 months ago 7:54pm 18 April 2024 - π¬π§United Kingdom scott_euser
Merge request created + updated tests. Rather than create a new method in ViewAjaxControllerTest, I opted to add to ::testAjaxView() to keep it faster as I would need to repeat a chunk of what is in that, but happy to move this to a separate method if that is the preference.
- Status changed to RTBC
6 months ago 2:11pm 22 April 2024 - πΊπΈUnited States smustgrave
Thanks for including tests from the start
1) Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::testAjaxView Undefined array key 2 /builds/issue/drupal-3441920/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php:216 /builds/issue/drupal-3441920/vendor/phpunit/phpunit/src/Framework/TestResult.php:729 /builds/issue/drupal-3441920/vendor/phpunit/phpunit/src/Framework/TestSuite.php:685 /builds/issue/drupal-3441920/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:651 /builds/issue/drupal-3441920/vendor/phpunit/phpunit/src/TextUI/Command.php:146 /builds/issue/drupal-3441920/vendor/phpunit/phpunit/src/TextUI/Command.php:99 ERRORS! Tests: 10, Assertions: 57, Errors: 1.
Issue summary appears complete.
Extra condition appears fine to me.
- Status changed to Needs work
6 months ago 3:43am 23 April 2024 - π³πΏNew Zealand quietone
"Views Ajax Controller" This should be the name of the class, ViewAjaxController as well as describe the fix, not the problem.
- Status changed to Needs review
6 months ago 4:02am 23 April 2024 - Status changed to RTBC
6 months ago 1:40pm 23 April 2024 - Status changed to Needs work
6 months ago 11:54am 25 April 2024 - π¬π§United Kingdom catch
I think there might be a more generic way to fix this - left a long-ish comment on the MR.
- π¬π§United Kingdom scott_euser
Thanks for the tip!
The code change itself should work in reality, but the test as is is definitely going to fail. I would appreciate if you have advice on this one:
- UnitTest: Mocking `\Drupal\core\Ajax\AjaxResponseAttachmentsProcessor` seems like a big rabbit hole, each time I think I've mocked everything, there is another service called somewhere in the pipeline that further needs to be mocked.
- KernalTest: If I switch to a KernalTest it would be easier, but a lot of the heavy lifting this ViewAjaxControllerTest would be repeated
- FunctionalJavascript: Or I can go for a FunctionalJavascript test and test it fully without any mocking and actually check that the response contains the correct thing (though I will probably need to add a test module to add #attached into a Handler).
- π¬π§United Kingdom catch
Replied on the MR since I am hopeful the test complexity stems from a possibly unnecessary line.
- Assigned to scott_euser
- π¬π§United Kingdom scott_euser
Thanks! Yes you are right, in a real site it works with just setAttachments. So probably I need to do some tweaking with the mocking to make sure that AjaxResponseAttachmentsProcessor is actually running as well. Will work on the test a bit more.
- π¬π§United Kingdom catch
The test could maybe just call ::getAttachments() on the response, to make sure the attachments are set?
Running the commands ought to be handled by AJAX system tests themselves.
- Issue was unassigned.
- Status changed to Needs review
6 months ago 5:19am 27 April 2024 - π¬π§United Kingdom scott_euser
Right of course! Much simpler, and of course AjaxResponseSubscriber is tested elsewhere already so that does not need to be covered here. Tests passing now in ddev. Thank you very much for your help here.
- π¬π§United Kingdom scott_euser
To note, I did consider adding an attached libraries as well to the ::setupValidMocks() method, but I tested with my initial commit that only covered SettingsCommand rather than attachments and the tests pass anyways for the library, so I do not think it adds anything (whereas as is, test only fails as expected and with the change test passes).
- Status changed to RTBC
6 months ago 9:46am 27 April 2024 - π¬π§United Kingdom catch
Looks great. Ran the test only job too just to see the failures.
- π«π·France nod_ Lille
I was worried having drupalSetting added to the preview could break views ui somehow. Haven't found an explicit way it could yet.
Not really my area of the code so leaving the commit to someone else. RTBC +1
- π¬π§United Kingdom alexpott πͺπΊπ
Committed and pushed 3e486f783a to 11.x and 4d0abee5f2 to 11.0.x and af7f5ed2e1 to 10.4.x and 12097985d8 to 10.3.x. Thanks!
-
alexpott β
committed 12097985 on 10.3.x
Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #...
-
alexpott β
committed 12097985 on 10.3.x
-
alexpott β
committed af7f5ed2 on 10.4.x
Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #...
-
alexpott β
committed af7f5ed2 on 10.4.x
-
alexpott β
committed 4d0abee5 on 11.0.x
Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #...
-
alexpott β
committed 4d0abee5 on 11.0.x
- Status changed to Fixed
6 months ago 8:51pm 5 May 2024 -
alexpott β
committed 3e486f78 on 11.x
Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #...
-
alexpott β
committed 3e486f78 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.