Issue #2825712: The allowed values storage setting of list fields should be required
Merge request reports
Activity
added 1 commit
- f6f75b40 - Removed unused return statement and permissions in tests
1 <?php 2 3 namespace Drupal\Tests\options\FunctionalJavascript; 4 5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase; 6 7 /** 8 * Tests the machine name transliteration functionality. 9 * 10 * @group javascript changed this line in version 12 of the diff
1 <?php 2 3 namespace Drupal\Tests\options\FunctionalJavascript; 4 5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase; 6 7 /** 8 * Tests the machine name transliteration functionality. changed this line in version 12 of the diff
37 'name' => 'Article', 38 'type' => 'article', 39 ]); 40 41 $admin_user = $this->drupalCreateUser([ 42 'administer node fields', 43 ]); 44 $this->drupalLogin($admin_user); 45 $this->drupalPlaceBlock('local_actions_block'); 46 47 } 48 49 /** 50 * Test for machine name transliteration functionality. 51 */ 52 public function testMachineNameTransliterations() { changed this line in version 12 of the diff
38 'type' => 'article', 39 ]); 40 41 $admin_user = $this->drupalCreateUser([ 42 'administer node fields', 43 ]); 44 $this->drupalLogin($admin_user); 45 $this->drupalPlaceBlock('local_actions_block'); 46 47 } 48 49 /** 50 * Test for machine name transliteration functionality. 51 */ 52 public function testMachineNameTransliterations() { 53 changed this line in version 12 of the diff
48 49 /** 50 * Test for machine name transliteration functionality. 51 */ 52 public function testMachineNameTransliterations() { 53 54 $page = $this->getSession()->getPage(); 55 56 $node = $this->createNode([ 57 'type' => 'article', 58 'title' => 'Test', 59 ]); 60 $node->save(); 61 $this->drupalGet('/admin/structure/types/manage/article/fields'); 62 $this->assertSession()->pageTextContains('Create a new field'); 63 $this->clickLink('Create a new field'); changed this line in version 12 of the diff
50 * Test for machine name transliteration functionality. 51 */ 52 public function testMachineNameTransliterations() { 53 54 $page = $this->getSession()->getPage(); 55 56 $node = $this->createNode([ 57 'type' => 'article', 58 'title' => 'Test', 59 ]); 60 $node->save(); 61 $this->drupalGet('/admin/structure/types/manage/article/fields'); 62 $this->assertSession()->pageTextContains('Create a new field'); 63 $this->clickLink('Create a new field'); 64 $page->find('css', '#edit-new-storage-type')->click(); 65 $page->find('css', '#edit-new-storage-type optgroup:nth-child(3) option:nth-child(2)')->click(); changed this line in version 12 of the diff
1 <?php 2 3 namespace Drupal\Tests\options\FunctionalJavascript; Testing a required field doesn't require JavaScript, you can take care of this with a functional test, perhaps just add one to
\Drupal\Tests\options\Functional\OptionsFieldUITest
. The only part that sorta-needs JS is the field addition, butOptionsFieldUITest::createOptionsField()
will add a field without having to use the UI at all.changed this line in version 12 of the diff
54 $page = $this->getSession()->getPage(); 55 56 $node = $this->createNode([ 57 'type' => 'article', 58 'title' => 'Test', 59 ]); 60 $node->save(); 61 $this->drupalGet('/admin/structure/types/manage/article/fields'); 62 $this->assertSession()->pageTextContains('Create a new field'); 63 $this->clickLink('Create a new field'); 64 $page->find('css', '#edit-new-storage-type')->click(); 65 $page->find('css', '#edit-new-storage-type optgroup:nth-child(3) option:nth-child(2)')->click(); 66 $page->find('css', '[data-drupal-selector="edit-label"]')->setValue('list float'); 67 $this->assertSession()->waitForText('field_list_float'); 68 $page->findButton('Save and continue')->click(); 69 Everything up until here is pretty much unnecessary if you move this to
OptionsFieldUITest
and use thecreateOptionsField()
method in that class. That method will directly add the field so you don't have to do it step-by-step via the UI. It's particularly helpful to do this since the actual add Field UI is changing, doing it withcreateOptionsField()
means the test will still work even when that part of the UI changes.changed this line in version 12 of the diff
51 */ 52 public function testMachineNameTransliterations() { 53 54 $page = $this->getSession()->getPage(); 55 56 $node = $this->createNode([ 57 'type' => 'article', 58 'title' => 'Test', 59 ]); 60 $node->save(); 61 $this->drupalGet('/admin/structure/types/manage/article/fields'); 62 $this->assertSession()->pageTextContains('Create a new field'); 63 $this->clickLink('Create a new field'); 64 $page->find('css', '#edit-new-storage-type')->click(); 65 $page->find('css', '#edit-new-storage-type optgroup:nth-child(3) option:nth-child(2)')->click(); 66 $page->find('css', '[data-drupal-selector="edit-label"]')->setValue('list float'); It looks like you're choosing a list of floats? Float is the field most likely to be removed from Drupal so one of the other list options would work better.
changed this line in version 12 of the diff
68 $page->findButton('Save and continue')->click(); 69 70 // Try to save field settings without entering values. 71 $this->assertSession()->waitForText('Allowed values list'); 72 $page->findButton('Save field settings')->click(); 73 74 // Message that confirms that this field is required. 75 $this->assertSession()->waitForText('Please fill in this field'); 76 77 // Now try to submit the form after entering values. 78 $page->find('css', '[data-drupal-selector="edit-settings-allowed-values"]')->setValue('1 | 1'); 79 $page->findButton('Save field settings')->click(); 80 $page->findButton('Save settings')->click(); 81 82 // Confirms that the field is created. 83 $this->assertSession()->waitForText('field_list_float'); changed this line in version 12 of the diff
- Resolved by utkarsh_33
- Resolved by utkarsh_33
- Resolved by Ben Mullins