public function AuthenticationFormJsTest::testKeyAddForm in Apigee Edge 8
Tests the Key add form.
We assume that if the Authentication form and the Key add form test passed then the Key edit form also works correctly, because the Authentication form is a customized Key edit form.
File
- tests/
src/ FunctionalJavascript/ Form/ AuthenticationFormJsTest.php, line 154
Class
- AuthenticationFormJsTest
- Apigee Edge API credentials, authentication form, key integration test.
Namespace
Drupal\Tests\apigee_edge\FunctionalJavascript\FormCode
public function testKeyAddForm() {
if ($this->instanceType == EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this
->markTestSkipped('Skipping "testKeyAddForm": can only be tested with public/private cloud credentials.');
}
$web_assert = $this
->assertSession();
// Test the authentication form using the default key stored by environment
// variable key provider.
$this
->drupalLogin($this->rootUser);
$this
->drupalGet(Url::fromRoute('entity.key.add_form'));
// The default Key type is "Authentication" so the "Send request" button
// should not be visible.
$web_assert
->elementNotExists('css', 'input[name="test_connection"]');
$this
->cssSelect('select[name="key_type"]')[0]
->setValue('apigee_auth');
// The "Send request" button now should appear.
$web_assert
->waitForElementVisible('css', 'input[name="test_connection"]');
// The "Send request" button now should not appear if Key entity form
// customization is disabled.
$this
->config('apigee_edge.dangerzone')
->set('do_not_alter_key_entity_forms', TRUE)
->save();
$this
->drupalGet(Url::fromRoute('entity.key.add_form'));
$this
->cssSelect('select[name="key_type"]')[0]
->setValue('apigee_auth');
$web_assert
->assertWaitOnAjaxRequest();
$web_assert
->elementNotExists('css', 'input[name="test_connection"]');
// Revert the config change.
$this
->config('apigee_edge.dangerzone')
->set('do_not_alter_key_entity_forms', FALSE)
->save();
$this
->validateForm([
$this,
'visitKeyAddForm',
]);
}