diff --git a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php index 2e040fee4c79df547b0298ca51ec9f7c6d8ba599..5eb912c577cd88045cc2a9d3c4c896000a825335 100644 --- a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php +++ b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\node\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\views\Views; /** * Tests JavaScript functionality specific to delete operations. @@ -65,10 +66,10 @@ public function testNodeDelete(): void { $this->assertEquals('Are you sure you want to delete the content item Delete article from content list?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText()); $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete'); - $assert_session->waitForText('The Article Delete article from content list has been deleted.'); + $assert_session->pageTextContains('The Article Delete article from content list has been deleted.'); // Assert that the node is deleted in above operation. - $this->drupalGet('/admin/content'); - $assert_session->waitForText('There are no content items yet.'); + $this->drupalGet('admin/content'); + $assert_session->pageTextContains('There are no content items yet.'); $node = $this->createNode([ 'type' => 'article', @@ -82,11 +83,28 @@ public function testNodeDelete(): void { $this->assertEquals('Are you sure you want to delete the content item Delete article from entity form?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText()); $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete'); - $this->assertSession()->pageTextContains('The Article Delete article from entity form has been deleted.'); + $assert_session->pageTextContains('The Article Delete article from entity form has been deleted.'); - // Assert that the node is deleted in above operation. - $this->drupalGet('/admin/content'); - $assert_session->waitForText('There are no content items yet.'); + $node = $this->createNode([ + 'type' => 'article', + 'title' => 'Delete article from views entity operations', + ]); + $node->save(); + + \Drupal::service('module_installer')->install(['views']); + $view = Views::getView('content'); + $view->storage->enable()->save(); + \Drupal::service('router.builder')->rebuildIfNeeded(); + + $this->drupalGet('admin/content'); + $page->find('css', '.dropbutton-toggle button')->click(); + $page->clickLink('Delete'); + // Asserts a dialog opens with the expected text. + $this->assertEquals('Are you sure you want to delete the content item Delete article from views entity operations?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText()); + $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete'); + + $assert_session->pageTextContains('The Article Delete article from views entity operations has been deleted.'); + $assert_session->pageTextContains('No content available.'); } /** diff --git a/core/modules/views/src/Plugin/views/field/EntityOperations.php b/core/modules/views/src/Plugin/views/field/EntityOperations.php index 8b70254489c149d5005d427d9d9c450271d45bf3..b397d477824e2eab697774eacd6d018b7a0146fb 100644 --- a/core/modules/views/src/Plugin/views/field/EntityOperations.php +++ b/core/modules/views/src/Plugin/views/field/EntityOperations.php @@ -147,6 +147,10 @@ public function render(ResultRow $values) { $build = [ '#type' => 'operations', '#links' => $operations, + // Allow links to use modals. + '#attached' => [ + 'library' => ['core/drupal.dialog.ajax'], + ], ]; return $build; diff --git a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php index a1c2a78a99ee2d653c1cc0fbd32cf1a584f3cd8c..d357d5a0a47c880fadc6065d089c8b2c48639003 100644 --- a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php @@ -134,6 +134,9 @@ public function testRenderWithDestination(): void { $expected_build = [ '#type' => 'operations', '#links' => $operations, + '#attached' => [ + 'library' => ['core/drupal.dialog.ajax'], + ], ]; $expected_build['#links']['foo']['query'] = ['destination' => 'foobar']; $build = $this->plugin->render($result); @@ -176,6 +179,9 @@ public function testRenderWithoutDestination(): void { $expected_build = [ '#type' => 'operations', '#links' => $operations, + '#attached' => [ + 'library' => ['core/drupal.dialog.ajax'], + ], ]; $build = $this->plugin->render($result); $this->assertSame($expected_build, $build);