Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

michielnugter’s picture

Status: Active » Needs review
FileSize
15.67 KB

I created a partial conversion and am in doubt about it.

While converting I saw that the JS part of this test is testing drag-n-drop. There are many tests that test this already, in particular #2809483: Convert AJAX part of \Drupal\field\Tests\FormTest::testFieldFormJSAddMore to JavascriptTestBase.

The conversion can still be usefull as the test is a little less hacky than the WebTest but for now no JS is tested.

To be decided:
Should this test contain validation for the drag-n-drop?

If not:
- Should the current js-add-more test be extended to use multiple draggable fields?
- Should the current conversion be committed or only a patch stripping the Add more and draggable test part?

michielnugter’s picture

Issue summary: View changes
dawehner’s picture

As said in the parent issue, I think we should keep the conversions as parallel as possible.

michielnugter’s picture

Status: Needs review » Needs work

Thanks for answering my question.

I'll add the drag-n-drop functionality and update the issue with a new patch.

michielnugter’s picture

Status: Needs work » Needs review
FileSize
9.65 KB
20.1 KB

I updated the test to be an exact copy of the original, testing the dragging and add more behavrior. As a bonus the expanding of the second entity is also tested, this was required because the dragging and add more functionality couldn't be tested otherwise..

michielnugter’s picture

Update to conform to the new wait API.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

michielnugter’s picture

Component: phpunit » field system
Issue tags: +phpunit initiative
dawehner’s picture

Just some quick general review.

  1. +++ b/core/modules/field/src/Tests/FieldAssertTrait.php
    @@ -0,0 +1,66 @@
    +
    +trait FieldAssertTrait {
    +
    

    This needs some docs

  2. +++ b/core/modules/field/src/Tests/FieldAssertTrait.php
    @@ -0,0 +1,66 @@
    +  function _generateTestFieldValues($cardinality) {
    ...
    +  function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_DEFAULT, $column = 'value') {
    

    If its a trait we could use proper function names / protected visibility and then wire it up to the old names in the test files.

  3. +++ b/core/modules/field/src/Tests/FieldAssertTrait.php
    @@ -0,0 +1,66 @@
    +    /** @var EntityTest $e */
    

    Let's use a fully qualified class name (FQCN)

  4. +++ b/core/modules/field/tests/src/FunctionalJavascript/NestedFormTest.php
    @@ -0,0 +1,251 @@
    +  function testNestedFieldForm() {
    

    Some more visibility.

michielnugter’s picture

Status: Needs review » Needs work

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ApacheEx’s picture

I think it's better to convert whole NestedFormTest with minimal changes to BTB.
there is no interdiff because it's completely a new patch.

one thing to highlight:
instead of this

$this->assertFieldByName('entity_2[changed]', 0, 'Entity 2: changed value appears correctly in the form.');

I use this

$assert_session->hiddenFieldValueEquals('entity_2[changed]', REQUEST_TIME);

I don't know how it worked before, changed field will be the same as created after first save like this:

$storage = $this->container->get('entity_type.manager')
  ->getStorage('entity_test_constraints');

$entity_1 = $storage->create();
$entity_1->save();

here is a proof: \Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem::preSave()

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Lendude’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The use of AJAX here was as a workaround for limitations in WebTestBases drupalPostForm and we have proper coverage for the 'add more' javascript in \Drupal\Tests\field\FunctionalJavascript\FormJSAddMoreTest::testFieldFormJsAddMore. This seems sufficient for this, I think.

So just converting this to BrowserTestBase makes sense here I think.

The conversion looks good, nice and minimal.

Updated the IS to reflect the new direction.

alexpott’s picture

Title: Convert AJAX part of \Drupal\field\Tests\NestedFormTest::testNestedFieldForm to JavascriptTestBase » Convert \Drupal\field\Tests\NestedFormTest::testNestedFieldForm to BrowserTestBase
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Can someone update the issue summary - I've updated the title but now the issue summary is out-of-date. Once the issue summary is updated it can be set back to rtbc.

ApacheEx’s picture

Title: Convert \Drupal\field\Tests\NestedFormTest::testNestedFieldForm to BrowserTestBase » Convert \Drupal\field\Tests\NestedFormTest to BrowserTestBase
Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs issue summary update
Parent issue: #2809161: Convert Javascript/AJAX testing to use JavascriptTestBase » #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)

Updated summary.

ApacheEx’s picture

Issue summary: View changes
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed c93ced1ea2 to 8.7.x and 9082b8de9b to 8.6.x. Thanks!

  • alexpott committed c93ced1 on 8.7.x
    Issue #2809489 by michielnugter, ApacheEx, dawehner, Lendude: Convert \...

  • alexpott committed 9082b8d on 8.6.x
    Issue #2809489 by michielnugter, ApacheEx, dawehner, Lendude: Convert \...

Status: Fixed » Closed (fixed)

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