See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)

Scope:

  • SearchAdvancedSearchFormTest
  • SearchBlockTest: postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and a way to port Simpletest AssertContentTrait::parse().
  • SearchCommentTest
  • SearchConfigSettingsFormTest: postponed, waiting a way to port Simpletest AssertContentTrait::parse(). Should fail using php-fpm see #2157061: Path Alias test fails on php-fpm
  • SearchEmbedFormTest
  • SearchLanguageTest
  • SearchNodeUpdateAndDeletionTest
  • SearchNumberMatchingTest
  • SearchNumbersTest
  • SearchPageCacheTagsTest
  • SearchPageTextTest
  • SearchPreprocessLangcodeTest
  • SearchQueryAlterTest
  • SearchRankingTest

Out of Scope:

Comments

GoZ created an issue. See original summary.

GoZ’s picture

Status: Active » Needs review
FileSize
26.44 KB

Many tests have been converted and are OK.

Some needs work, some other require postponed.

  • SearchAdvancedSearchFormTest
  • SearchBlockTest: postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and a way to port Simpletest AssertContentTrait::parse().
  • SearchCommentTest: needs work
  • SearchConfigSettingsFormTest: needs to work and postponed, waiting a way to port Simpletest AssertContentTrait::parse()
  • SearchEmbedFormTest
  • SearchLanguageTest
  • SearchNodeUpdateAndDeletionTest
  • SearchNumberMatchingTest
  • SearchNumbersTest
  • SearchPageCacheTagsTest
  • SearchPageTextTest
  • SearchPreprocessLangcodeTest
  • SearchQueryAlterTest
  • SearchRankingTest
GoZ’s picture

comment instead of edit summary. Oops

GoZ’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 2: convert_web_tests_to-2863842-2.patch, failed testing.

GoZ’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
27.24 KB
3.33 KB

Here is some fix, but the rest should be waiting for postponed (see summary)

Status: Needs review » Needs work

The last submitted patch, 6: convert_web_tests_to-2863842-6.patch, failed testing.

GoZ’s picture

Status: Needs work » Postponed

Fail due to clickLinkPartialName() and parse() as expected. Postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and port of Simpletest AssertContentTrait::parse()

GoZ’s picture

Status: Postponed » Needs review
FileSize
21.17 KB
3.06 KB

Remove two tests from this patch so it can be commited. 2 missing tests needs more work due to other issues. Let's deal with them in another issue.

  • SearchBlockTest: postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and a way to port Simpletest AssertContentTrait::parse().
  • SearchConfigSettingsFormTest: postponed, waiting a way to port Simpletest AssertContentTrait::parse(). Should fail using php-fpm see #2157061: Path Alias test fails on php-fpm

Status: Needs review » Needs work

The last submitted patch, 9: convert_web_tests_to-2863842-9.patch, failed testing.

GoZ’s picture

Status: Needs work » Needs review
FileSize
20.77 KB
265 bytes

What are you doing here TextFieldTest ? Please leave.

Sorry for this irrelevant test.

dawehner’s picture

Does someone mind to create a followup issue so we don't forget to the convert the remaining bits?

dawehner’s picture

Status: Needs review » Needs work
Issue tags: +Needs followup
GoZ’s picture

I create #2870595: Convert postponed WTB to BTB for search module SearchBlockTest and SearchConfigSettingsFormTest to deal with postponed SearchBlockTest and SearchConfigSettingsFormTest so we can close this issue and working on remaining conversions in another thread.

dawehner’s picture

+++ b/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php
@@ -53,14 +53,14 @@ public function testNodeType() {
-    $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+    $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
...
-    $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), t('Advanced search'));
+    $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), 'edit-submit--2');
...
-    $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), t('Advanced search'));
+    $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), 'edit-submit--2');

I'm wondering is this change really needed? Reading the function documentation explains that you should be able to provide a label.

GoZ’s picture

I can't use label because there is a conflict with another 'Advanced search' label in form.

michielnugter’s picture

Status: Needs review » Reviewed & tested by the community

Follow-ups created and the feedback from @dawehner was explained. I think this is good to got!

Thanks @GoZ!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: convert_web_tests_to-2863842-11.patch, failed testing.

michielnugter’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail

dawehner’s picture

+1 for the RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Re #15 I think this makes the tests way less readable. However reading the docs for \Drupal\Tests\BrowserTestBase::submitForm() in BrowserTestBase I think we should just use that method instead and supply the $form_html_id param. Or maybe we should open an issue to add a param to drupalPostForm(). I think I prefer converting these calls to use \Drupal\Tests\BrowserTestBase::submitForm()

naveenvalecha’s picture

Title: Convert web tests to browser tests for search module » [PP-1] Convert web tests to browser tests for search module
Issue summary: View changes
Status: Needs work » Postponed

Created a follow-up for #21 #2887411: Add $form_html_id to drupalPostForm in BrowserTestBase and convert SearchAdvancedSearchFormTest from WTB to BTB

Shall we convert this particular test in follow-up and move with the tests which have minimal disruptions that way we'll have very fewer tests which are pending on postponed issues

//Naveen

naveenvalecha’s picture

larowlan’s picture

We can use ::findButton and then ::press instead of ::submitForm if there are conflicts

$page = $this->getSession()->getPage();
$button = $page->findButton('edit-submit-2');
$page->fillField('some field', 'some value');
$button->press();