From b528da6072fd4324c07796752d524a36dcbbdcbc Mon Sep 17 00:00:00 2001 From: Pete Inge Date: Fri, 12 Apr 2024 18:19:42 -0400 Subject: [PATCH] Add in Quick tests --- phpunit.xml | 0 .../FunctionalJavascript/AjaxContentTest.php | 86 +++++++++++++++++++ 2 files changed, 86 insertions(+) mode change 100644 => 100755 phpunit.xml create mode 100644 tests/src/FunctionalJavascript/AjaxContentTest.php diff --git a/phpunit.xml b/phpunit.xml old mode 100644 new mode 100755 diff --git a/tests/src/FunctionalJavascript/AjaxContentTest.php b/tests/src/FunctionalJavascript/AjaxContentTest.php new file mode 100644 index 0000000..b36967c --- /dev/null +++ b/tests/src/FunctionalJavascript/AjaxContentTest.php @@ -0,0 +1,86 @@ +drupalCreateUser(['administer actions']); + // $this->drupalLogin($user); + } + + /** + * Tests action plugins with AJAX save their configuration. + */ + public function testAjaxContentLoad() { + // Simple example. + $url = Url::fromRoute('bluecadet_ajax_content_example.simple_example_immediate'); + $this->drupalGet($url); + // $this->assertSession()->assertWaitOnAjaxRequest(); + $page = $this->getSession()->getPage(); + + $this->assertSession()->pageTextContains('Ajaxed Paragraph 1.'); + $this->assertSession()->pageTextContains('Ajaxed Paragraph 2.'); + $this->assertSession()->pageTextContains('Ajaxed Paragraph 3.'); + + + // Scroll example. + $url = Url::fromRoute('bluecadet_ajax_content_example.simple_example_scroll'); + $this->drupalGet($url); + $this->assertSession()->assertWaitOnAjaxRequest(); + $page = $this->getSession()->getPage(); + + $this->assertSession()->waitForElementVisible('css', 'div[data-ajax-scroll=*]'); + + $this->assertSession()->pageTextContains('Ajaxed Paragraph 1.'); + $this->assertSession()->pageTextContains('Ajaxed Paragraph 2.'); + $this->assertSession()->pageTextContains('Ajaxed Paragraph 3.'); + + + // $id = 'test_plugin'; + // $this->assertSession()->waitForElementVisible('named', ['button', 'Edit'])->press(); + // $this->assertSession()->waitForElementVisible('css', '[name="id"]')->setValue($id); + + // $page->find('css', '[name="having_a_party"]') + // ->check(); + // $this->assertSession()->waitForElementVisible('css', '[name="party_time"]'); + + // $party_time = 'Evening'; + // $page->find('css', '[name="party_time"]') + // ->setValue($party_time); + + // $page->find('css', '[value="Save"]') + // ->click(); + + // $url = Url::fromRoute('entity.action.collection'); + // $this->assertSession()->pageTextContains('The action has been successfully saved.'); + // $this->assertSession()->addressEquals($url); + + // // Check storage. + // $instance = Action::load($id); + // $configuration = $instance->getPlugin()->getConfiguration(); + // $this->assertEquals(['party_time' => $party_time], $configuration); + + // // Configuration should be shown in edit form. + // $this->drupalGet($instance->toUrl('edit-form')); + // $this->assertSession()->checkboxChecked('having_a_party'); + // $this->assertSession()->fieldValueEquals('party_time', $party_time); + } +}