Verified Commit 28f4400e authored by godotislate's avatar godotislate
Browse files

task: #3617584 Change tests using Olivero

By: quietone
By: gábor hojtsy
By: godotislate
parent 0263bee5
Loading
Loading
Loading
Loading
Loading
+4 −4
Changes for core/modules/block/tests/src/Functional/BlockAdminThemeTest.php: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -38,15 +38,15 @@ public function testAdminTheme(): void {

    // Ensure that access to block admin page is denied when theme is not
    // installed.
    $this->drupalGet('admin/structure/block/list/olivero');
    $this->drupalGet('admin/structure/block/list/test_theme');
    $this->assertSession()->statusCodeEquals(403);

    // Install admin theme and confirm that tab is accessible.
    \Drupal::service('theme_installer')->install(['olivero']);
    $edit['admin_theme'] = 'olivero';
    \Drupal::service('theme_installer')->install(['test_theme']);
    $edit['admin_theme'] = 'test_theme';
    $this->drupalGet('admin/appearance');
    $this->submitForm($edit, 'Save configuration');
    $this->drupalGet('admin/structure/block/list/olivero');
    $this->drupalGet('admin/structure/block/list/test_theme');
    $this->assertSession()->statusCodeEquals(200);
  }

+3 −3
Changes for core/modules/block/tests/src/Functional/NonDefaultBlockAdminTest.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -43,11 +43,11 @@ public function testNonDefaultBlockAdmin(): void {
      'administer themes',
    ]);
    $this->drupalLogin($admin_user);
    $new_theme = 'olivero';
    $new_theme = 'test_theme';
    \Drupal::service('theme_installer')->install([$new_theme]);
    // Ensure that the Olivero tab is shown.
    // Ensure that the Test theme tab is shown.
    $this->drupalGet('admin/structure/block/list/' . $new_theme);
    $this->assertSession()->pageTextContains('Olivero');
    $this->assertSession()->pageTextContains('Test theme');
  }

}
+17 −16
Changes for core/modules/block/tests/src/FunctionalJavascript/BlockDragTest.php: 17 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class BlockDragTest extends WebDriverTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'olivero';
  protected $defaultTheme = 'claro';

  /**
   * {@inheritdoc}
@@ -50,22 +50,23 @@ public function testDragAndDropBlocks(): void {
    // Test if drag orientation on block layout page was applied with success.
    $this->assertNotEmpty($assertSession->waitForElementVisible('css', '.tabledrag-handle-y'));

    // Dragging main-menu and status messages to header region.
    $siteBranding = $this->getDragRow($page, 'edit-blocks-olivero-site-branding');
    $mainMenuRow = $this->getDragRow($page, 'edit-blocks-olivero-main-menu');
    $mainMenuRow->dragTo($siteBranding);
    $messages = $this->getDragRow($page, 'edit-blocks-olivero-messages');
    $messages->dragTo($siteBranding);
    // Dragging Secondary tabs and Status messages to header region.
    $primaryTabs = $this->getDragRow($page, 'edit-blocks-claro-primary-local-tasks');

    // Test if both blocks above was positioned on the header region.
    $secondaryTabs = $this->getDragRow($page, 'edit-blocks-claro-secondary-local-tasks');
    $secondaryTabs->dragTo($primaryTabs);
    $messages = $this->getDragRow($page, 'edit-blocks-claro-messages');
    $messages->dragTo($primaryTabs);

    // Test if both blocks above were positioned on the header region.
    $this->assertEquals(
      'header',
      $page->findField('edit-blocks-olivero-main-menu-region')->getValue(),
      $page->findField('edit-blocks-claro-secondary-local-tasks-region')->getValue(),
      'Main menu should be positioned on header region'
    );
    $this->assertEquals(
      'header',
      $page->findField('edit-blocks-olivero-messages-region')->getValue(),
      $page->findField('edit-blocks-claro-messages-region')->getValue(),
      'Status messages should be positioned on header region'
    );

@@ -74,16 +75,16 @@ public function testDragAndDropBlocks(): void {

    // Test if the message for empty regions appear after drag the unique block
    // on the region.
    $noBlockMessage = $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-primary-menu-message"] td')->getText();
    $this->assertSession()->assert($noBlockMessage === 'No blocks in this region', 'Region primary menu should be empty.');
    $noBlockMessage = $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-pre-content-message"] td')->getText();
    $this->assertSession()->assert($noBlockMessage === 'No blocks in this region', 'Region pre-content should be empty.');

    // Testing drag row to an empty region.
    $pageTitle = $this->getDragRow($page, 'edit-blocks-olivero-page-title');
    $heroRegion = $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-hero-message"]');
    $pageTitle = $this->getDragRow($page, 'edit-blocks-claro-page-title');
    $heroRegion = $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-help-message"]');
    $pageTitle->dragTo($heroRegion);
    $this->assertSession()->assert(
      $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-hero-message"] td')->getText() !== 'No blocks in this region',
      "Region here shouldn't be empty"
      $page->find('css', 'tr[data-drupal-selector="edit-blocks-region-help-message"] td')->getText() !== 'No blocks in this region',
      "Region help shouldn't be empty"
    );

  }
+17 −14
Changes for core/modules/block/tests/src/Kernel/ConfigActionsTest.php: 17 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -47,12 +47,12 @@ protected function setUp(): void {
    parent::setUp();
    $this->installConfig('system');
    $this->container->get(ThemeInstallerInterface::class)->install([
      'olivero',
      'stark',
      'claro',
      'block_test_theme',
    ]);
    $this->config('system.theme')
      ->set('default', 'olivero')
      ->set('default', 'stark')
      ->set('admin', 'claro')
      ->save();
    $this->configActionManager = $this->container->get('plugin.manager.config_action');
@@ -62,7 +62,7 @@ protected function setUp(): void {
   * Tests the application of entity method actions on a block.
   */
  public function testEntityMethodActions(): void {
    $block = $this->placeBlock('system_messages_block', ['theme' => 'olivero']);
    $block = $this->placeBlock('system_messages_block', ['theme' => 'stark']);
    $this->assertSame('content', $block->getRegion());
    $this->assertSame(0, $block->getWeight());

@@ -97,29 +97,32 @@ public function testPlaceBlockActionOnlyWorksOnBlocks(string $action): void {
   * Verifies placeBlockInDefaultTheme action doesn't alter an existing block.
   */
  public function testPlaceBlockActionDoesNotChangeExistingBlock(): void {
    $extant_region = Block::load('olivero_powered')->getRegion();
    $this->config('system.theme')
      ->set('default', 'claro')
      ->save();
    $extant_region = Block::load('claro_breadcrumbs')->getRegion();
    $this->assertNotSame('content', $extant_region);

    $this->configActionManager->applyAction('placeBlockInDefaultTheme', 'block.block.olivero_powered', [
    $this->configActionManager->applyAction('placeBlockInDefaultTheme', 'block.block.claro_powered', [
      'plugin' => 'system_powered_by_block',
      'region' => [
        'olivero' => 'content',
        'claro' => 'content',
      ],
    ]);
    // The extant block should be unchanged.
    $this->assertSame($extant_region, Block::load('olivero_powered')->getRegion());
    $this->assertSame($extant_region, Block::load('claro_breadcrumbs')->getRegion());
  }

  /**
 * Tests place block in dynamic region.
 */
  #[TestWith(["placeBlockInDefaultTheme", "olivero", "header"])]
  #[TestWith(["placeBlockInDefaultTheme", "stark", "header"])]
  #[TestWith(["placeBlockInAdminTheme", "claro", "page_bottom"])]
  public function testPlaceBlockInDynamicRegion(string $action, string $expected_theme, string $expected_region): void {
    $this->configActionManager->applyAction($action, 'block.block.test_block', [
      'plugin' => 'system_powered_by_block',
      'region' => [
        'olivero' => 'header',
        'stark' => 'header',
        'claro' => 'page_bottom',
      ],
      'default_region' => 'content',
@@ -142,7 +145,7 @@ public function testPlaceBlockInDynamicRegion(string $action, string $expected_t
  /**
 * Tests place block in static region.
 */
  #[TestWith(["placeBlockInDefaultTheme", "olivero"])]
  #[TestWith(["placeBlockInDefaultTheme", "stark"])]
  #[TestWith(["placeBlockInAdminTheme", "claro"])]
  public function testPlaceBlockInStaticRegion(string $action, string $expected_theme): void {
    $this->configActionManager->applyAction($action, 'block.block.test_block', [
@@ -172,7 +175,7 @@ public function testPlaceBlockAtPosition(): void {
    // Ensure there's at least one block already in the region.
    $block = Block::create([
      'id' => 'block_1',
      'theme' => 'olivero',
      'theme' => 'stark',
      'region' => 'content_above',
      'weight' => 0,
      'plugin' => 'system_powered_by_block',
@@ -216,15 +219,15 @@ public function testPlaceBlockInEmptyRegion(): void {
      ->getStorage('block')
      ->getQuery()
      ->count()
      ->condition('theme', 'olivero')
      ->condition('region', 'footer_top');
      ->condition('theme', 'stark')
      ->condition('region', 'footer');
    $this->assertSame(0, $query->execute());

    // Place a block in that region.
    $this->configActionManager->applyAction('placeBlockInDefaultTheme', 'block.block.test', [
      'plugin' => 'system_powered_by_block',
      'region' => [
        'olivero' => 'footer_top',
        'stark' => 'footer',
      ],
      'position' => 'first',
    ]);
+1 −1
Changes for core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public function testModuleBreakpoints(): void {
   */
  public function testBreakpointGroups(): void {
    $expected = [
      'olivero' => 'Olivero',
      'stark' => 'Stark',
      'breakpoint_module_test' => 'Breakpoint test module',
      'breakpoint_theme_test' => 'Breakpoint test theme',
      'breakpoint_theme_test.group2' => 'breakpoint_theme_test.group2',
Loading