3 namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
5 use Drupal\Tests\SchemaCheckTestTrait;
6 use Drupal\field\Entity\FieldConfig;
7 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
8 use Drupal\node\Entity\NodeType;
9 use Drupal\views\Tests\ViewTestData;
12 * Tests the field field handler UI.
16 class FieldTest extends WebDriverTestBase {
17 use SchemaCheckTestTrait;
22 public static $modules = ['node', 'views', 'views_ui', 'views_test_config'];
25 * Views used by this test.
29 public static $testViews = ['test_field_body'];
34 * @var \Drupal\user\UserInterface
41 protected function setUp() {
44 ViewTestData::createTestViews(get_class($this), ['views_test_config']);
46 // Disable automatic live preview to make the sequence of calls clearer.
47 \Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
49 $this->account = $this->drupalCreateUser(['administer views']);
50 $this->drupalLogin($this->account);
57 'entity_type' => 'node',
58 'field_name' => 'body',
63 public function testFormatterChanging() {
64 $web_assert = $this->assertSession();
65 $url = '/admin/structure/views/view/test_field_body';
66 $this->drupalGet($url);
68 $page = $this->getSession()->getPage();
70 $page->clickLink('Body field');
71 $web_assert->assertWaitOnAjaxRequest();
73 $page->fillField('options[type]', 'text_trimmed');
74 // Add a value to the trim_length setting.
75 $web_assert->assertWaitOnAjaxRequest();
76 $page->fillField('options[settings][trim_length]', '700');
77 $apply_button = $page->find('css', '.views-ui-dialog button.button--primary');
78 $this->assertTrue(!empty($apply_button));
79 $apply_button->press();
80 $web_assert->assertWaitOnAjaxRequest();
83 $save_button = $page->find('css', '#edit-actions-submit');
84 $save_button->press();
86 // Set the body field back to 'default' and test that the trim_length
87 // settings are not in the config.
88 $this->drupalGet($url);
89 $page->clickLink('Body field');
90 $web_assert->assertWaitOnAjaxRequest();
92 $page->fillField('options[type]', 'text_default');
93 $web_assert->assertWaitOnAjaxRequest();
94 $apply_button = $page->find('css', '.views-ui-dialog button.button--primary');
95 $apply_button->press();
96 $web_assert->assertWaitOnAjaxRequest();
99 $save_button = $page->find('css', '#edit-actions-submit');
100 $save_button->press();
102 $this->assertConfigSchemaByName('views.view.test_field_body');