Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Apparently functional tests are now the preferred way of testing the UI. We should therefore try to port our existing web tests to those. (According to Joris, it can incredibly simple in a lot of cases.)
Then we can also think about expanding those tests with JS checks in the course of #2753807: Add functional Javascript tests.
Comment | File | Size | Author |
---|---|---|---|
#24 | 2753815-23--use_BrowserTestBase.patch | 198.72 KB | drunken monkey |
| |||
#18 | 2753815-18.patch | 162.43 KB | niko- |
Comments
Comment #2
borisson_Web tests should extend from the BrowserTestBase base class.
Comment #3
niko- CreditAttribution: niko- at Adyax commentedComment #4
borisson_I don't think that's a move of all the tests? Also, it'd be great to make the patch with
git diff -M > patchname.path
, as that makes the patch much easier to grok.Thanks for working on this!
Comment #5
itsekhmistro CreditAttribution: itsekhmistro at Adyax commentedHi guys,
Checked the patch from nico comment #3 https://www.drupal.org/files/issues/initial-functional-tests-2753815-3.p...
and slightly updated it, I would like to outline some details here:
* (1) Fixed checkForMetaRefresh() method in WebTestbase - now it does as supposed to be = checks for redirects in recursion (allows to pass batches).
* (2) There is really an issue with "Index now" form, due to
<summary role="button" aria-controls="edit-index" aria-expanded="true" aria-pressed="true">Index now</summary>
this element is confusing for submitForm() method in BrowserTestBase.
$this->drupalPostForm(NULL, array(), $this->t('Index now'));
The real submit button is
<input data-drupal-selector="edit-index-now" type="submit" id="edit-index-now" name="index_now" value="Index now" class="button js-form-submit form-submit">
* (3) Ported LanguageIntegrationTest (passes 100%) and IntegrationTest , this is not final patch there are still several Tests to port.
For (2) fixed by renaming element title to "'Start indexing now". What do you think about it?
The alternative would be to pass element name into
$this->drupalPostForm(NULL, array(), 'index_now');
But it doesn't sound good as for me.
Comment #6
borisson_Setting to NR for the bots, will respond to #5 later.
Comment #8
niko- CreditAttribution: niko- at Adyax commentedThanks for your help.
Updated patch includes:
CacheabilityTest
HooksTest
IntegrationTest - not finished
LanguageIntegrationTest
OverviewPageTest
ProcessorIntegrationTest
WebTestBase was renamed to SearchApiBrowserTestBase
ExampleContentTrait was moved to namespace Drupal\Tests\search_api
Comment #10
niko- CreditAttribution: niko- at Adyax commentedAll search_api simpletest tests are moved to functional tests.
Current tests status:
All existing Kernel, Unit tests have passed with ../vendor/bin/phpunit
Functional tests status:
CacheabilityTest - passed
HooksTest - passed
IntegrationTest - Passed
- all things that need detail review was marked with @todo
- calls drupalPostAjaxForm - need discussing and port to javascript fucntional tests (commented now)
LanguageIntegrationTest - passed
OverviewPageTest - passed
LocalActionsWebTest - passed
ProcessorIntegrationTest - passed
ViewsTest - not passed
- need proper migration of installModulesFromClassProperty method that not exists in BrowserTestBase
Comment #11
niko- CreditAttribution: niko- at Adyax commentedComment #13
borisson_Not really, we could just remove that, and the else
Is there no other way to test this behavior other than a js test? That'd be very unfortunate, JS tests take a lot longer.
See above. Not testing these would lead to a significant regression in the tests-suite as it is right now.
I think we need to keep those
I'll go trough the rest of the patch after work.
Comment #14
borisson_I just ran the integration test locally and that did seem to pass. So not sure why the bots are so confused about this patch.
We do need to find a way to replace the
drupalPostAjaxForm
calls. Not sure how/if the drupal core tests have done that when they converted to BTB.Comment #15
niko- CreditAttribution: niko- at Adyax commentedComment #17
borisson_Woo - no longer errors on drupal-ci! Now all we need to do is fix the remaining fails.
Comment #18
niko- CreditAttribution: niko- at Adyax commentedDetails:
- LocalActionsWebTest was marged into OverviewPageTest and removed
- @todos was processed according #13
- search_api_db test was moved to Functional
-
was moved to
because run-tests.sh can't preper configure autoload. It seems
not called and this issue led to CI error.
- convert arrays to short syntax
Remaining tasks:
ViewsTest - not passed
- need proper migration of installModulesFromClassProperty method that not exists in BrowserTestBase
Comment #20
borisson_Yeah, the autoloader is a known issue; there's a core issue available. (I don't remember the issue by heart, but I pinged @dawehner on irc to ask about that).
I'll have a look at installModulesFromClassProperty later.
Comment #21
niko- CreditAttribution: niko- at Adyax commentedinstallModulesFromClassProperty() migration.
It seems all simpletest tests was migrated to functional one.
Comment #22
niko- CreditAttribution: niko- at Adyax commentedmodules/search_api_db/search_api_db_defaults/src/Tests/IntegrationTest.php moved to
modules/search_api_db/search_api_db_defaults/tests/src/Functional/IntegrationTest.php
Found strange thing with this test \Drupal\Tests\search_api_db_defaults\IntegrationTest::testInstallAndDefaultSetupWorking() is protected, not sure is it ok or not?
modules/search_api_db/tests/src/Functional/IntegrationTest.php moved to modules/search_api_db/tests/src/FunctionalJavascript/IntegrationTest.php
Comment #23
borisson_I think these changes look good - the diff is really big. @drunken monkey how are you feeling about these changes?
Comment #24
drunken monkeyAmazing job, thanks a lot! Looks really good, on the whole.
Since the tests now use PhpUnit, and thus abort at the first fail anyways, no, we don't need those
if
s anymore.Had a few other remarks, corrections and nit-picks. Should now all be good, more or less. I only have one error, in the DB Defaults module's integration test: there, the form submit for enabling the modules takes more than 30 seconds, thus terminating in a timeout and throwing an exception. I tried to find out how I can increase the timeout, but since the architecture seems to be "BrowserTestBase -> Mink -> BrowserKit -> Goutte -> Guzzle -> Curl" I couldn't really see a way to do that. (Sometimes, D8 is just insane.)
Let's see, how the test bot fares. Otherwise, maybe we could try splitting that up into three separate form submissions, one for each module.
Integrating
LocalActionsWebTest
intoOverviewPageTest
is a good idea, thanks!Having to override
installDrupal()
in ourViewsTest
is really ugly, but I don't really see any alternative either. At least it seems Core is already working on it: #2796105: Move similar methods in BrowserTestBase / WebTestBase to a trait; untangle installDrupal().Comment #25
borisson_Comment #27
drunken monkeyGreat, thanks a lot for reviewing!
Committed.
Thanks again for your excellent work here, niko-!