Test Drupal.behaviors.copyFieldValue javascript

Created on 12 February 2018, over 7 years ago
Updated 27 March 2023, over 2 years ago

Problem/Motivation

In #2925064: [1/2] JS codestyle: no-restricted-syntax we broke Drupal.behaviors.copyFieldValue(). It was fixed in #2941106: Site email address in the install profile form is no longer copied to the user email address but we should add test coverage so we don't break it again.

Proposed resolution

Add test coverage.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

📌 Task
Status

Fixed

Version

10.1

Component
Javascript 

Last updated 2 days ago

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India santosh_verma Faridabad

    reviewed the patch on comment #48, patch applied successfully on D10 and there is no functionality break in the website, can we merge now

  • Status changed to Needs work over 2 years ago
  • 🇬🇧United Kingdom longwave UK
    +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
    @@ -0,0 +1,54 @@
    +    $assert_session->assertWaitOnAjaxRequest();
    ...
    +    $assert_session->assertWaitOnAjaxRequest();
    

    There's no AJAX going on here so waiting for AJAX is pointless.

  • Status changed to Needs review over 2 years ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #48 by addressing #50, please review it.

    Thanks!

  • Status changed to RTBC over 2 years ago
  • 🇺🇸United States smustgrave

    Even though I worked on the ticket, this was previously marked RTBC and the update was removing 2 lines so think I can still move it back to RTBC.

  • 🇺🇸United States smustgrave

    Random failure

  • Status changed to Needs work over 2 years ago
  • 🇫🇮Finland lauriii Finland
    1. +++ b/core/modules/system/tests/modules/system_test/src/Form/CopyFieldValueTestForm.php
      @@ -0,0 +1,53 @@
      +    // We are only testing the javascript part of form. We are not submitting
      
      +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      @@ -0,0 +1,52 @@
      + * Tests copy field value javascript functionality works fine.
      ...
      +   * Tests copy field value javascript functionality.
      

      Nit: javascript should be replaced with JavaScript.

    2. +++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml
      --- /dev/null
      +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      
      +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      @@ -0,0 +1,52 @@
      +    $assert_session = $this->assertSession();
      

      Unused variable.

    3. +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      @@ -0,0 +1,52 @@
      +    // Now focus target field.
      ...
      +    // Now focus target field.
      

      This comment is redundant because that's exactly how the following line would read..

    4. +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      @@ -0,0 +1,52 @@
      +    $this->assertTrue($target_field->getValue() == $random_string);
      ...
      +    $this->assertTrue($target_field->getValue() == $random_string);
      

      You can use $this->assertEquals() here 😇

    5. +++ b/core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php
      @@ -0,0 +1,52 @@
      +    // After filling the field the JS will run async. Just to ensure the JS
      

      I'm not sure I understand this comment. Isn't the expectation that nothing happens to the target at this point? Why is this comment explaining that the JavaScript will run async?

  • Status changed to Needs review over 2 years ago
  • 🇮🇳India Abhisheksingh27

    Uploading updated #51 patch with suggested 1,2 and 3 changes in comment #55.

  • 🇮🇳India TanujJain-TJ

    #56 doesn't fix issues 1,4,5 mentioned in #55, re-uploading patch to fix all the mentioned issues, please review.

  • Status changed to RTBC over 2 years ago
  • 🇺🇸United States smustgrave

    #57 appears to address the points from #55

  • 🇫🇮Finland lauriii Finland

    Minor adjustments to code comments.

  • 🇺🇸United States smustgrave

    Random failure.

    • nod_ committed f88d58b0 on 10.1.x
      Issue #2944089 by msankhala, smustgrave, lauriii, Ada Hernandez,...
  • Status changed to Fixed over 2 years ago
  • 🇫🇷France nod_ Lille

    Committed f88d58b and pushed to 10.1.x. Thanks!

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

Production build 0.71.5 2024