3 namespace Drupal\Tests\views_ui\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
8 * Tests the JavaScript library caching on consecutive requests.
12 class LibraryCachingTest extends WebDriverTestBase {
17 public static $modules = ['node', 'views', 'views_ui'];
20 * Tests if the Views UI dialogs open on consecutive requests.
22 public function testConsecutiveDialogRequests() {
23 $admin_user = $this->drupalCreateUser([
24 'administer site configuration',
27 'access content overview',
30 // Disable automatic live preview to make the sequence of calls clearer.
31 \Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
32 $this->drupalLogin($admin_user);
34 $this->drupalGet('admin/structure/views/view/content');
35 $page = $this->getSession()->getPage();
37 // Use the 'Add' link for fields to open a dialog. This will load the proper
39 $add_link = $page->findById('views-add-field');
40 $this->assertTrue($add_link->isVisible(), 'Add fields button found.');
42 $this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
43 // Close the dialog and open it again. No no libraries will be loaded, but a
44 // cache entry will be made for not loading any libraries.
45 $page->pressButton('Close');
47 $this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
48 $page->pressButton('Close');
51 $this->drupalGet('admin/structure/views/view/content');
52 $page = $this->getSession()->getPage();
54 // Now use the 'Update preview' button to load libraries.
55 $preview = $page->findById('preview-submit');
56 // The first click will load all the libraries.
58 $this->assertJsCondition("jQuery('.ajax-progress').length === 0");
59 // The second click will not load any new libraries.
61 $this->assertJsCondition("jQuery('.ajax-progress').length === 0");
62 // Check to see if the dialogs still open.
63 $add_link = $page->findById('views-add-field');
65 $this->assertJsCondition("jQuery('.ui-dialog-titlebar').length > 0");
66 $page->pressButton('Close');