diff --git a/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml b/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml index b3f5f6497f6d32e253966352c84a4949cea84236..28979932bff7c8f48c9df32b0953e175e34ebb89 100644 --- a/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml +++ b/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml @@ -14,7 +14,7 @@ mode: default content: created: type: datetime_timestamp - weight: 3 + weight: 10 region: content settings: { } third_party_settings: { } @@ -35,7 +35,7 @@ content: third_party_settings: { } path: type: path - weight: 4 + weight: 30 region: content settings: { } third_party_settings: { } @@ -43,12 +43,12 @@ content: type: boolean_checkbox settings: display_label: true - weight: 5 + weight: 100 region: content third_party_settings: { } uid: type: entity_reference_autocomplete - weight: 2 + weight: 5 settings: match_operator: CONTAINS size: 60 diff --git a/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml b/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml index 658648fd183c7eb47add596e4e34dabd1726b1ec..d0fa5049d5bf9f97319930e747cf6b68d2d15656 100644 --- a/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml +++ b/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml @@ -14,7 +14,7 @@ mode: default content: created: type: datetime_timestamp - weight: 3 + weight: 10 region: content settings: { } third_party_settings: { } @@ -35,7 +35,7 @@ content: third_party_settings: { } path: type: path - weight: 4 + weight: 30 region: content settings: { } third_party_settings: { } @@ -43,12 +43,12 @@ content: type: boolean_checkbox settings: display_label: true - weight: 5 + weight: 100 region: content third_party_settings: { } uid: type: entity_reference_autocomplete - weight: 2 + weight: 5 settings: match_operator: CONTAINS size: 60 diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php index 321c4bb61dd4cdd14bb93c19aa06800841092c66..e91a192e2ba7ece91067d7a836600498cce44773 100644 --- a/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\standard\Functional; +use Drupal\Component\Utility\Html; +use Drupal\media\Entity\MediaType; use Drupal\Tests\SchemaCheckTestTrait; use Drupal\contact\Entity\ContactForm; use Drupal\Core\Url; @@ -219,6 +221,38 @@ public function testStandard() { $this->assertText('Archive'); $this->assertText('Restore to Draft'); $this->assertText('Restore'); + + \Drupal::service('module_installer')->install(['media']); + $role = Role::create([ + 'id' => 'admin_media', + 'label' => 'Admin media', + ]); + $role->grantPermission('administer media'); + $role->save(); + $this->adminUser->addRole($role->id()); + $this->adminUser->save(); + $assert_session = $this->assertSession(); + /** @var \Drupal\media\Entity\MediaType $media_type */ + foreach (MediaType::loadMultiple() as $media_type) { + $media_type_machine_name = $media_type->id(); + $this->drupalGet('media/add/' . $media_type_machine_name); + // Get the form element, and its HTML representation. + $form_selector = '#media-' . Html::cleanCssIdentifier($media_type_machine_name) . '-add-form'; + $form = $assert_session->elementExists('css', $form_selector); + $form_html = $form->getOuterHtml(); + + // The name field should come before the source field, which should itself + // come before the vertical tabs. + $name_field = $assert_session->fieldExists('Name', $form)->getOuterHtml(); + $test_source_field = $assert_session->fieldExists($media_type->getSource()->getSourceFieldDefinition($media_type)->getLabel(), $form)->getOuterHtml(); + $vertical_tabs = $assert_session->elementExists('css', '.form-type-vertical-tabs', $form)->getOuterHtml(); + $date_field = $assert_session->fieldExists('Date', $form)->getOuterHtml(); + $published_checkbox = $assert_session->fieldExists('Published', $form)->getOuterHtml(); + $this->assertTrue(strpos($form_html, $test_source_field) > strpos($form_html, $name_field)); + $this->assertTrue(strpos($form_html, $vertical_tabs) > strpos($form_html, $test_source_field)); + // The "Published" checkbox should be the last element. + $this->assertTrue(strpos($form_html, $published_checkbox) > strpos($form_html, $date_field)); + } } }