Skip to content
Snippets Groups Projects
Verified Commit c217e00f authored by Pierre Rudloff's avatar Pierre Rudloff
Browse files

Add JS test

parent 3f6c8613
No related branches found
No related tags found
No related merge requests found
module.exports = {
'@tags': ['core', 'ajax'],
before(browser) {
browser.drupalInstall({
setupFile:
'core/tests/Drupal/TestSite/TestSiteViewAjaxInstallTestScript.php',
installProfile: 'minimal',
});
},
after(browser) {
browser.drupalUninstall();
},
'Test View AJAX GET parameters': (browser) => {
browser.drupalLoginAsAdmin(() => {
browser
.drupalRelativeURL('/admin/content?title=&type=All&status=All')
.waitForElementVisible('body', 1000)
.captureNetworkRequests((requestParams) => {
if (
requestParams.request.headers['X-Requested-With'] ===
'XMLHttpRequest'
) {
const searchParams = URL.parse(
requestParams.request.url,
).searchParams;
browser.assert.strictEqual(
searchParams.getAll('title').length,
1,
'Duplicate title parameter',
);
browser.assert.strictEqual(
searchParams.getAll('type').length,
1,
'Duplicate type parameter',
);
browser.assert.strictEqual(
searchParams.getAll('status').length,
1,
'Duplicate status parameter',
);
}
})
.click('#edit-submit-content');
});
},
};
<?php
declare(strict_types=1);
namespace Drupal\TestSite;
use Drupal\Core\Extension\ModuleInstallerInterface;
/**
* Setup file used by ajaxGetParametersTest.js.
*
* @see \Drupal\KernelTests\Scripts\TestSiteApplicationTest
*/
class TestSiteViewAjaxInstallTestScript implements TestSetupInterface {
/**
* {@inheritdoc}
*/
public function setup(): void {
$module_installer = \Drupal::service('module_installer');
assert($module_installer instanceof ModuleInstallerInterface);
$module_installer->install(['views', 'node']);
// Enable AJAX on the /admin/content View.
\Drupal::configFactory()->getEditable('views.view.content')
->set('display.default.display_options.use_ajax', TRUE)
->save();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment