You are here

public function LayoutBuilderModalTest::testAdminCss in Layout Builder Modal 8

Tests minimal presence/absence of admin CSS.

File

tests/src/FunctionalJavascript/LayoutBuilderModalTest.php, line 260

Class

LayoutBuilderModalTest
Tests Layout Builder Modal.

Namespace

Drupal\Tests\layout_builder_modal\FunctionalJavascript

Code

public function testAdminCss() {
  $layout_url = 'node/1/layout';
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->drupalGet($layout_url);
  $this
    ->click('.layout-builder__add-block .layout-builder__link');
  $assert_session
    ->assertWaitOnAjaxRequest();
  $this
    ->clickLink('Create custom block');
  $assert_session
    ->assertWaitOnAjaxRequest();

  // Verify there is a 'primary' class.
  $assert_session
    ->elementExists('css', '#layout-builder-modal .button--primary');
  $button_background = $this
    ->getSession()
    ->evaluateScript('jQuery("#layout-builder-modal .button--primary").css("background-color")');
  $default_background = "rgb(221, 221, 221)";
  $this
    ->assertSame($button_background, $default_background);
  \Drupal::configFactory()
    ->getEditable('layout_builder_modal.settings')
    ->set('theme_display', 'seven')
    ->save();
  $this
    ->drupalGet($layout_url);
  $this
    ->click('.layout-builder__add-block .layout-builder__link');
  $assert_session
    ->assertWaitOnAjaxRequest();
  $this
    ->clickLink('Create custom block');
  $assert_session
    ->assertWaitOnAjaxRequest();

  // Verify there seven background attribute is present.
  $button_background = $this
    ->getSession()
    ->evaluateScript('jQuery("#layout-builder-modal .button--primary").css("background-color")');
  $seven_background = "rgb(0, 113, 184)";
  $this
    ->assertSame($seven_background, $button_background);
}