Skip to content

Commit

Permalink
Add in Quick tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pingevt committed Apr 13, 2024
1 parent fe1c2ac commit ffbc600
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/drupal-tests-and-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
working-directory: ${{ env.DRUPAL_ROOT }}
run: |
composer config --no-plugins allow-plugins.oomphinc/composer-installers-extender true
composer config repositories.0 path $GITHUB_WORKSPACE
composer config repositories.$DRUPAL_MODULE_NAME '{"type": "path", "url": "$GITHUB_WORKSPACE", "options": {"symlink": true}}'
composer config extra.installer-paths
composer config --json extra.installer-types '["custom-drupal-module"]'
composer config --json --merge extra.installer-paths '{"modules/bluecadet/{$name}": ["type:custom-drupal-module"]}'
Expand Down Expand Up @@ -161,6 +161,12 @@ jobs:
# --sqlite /tmp/test.sqlite \
# --url $SIMPLETEST_BASE_URL $DRUPAL_MODULE_NAME

- name: Debug 1
working-directory: ${{ env.DRUPAL_ROOT }}
continue-on-error: true
run: |
ls -sla $MODULE_FOLDER
# Uncomment this step to run tests using phpunit. Your module is expected
# to ship with 'phpunit.xml' file. See the repository for an example
# phpunit.xml file.
Expand Down
Empty file modified phpunit.xml
100644 → 100755
Empty file.
89 changes: 89 additions & 0 deletions tests/src/FunctionalJavascript/AjaxContentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace Drupal\bluecadet_ajax_content\FunctionalJavascript;

use Drupal\Core\Url;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\system\Entity\Action;

class AjaxContentTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['bluecadet_ajax_content', 'bluecadet_ajax_content_example'];

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';

/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// $user = $this->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);

$session_assert = $this->assertSession();

$session_assert->assertWaitOnAjaxRequest();

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.1.x, 8.1, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.1.x, 8.1, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.1.x, 8.2, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.1.x, 8.2, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.2.x, 8.1, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.2.x, 8.1, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.2.x, 8.2, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.2.x, 8.2, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.3.x, 8.1, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.3.x, 8.1, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.3.x, 8.2, 10.4)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().

Check failure on line 39 in tests/src/FunctionalJavascript/AjaxContentTest.php

View workflow job for this annotation

GitHub Actions / test (10.3.x, 8.2, 10.6)

Call to an undefined method Drupal\Tests\WebAssert::assertWaitOnAjaxRequest().
$page = $this->getSession()->getPage();

$session_assert->pageTextContains('Ajaxed Paragraph 1.');
$session_assert->pageTextContains('Ajaxed Paragraph 2.');
$session_assert->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);
}
}

0 comments on commit ffbc600

Please sign in to comment.