public function MetatagAsyncWidgetTest::doTestMetatagAsyncWidget in Metatag Asynchronous Widget 1.0.x
Tests the Metatag Async Widget.
4 calls to MetatagAsyncWidgetTest::doTestMetatagAsyncWidget()
- MetatagAsyncWidgetTest::testMetatagAsyncWidgetBartik in tests/
src/ FunctionalJavascript/ MetatagAsyncWidgetTest.php - Tests the Metatag Async Widget with Bartik.
- MetatagAsyncWidgetTest::testMetatagAsyncWidgetClaro in tests/
src/ FunctionalJavascript/ MetatagAsyncWidgetTest.php - Tests the Metatag Async Widget with Claro.
- MetatagAsyncWidgetTest::testMetatagAsyncWidgetSeven in tests/
src/ FunctionalJavascript/ MetatagAsyncWidgetTest.php - Tests the Metatag Async Widget with Seven.
- MetatagAsyncWidgetTest::testMetatagAsyncWidgetStark in tests/
src/ FunctionalJavascript/ MetatagAsyncWidgetTest.php - Tests the Metatag Async Widget with Stark.
File
- tests/
src/ FunctionalJavascript/ MetatagAsyncWidgetTest.php, line 111
Class
- MetatagAsyncWidgetTest
- Ensures that metatag_async_widget works with JavaScript enabled.
Namespace
Drupal\Tests\metatag_async_widget\FunctionalJavascriptCode
public function doTestMetatagAsyncWidget($metatag_details_xpath) {
$assert = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Add a Metatag field to the content type.
$this
->drupalGet('admin/structure/types/manage/metatag_node/fields/add-field');
$assert
->fieldExists('new_storage_type')
->setValue('metatag');
$assert
->waitForField('label');
$assert
->fieldExists('label')
->setValue('Meta tags');
$assert
->waitForText('Machine name');
$page
->pressButton('Save and continue');
$page
->pressButton('Save field settings');
$page
->pressButton('Save settings');
// Set the form display.
$this
->drupalGet('admin/structure/types/manage/metatag_node/form-display');
$assert
->fieldExists('edit-fields-field-meta-tags-type')
->setValue('metatag_async_widget_firehose');
$assert
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$assert
->pageTextContains('Your settings have been saved.');
// Create a node.
$this
->drupalGet('node/add/metatag_node');
$assert
->fieldExists('edit-title-0-value')
->setValue($this
->getRandomGenerator()
->sentences('4'));
$assert
->fieldNotExists('field_meta_tags[0][basic][abstract]');
$assert
->waitForElement('xpath', $metatag_details_xpath)
->click();
$assert
->waitForButton('Customize meta tags')
->click();
$assert
->waitForText('Configure the meta tags below.');
$assert
->pageTextContains('Configure the meta tags below.');
// Ensure the summary is not duplicated.
$selector = substr($metatag_details_xpath, strrpos($metatag_details_xpath, '/') + 1);
$this
->htmlOutput();
$assert
->elementsCount('xpath', '//' . $selector, 1);
$abstract = $this
->getRandomGenerator()
->sentences(10);
$field = $assert
->fieldExists('field_meta_tags[0][basic][abstract]');
// Ensure that field has been loaded via AJAX. See
// \Drupal\Component\Utility\Html::getUniqueId().
$this
->assertRegExp('/^edit-field-meta-tags-0-basic-abstract--([a-zA-Z0-9_-])*$/', $field
->getAttribute('id'));
$field
->setValue($abstract);
$page
->pressButton('Save');
// For some reason we need to sleep here before trying to click edit.
// @todo Without this the Seven test fail, work out why.
sleep(1);
// Edit the node and ensure the abstract is saved.
$assert
->waitForLink('Edit')
->click();
$assert
->fieldNotExists('field_meta_tags[0][basic][abstract]');
$assert
->waitForElement('xpath', $metatag_details_xpath)
->click();
$assert
->waitForButton('Customize meta tags')
->click();
$assert
->waitForText('Configure the meta tags below.');
$assert
->fieldValueEquals('field_meta_tags[0][basic][abstract]', $abstract);
}