9e303dfb9222cf989ae956a3ff9843c4feb33f34
[yaffs-website] / web / core / modules / views_ui / tests / src / FunctionalJavascript / FilterCriteriaTest.php
1 <?php
2
3 namespace Drupal\Tests\views_ui\FunctionalJavascript;
4
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
6
7 /**
8  * Tests the View UI filter criteria group dialog.
9  *
10  * @group views_ui
11  */
12 class FilterCriteriaTest extends WebDriverTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['node', 'views', 'views_ui'];
18
19   /**
20    * {@inheritdoc}
21    */
22   public function setUp() {
23     parent::setUp();
24
25     $admin_user = $this->drupalCreateUser([
26       'administer site configuration',
27       'administer views',
28       'administer nodes',
29       'access content overview',
30     ]);
31
32     // Disable automatic live preview to make the sequence of calls clearer.
33     \Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
34     $this->drupalLogin($admin_user);
35   }
36
37   /**
38    * Tests dialog for filter criteria.
39    */
40   public function testFilterCriteriaDialog() {
41     $this->drupalGet('admin/structure/views/view/content_recent');
42     $assert_session = $this->assertSession();
43     $page = $this->getSession()->getPage();
44
45     // Use the 'And/Or Rearrange' link for fields to open a dialog.
46     $dropbutton = $page->find('css', '.views-ui-display-tab-bucket.filter .dropbutton-toggle button');
47     $dropbutton->click();
48     $add_link = $page->findById('views-rearrange-filter');
49     $this->assertTrue($add_link->isVisible(), 'And/Or Rearrange button found.');
50     $add_link->click();
51     $assert_session->assertWaitOnAjaxRequest();
52
53     // Add a new filter group.
54     $create_new_filter_group = $page->findById('views-add-group-link');
55     $this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.');
56     $create_new_filter_group->click();
57     $assert_session->assertWaitOnAjaxRequest();
58
59     // Assert the existence of the new filter group by checking the remove group
60     // link.
61     $remove_link = $page->findLink('Remove group');
62     $this->assertTrue($remove_link->isVisible(), 'New group found.');
63
64     // Remove the group again and assert the group is not present anymore.
65     $remove_link->click();
66     $assert_session->assertWaitOnAjaxRequest();
67     $remove_link = $page->findLink('Remove group');
68     $this->assertEmpty($remove_link, 'Remove button not available');
69
70     // Checks that the admin summary is not double escaped.
71     $this->drupalGet('admin/structure/views/view/who_s_online');
72     $page = $this->getSession()->getPage();
73     $this->assertNotNull($page->findLink('User: Last access (>= -15 minutes)'));
74   }
75
76 }