+ $assert_session->selectExists('Media source')->selectOption('test_different_displays');
+ $this->assertNotEmpty(
+ $assert_session->waitForElementVisible('css', 'fieldset[data-drupal-selector="edit-source-configuration"]')
+ );
+
+ // Change the media source.
+ $assert_session->selectExists('Media source')->selectOption('test');
+ $this->assertNotEmpty(
+ $assert_session->waitForElement('css', 'fieldset[data-drupal-selector="edit-source-configuration"] .fieldset-wrapper .placeholder:contains("Text (plain)")')
+ );
+
+ $page->pressButton('Save');
+
+ // Check that source can not be changed anymore.
+ $this->drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}");
+ $assert_session->pageTextContains('The media source cannot be changed after the media type is created');
+ $assert_session->fieldDisabled('Media source');
+ }
+
+ /**
+ * Tests the media type creation form.
+ */
+ public function testMediaTypeCreationFormWithDefaultField() {
+ $session = $this->getSession();
+ $page = $session->getPage();
+ $assert_session = $this->assertSession();
+
+ $label = 'Type with Default Field';
+ $mediaTypeMachineName = str_replace(' ', '_', strtolower($label));
+
+ $this->drupalGet('admin/structure/media/add');
+
+ // Select the media source used by our media type. Do this before setting
+ // the label or machine name in order to guard against the regression in
+ // https://www.drupal.org/project/drupal/issues/2557299.