protected function UiPatternsLibraryOverviewTest::assertPatternPreview in UI Patterns 8
Assert pattern preview display.
Parameters
array $pattern: Expected pattern.
2 calls to UiPatternsLibraryOverviewTest::assertPatternPreview()
- UiPatternsLibraryOverviewTest::testOverviewPage in modules/
ui_patterns_library/ tests/ src/ FunctionalJavascript/ UiPatternsLibraryOverviewTest.php - Tests overview page.
- UiPatternsLibraryOverviewTest::testSinglePages in modules/
ui_patterns_library/ tests/ src/ FunctionalJavascript/ UiPatternsLibraryOverviewTest.php - Tests overview page.
File
- modules/
ui_patterns_library/ tests/ src/ FunctionalJavascript/ UiPatternsLibraryOverviewTest.php, line 102
Class
- UiPatternsLibraryOverviewTest
- Test patterns overview page.
Namespace
Drupal\Tests\ui_patterns_library\FunctionalJavascriptCode
protected function assertPatternPreview(array $pattern) {
$session = $this
->assertSession();
// Assert pattern title and description.
$root = '.pattern-preview__' . $pattern['name'];
$session
->elementExists('css', $root);
$session
->elementContains('css', "{$root} > h3.pattern-preview__label", $pattern['label']);
$session
->elementContains('css', "{$root} > p.pattern-preview__description", $pattern['description']);
// Assert metadata block.
$this
->assertPatternFields($root, $pattern);
if (!$pattern['has_variants']) {
// Make sure no variant markup exists.
$session
->elementNotExists('css', "{$root} > fieldset.pattern-preview__preview > .pattern-preview__variants");
// Assert preview content when without variants.
$session
->elementContains('css', "{$root} > fieldset.pattern-preview__preview > .pattern-preview__markup", $pattern['preview']);
}
else {
// Assert that variant markup exists.
$session
->elementExists('css', "{$root} > fieldset.pattern-preview__preview > .pattern-preview__variants");
// Assert variant meta information and preview.
foreach ($pattern['variants'] as $variant) {
$this
->assertPatternVariant($root, $variant);
}
}
}