public function ConditionalFieldLinkFieldTest::testInvisibleEmpty in Conditional Fields 8
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/ConditionalFieldLinkFieldTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldLinkFieldTest::testInvisibleEmpty()
The target field is Invisible when the control field is Empty.
Overrides ConditionalFieldFilledEmptyInterface::testInvisibleEmpty
File
- tests/
src/ FunctionalJavascript/ ConditionalFieldLinkFieldTest.php, line 561
Class
- ConditionalFieldLinkFieldTest
- Test Conditional Fields Link field plugin.
Namespace
Drupal\Tests\conditional_fields\FunctionalJavascriptCode
public function testInvisibleEmpty() {
$this
->baseTestSteps();
$url = 'https://drupal.org';
// Visit a ConditionalFields configuration page for Content bundles.
$this
->createCondition('body', $this->fieldName, '!visible', 'empty');
$this
->createScreenshot($this->screenshotPath . '01-testFieldLinkVisibleValueNot.png');
$this
->createScreenshot($this->screenshotPath . '02-testFieldLinkVisibleValueNot.png');
// Check if that configuration is saved.
$this
->drupalGet('admin/structure/types/manage/article/conditionals');
$this
->createScreenshot($this->screenshotPath . '03-testFieldLinkVisibleValueNot.png');
$this
->assertSession()
->pageTextContains('body ' . $this->fieldName . ' !visible empty');
// Visit Article Add form to check that conditions are applied.
$this
->drupalGet('node/add/article');
// Check that the field Body is visible.
$this
->createScreenshot($this->screenshotPath . '04-testFieldLinkVisibleValueNot.png');
$this
->waitUntilHidden('.field--name-body', 50, '01. Article Body field is visible');
// Change a link that should not show the body.
$this
->changeField($this->fieldSelector, $url);
$this
->createScreenshot($this->screenshotPath . '05-testFieldLinkVisibleValueNot.png');
$this
->waitUntilVisible('.field--name-body', 50, '02. Article Body field is not visible');
// Change a link value to show the body.
$this
->changeField($this->fieldSelector, '');
$this
->createScreenshot($this->screenshotPath . '08-testFieldLinkVisibleValueNot.png');
$this
->waitUntilHidden('.field--name-body', 50, '03. Article Body field is visible');
}