ContentTranslationLanguageChangeTest should perform setup tasks using API calls not form submissions

Created on 21 April 2023, over 1 year ago
Updated 20 June 2023, over 1 year ago

Problem/Motivation

ContentTranslationLanguageChangeTest sets up translation and creates an image field using form submissions.

These should be done with API calls.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.1

Component
Content translation 

Last updated 2 days ago

No maintainer
Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

  • Issue created by @joachim
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,302 pass
  • @joachim opened merge request.
  • 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺

    Why? This actually covers the forms submission too.

    Specially having to call

        $this->rebuildContainer();
    

    raises a red flag to me that better we test that happens on the form submission.

  • 🇬🇧United Kingdom joachim

    > Why? This actually covers the forms submission too.

    The form submission already has specific test coverage.

    If this test was where it was covered, then the form submissions should be in the testFoo() method, and not in setUp().

    Here the form submission is being repeated for several test methods. That's wasteful of time, CPU cycles and energy because doing browser requests is more expensive than API calls. It increases d.org's CI costs.

    See the parent issue and the sustainability docs for details.

    > $this->rebuildContainer();

    It's documented elsewhere that a kernel rebuild is needed when switching a site to multilingual. That has coverage elsewhere.

  • 🇬🇧United Kingdom joachim

    A search for the path 'admin/config/regional/content-language' in functional tests shows these test files:

    contact/tests/src/Functional/ContactLanguageTest.php
    menu_ui/tests/src/Functional/MenuUiNodeTest.php
    content_moderation/tests/src/Functional/ModerationContentTranslationTest.php
    content_moderation/tests/src/Functional/ModerationFormTest.php
    content_moderation/tests/src/Functional/ModerationLocaleTest.php
    file/tests/src/Functional/FileOnTranslatedEntityTest.php
    file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php
    path/tests/src/Functional/PathLanguageTest.php
    path/tests/src/Functional/PathContentModerationTest.php
    language/tests/src/Functional/LanguageConfigSchemaTest.php
    language/tests/src/Functional/EntityTypeWithoutLanguageFormTest.php
    language/tests/src/Functional/LanguageSelectorTranslatableTest.php
    workspaces/tests/src/Functional/PathWorkspacesTest.php
    field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
    image/tests/src/Functional/ImageOnTranslatedEntityTest.php
    node/tests/src/Functional/NodeTranslationUITest.php
    views/tests/src/Functional/Plugin/DisplayFeedTranslationTest.php
    views/tests/src/Functional/SearchMultilingualTest.php
    content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php
    content_translation/tests/src/Functional/ContentTranslationSyncImageTest.php
    content_translation/tests/src/Functional/ContentTranslationEnableTest.php
    content_translation/tests/src/Functional/ContentTranslationStandardFieldsTest.php
    content_translation/tests/src/Functional/ContentTranslationDisableSettingTest.php
    content_translation/tests/src/Functional/ContentTranslationOperationsTest.php
    content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php
    content_translation/tests/src/Functional/ContentTranslationContextualLinksTest.php
    content_translation/tests/src/Functional/ContentTranslationUISkipTest.php
    content_translation/tests/src/Functional/ContentTranslationLanguageChangeTest.php
    content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
    

    That's far too many -- some of them such as ContentTranslationEnableTest or ContentTranslationDisableSettingTest are clearly about using the settings form.

    But most of them have no need to use the form and should use the API. Anything outside of content_translation module shouldn't be dealing with a form that doesn't belong to it, and several of the content_translation tests need fixing too.

  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    That's far too many -- some of them such as ContentTranslationEnableTest or ContentTranslationDisableSettingTest are clearly about using the settings form.

    I agree that should we should reduce the number of times we do this trough the api, I wonder if the scope of this issue is correct in that case. Should we do everything in one issue?

  • 🇬🇧United Kingdom joachim

    > Should we do everything in one issue?

    Gah, no! It'll take way too long to get in.

    I will though make a meta issue to identify the test coverage for the form.

    This issue is fine to get in now though, as it's clearly not meant to be covering the form.

  • Status changed to RTBC over 1 year ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    Ok, #8 sounds great.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,302 pass
  • 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺

    RTBC+1

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,300 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,362 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    50:56
    46:56
    Running
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,367 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,374 pass
    • catch committed 4104aed9 on 10.1.x
      Issue #3355604 by joachim, penyaskito, borisson_:...
  • Status changed to Fixed over 1 year ago
  • 🇬🇧United Kingdom catch

    Committed/pushed to 10.1.x, thanks! Tagging for the follow-up.

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

  • Status changed to Fixed over 1 year ago
  • 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
  • 🇳🇿New Zealand quietone

    @joachim, thanks for making the followup issue. I am removing the tag.

Production build 0.71.5 2024