diff --git a/core/modules/system/tests/modules/dialog_test/dialog_test.info.yml b/core/modules/system/tests/modules/dialog_test/dialog_test.info.yml new file mode 100644 index 0000000..408e4bc --- /dev/null +++ b/core/modules/system/tests/modules/dialog_test/dialog_test.info.yml @@ -0,0 +1,6 @@ +name: 'Dialog test module' +type: module +description: 'Module for the dialog related tests.' +package: Testing +version: VERSION +core: 8.x diff --git a/core/modules/system/tests/modules/dialog_test/dialog_test.libraries.yml b/core/modules/system/tests/modules/dialog_test/dialog_test.libraries.yml new file mode 100644 index 0000000..62d4ea1 --- /dev/null +++ b/core/modules/system/tests/modules/dialog_test/dialog_test.libraries.yml @@ -0,0 +1,7 @@ +dialog_debug: + version: VERSION + js: + js/dialog.debug.js: {} + dependencies: + - core/jquery + - core/drupal diff --git a/core/modules/system/tests/modules/dialog_test/dialog_test.module b/core/modules/system/tests/modules/dialog_test/dialog_test.module new file mode 100644 index 0000000..4fb516b --- /dev/null +++ b/core/modules/system/tests/modules/dialog_test/dialog_test.module @@ -0,0 +1,8 @@ +findById('views-rearrange-filter'); $this->assertTrue($add_link->isVisible(), 'And/Or Rearrange button found.'); $add_link->click(); - $assert_session->assertWaitOnAjaxRequest(); + + // Wait for the dialog to open. + $this->waitForDialog(); // Add a new filter group. $create_new_filter_group = $page->findById('views-add-group-link'); $this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.'); $create_new_filter_group->click(); - $assert_session->assertWaitOnAjaxRequest(); // Assert the existence of the new filter group by checking the remove group // link. - $remove_link = $page->findLink('Remove group'); + $remove_link = $assert_session->waitForElementVisible('named_exact', [ + 'link', + 'Remove group', + ]); + $this->assertTrue($remove_link->isVisible(), 'New group found.'); // Remove the group again and assert the group is not present anymore. $remove_link->click(); - $assert_session->assertWaitOnAjaxRequest(); - $remove_link = $page->findLink('Remove group'); - $this->assertEmpty($remove_link, 'Remove button not available'); + + $result = $page->waitFor(10, function () use ($page) { + $remove_link = $page->findLink('Remove group'); + return empty($remove_link); + }); + + $this->assertTrue($result, 'Remove button not available'); // Checks that the admin summary is not double escaped. $this->drupalGet('admin/structure/views/view/who_s_online'); diff --git a/core/tests/Drupal/FunctionalTests/AssertDialogTrait.php b/core/tests/Drupal/FunctionalTests/AssertDialogTrait.php new file mode 100644 index 0000000..984818f --- /dev/null +++ b/core/tests/Drupal/FunctionalTests/AssertDialogTrait.php @@ -0,0 +1,22 @@ +assertArrayHasKey('dialog_test', self::$modules, 'The dialog_test module is required for this assertion.'); + $condition = 'Drupal.dialog_debug.has_open_dialog == true'; + $this->getSession()->wait($timeout, $condition); + } + +}