You are here

public function UiPatternsFieldGroupRenderTest::testUiPatternsFieldGroupRendering in UI Patterns 8

Test that pattern field group settings are correctly saved.

File

modules/ui_patterns_field_group/tests/src/FunctionalJavascript/UiPatternsFieldGroupRenderTest.php, line 48

Class

UiPatternsFieldGroupRenderTest
Test Field Group pattern rendering.

Namespace

Drupal\Tests\ui_patterns_field_group\FunctionalJavascript

Code

public function testUiPatternsFieldGroupRendering() {
  $assert_session = $this
    ->assertSession();
  $this
    ->enableTwigDebugMode();
  $user = $this
    ->drupalCreateUser([], NULL, TRUE);
  $this
    ->drupalLogin($user);
  $node = $this
    ->drupalCreateNode([
    'title' => 'Test article',
    'field_text' => 'Test text field',
    'type' => 'article',
  ]);
  $this
    ->drupalGet($node
    ->toUrl());

  // Assert correct variant suggestions.
  $suggestions = [
    'pattern-metadata--variant-first--field-group--group-pattern-group--node--article--default.html.twig',
    'pattern-metadata--variant-first--field-group--group-pattern-group--node--default.html.twig',
    'pattern-metadata--variant-first--field-group--group-pattern-group--node--article.html.twig',
    'pattern-metadata--variant-first--field-group--group-pattern-group--node.html.twig',
    'pattern-metadata--variant-first--field-group--group-pattern-group.html.twig',
    'pattern-metadata--variant-first--field-group.html.twig',
    'pattern-metadata--field-group--group-pattern-group--node--article--default.html.twig',
    'pattern-metadata--field-group--group-pattern-group--node--default.html.twig',
    'pattern-metadata--field-group--group-pattern-group--node--article.html.twig',
    'pattern-metadata--field-group--group-pattern-group--node.html.twig',
    'pattern-metadata--field-group--group-pattern-group.html.twig',
    'pattern-metadata--field-group.html.twig',
    'pattern-metadata--variant-first.html.twig',
    'pattern-metadata.html.twig',
  ];
  foreach ($suggestions as $suggestion) {
    $assert_session
      ->responseContains($suggestion);
  }

  // Test field content is rendered in field group pattern.
  $assert_session
    ->pageTextContains('Field 1: Text Test text field');
}