protected function UiPatternsLibraryOverviewTest::assertPatternVariant in UI Patterns 8
Assert pattern variant metadata and preview.
Parameters
string $root: CSS selector of element containing the table.
array $variant: Variant expected values.
1 call to UiPatternsLibraryOverviewTest::assertPatternVariant()
- UiPatternsLibraryOverviewTest::assertPatternPreview in modules/
ui_patterns_library/ tests/ src/ FunctionalJavascript/ UiPatternsLibraryOverviewTest.php - Assert pattern preview display.
File
- modules/
ui_patterns_library/ tests/ src/ FunctionalJavascript/ UiPatternsLibraryOverviewTest.php, line 170
Class
- UiPatternsLibraryOverviewTest
- Test patterns overview page.
Namespace
Drupal\Tests\ui_patterns_library\FunctionalJavascriptCode
protected function assertPatternVariant($root, array $variant) {
$session = $this
->assertSession();
$name = $variant['meta']['name'];
// Assert table header.
foreach ([
'Variant',
'Name',
'Description',
] as $index => $item) {
$child = $index + 1;
$session
->elementContains('css', "{$root} table.pattern-preview__variants--{$name} > thead > tr > th:nth-child({$child})", $item);
}
// Assert variant meta table rows.
$row_root = "{$root} table.pattern-preview__variants--{$name} > tbody > tr";
$session
->elementContains('css', "{$row_root} > td:nth-child(1)", $variant['meta']['name']);
$session
->elementContains('css', "{$row_root} > td:nth-child(2)", $variant['meta']['label']);
$session
->elementContains('css', "{$row_root} > td:nth-child(3)", $variant['meta']['description']);
// Assert variant preview.
$session
->elementContains('css', "{$root} .pattern-preview__markup--variant_{$name}", $variant['preview']);
}