Commit c271cea0 authored by catch's avatar catch

Issue #2809549 by Lendude: Convert AJAX part of...

Issue #2809549 by Lendude: Convert AJAX part of \Drupal\views\Tests\Wizard\BasicTest::testWizardForm to JavascriptTestBase and fix resulting Block row display options
parent 20cab6d9
......@@ -1091,7 +1091,8 @@ protected function blockDisplayOptions(array $form, FormStateInterface $form_sta
$block = $form_state->getValue('block');
$display_options['title'] = $block['title'];
$display_options['style'] = array('type' => $block['style']['style_plugin']);
$display_options['row'] = array('type' => isset($block['style']['row_plugin']) ? $block['style']['row_plugin'] : 'fields');
$options = $this->rowStyleOptions();
$display_options['row'] = array('type' => (isset($block['style']['row_plugin']) && isset($options[$block['style']['row_plugin']])) ? $block['style']['row_plugin'] : 'fields');
$display_options['pager']['type'] = $block['pager'] ? 'full' : (empty($block['items_per_page']) ? 'none' : 'some');
$display_options['pager']['options']['items_per_page'] = $block['items_per_page'];
return $display_options;
......
......@@ -170,26 +170,6 @@ function testViewsWizardAndListing() {
$this->assertEqual($node['nid'][0]['value'], $node1->id(), 'The node of type page is exported.');
}
/**
* Tests the actual wizard form.
*
* @see \Drupal\views_ui\ViewAddForm::form()
*/
public function testWizardForm() {
$this->drupalGet('admin/structure/views/add');
$result = $this->xpath('//small[@id = "edit-label-machine-name-suffix"]');
$this->assertTrue(count($result), 'Ensure that the machine name is applied to the name field.');
$this->drupalPostAjaxForm(NULL, array('show[wizard_key]' => 'users'), 'show[wizard_key]');
$this->assertNoFieldByName('show[type]', NULL, 'The "of type" filter is not added for users.');
$this->drupalPostAjaxForm(NULL, array('show[wizard_key]' => 'node'), 'show[wizard_key]');
$this->assertNoFieldByName('show[type]', 'all', 'The "of type" filter is not added for nodes when there are no node types.');
$this->drupalCreateContentType(array('type' => 'page'));
$this->drupalPostAjaxForm(NULL, array('show[wizard_key]' => 'node'), 'show[wizard_key]');
$this->assertFieldByName('show[type]', 'all', 'The "of type" filter is added for nodes when there is at least one node type.');
}
/**
* Tests default plugin values are populated from the wizard form.
*
......
......@@ -15,7 +15,7 @@ class ViewsWizardTest extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'views', 'views_ui', 'block'];
public static $modules = ['node', 'views', 'views_ui', 'block', 'user'];
/**
* {@inheritdoc}
......@@ -56,6 +56,27 @@ public function testCreateViewWizard() {
// Add a block display.
$page->findField('block[create]')->click();
$this->assertEquals($label_value, $page->findField('block[title]')->getValue());
// Select the entity type to display and test that the type selector is
// shown when expected.
$page->selectFieldOption('show[wizard_key]', 'node');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertNull($page->findField('show[type]'), 'The "of type" filter is not added for nodes when there are no node types.');
$this->assertEquals('teasers', $page->findField('page[style][row_plugin]')->getValue(), 'The page display format shows the expected default value.');
$this->assertEquals('titles_linked', $page->findField('block[style][row_plugin]')->getValue(), 'The block display format shows the expected default value.');
$page->selectFieldOption('show[wizard_key]', 'users');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertNull($page->findField('show[type]'), 'The "of type" filter is not added for users.');
$this->assertEquals('fields', $page->findField('page[style][row_plugin]')->getValue(), 'The page display format was updated to a valid value.');
$this->assertEquals('fields', $page->findField('block[style][row_plugin]')->getValue(), 'The block display format was updated to a valid value.');
$this->drupalCreateContentType(['type' => 'page']);
$page->selectFieldOption('show[wizard_key]', 'node');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertNotNull($page->findField('show[type]'), 'The "of type" filter is added for nodes when there is at least one node type.');
$this->assertEquals('fields', $page->findField('page[style][row_plugin]')->getValue(), 'The page display format was not changed from a valid value.');
$this->assertEquals('fields', $page->findField('block[style][row_plugin]')->getValue(), 'The block display format was not changed from a valid value.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment