diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Entity/EntityListBuilderTest.php new file mode 100644 index 0000000..a3a52e4 --- /dev/null +++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Entity/EntityListBuilderTest.php @@ -0,0 +1,68 @@ +webUser = $this->drupalCreateUser(['administer entity_test content']); + $this->drupalLogin($this->webUser); + } + + /** + * Test that delete confirm forms use a modal dialog. + */ + public function testDeleteConfirmForm() { + /** @var \Drupal\entity_test\Entity\EntityTest[] $entities */ + $entities = []; + foreach (range(1, 10) as $i) { + $entities[$i] = EntityTest::create(['name' => 'Test entity ' . $i]); + $entities[$i]->save(); + } + + /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $entity_storage */ + $entity_storage = $this->container->get('entity_type.manager')->getStorage('entity_test'); + + $this->assertTrue($entity_storage->load($entities[3]->id())); + $this->drupalGet(Url::fromRoute('entity.entity_test.collection')); + + // Expand the operations for the 3rd entity. + $this->click('table tr:contains("Test entity 3") button .dropbutton-arrow'); + $this->click('table tr:contains("Test entity 3") .delete a'); + $this->assertSession()->assertWaitOnAjaxRequest(); + // Should still be on the listing page. + $this->assertSession()->addressEquals(Url::fromRoute('entity.entity_test.collection')->toString()); + // Delete the 3rd entity. + $this->click('.ui-dialog button:contains("' . t('Delete') . '")'); + $this->assertFalse($entity_storage->loadUnchanged($entities[3]->id())); + // @todo Something is not quite right here. Clicking the button should + // result in a new page load, presumably with a success message? + } + +}