Skip to content
Snippets Groups Projects
Verified Commit 5a89db6f authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3444152 by m4olivei, smustgrave: Add test coverage to ensure navigation...

Issue #3444152 by m4olivei, smustgrave: Add test coverage to ensure navigation isn't rendered for users that don't have access
parent b3c0ee60
No related branches found
No related tags found
14 merge requests!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11281Use Drupal Core Leadership terminology in MAINTAINERS.txt,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator
Pipeline #384953 canceled
Pipeline: drupal

#384954

    <?php
    declare(strict_types=1);
    namespace Drupal\Tests\navigation\FunctionalJavascript;
    use Drupal\Core\Cache\Cache;
    use Drupal\FunctionalJavascriptTests\PerformanceTestBase;
    /**
    * Tests the performance impacts of navigation module.
    *
    * Stark is used as the default theme so that this test is not Olivero specific.
    *
    * @group navigation
    */
    class TopBarPerformanceTest extends PerformanceTestBase {
    /**
    * {@inheritdoc}
    */
    protected static $modules = [
    'navigation',
    ];
    /**
    * {@inheritdoc}
    */
    protected $defaultTheme = 'stark';
    /**
    * {@inheritdoc}
    */
    protected $profile = 'testing';
    /**
    * Tests performance for anonymous users is not affected by the Top Bar.
    */
    public function testTopBarPerformance(): void {
    // Request the front page, then immediately clear all object caches, so that
    // aggregates and image styles are created on disk but otherwise caches are
    // empty.
    $this->drupalGet('');
    // Give time for big pipe placeholders, asset aggregate requests, and post
    // response tasks to finish processing and write to any caches before
    // clearing caches again.
    sleep(2);
    foreach (Cache::getBins() as $bin) {
    $bin->deleteAll();
    }
    // Gather performance data before enabling navigation_top_bar.
    $performance_data_before_top_bar = $this->collectPerformanceData(function () {
    $this->drupalGet('');
    }, 'navigationFrontPageTopBarDisabled');
    // Install navigation_top_bar module.
    \Drupal::service('module_installer')->install(['navigation_top_bar']);
    // Clear caches to prep for another performance data collect.
    foreach (Cache::getBins() as $bin) {
    $bin->deleteAll();
    }
    // Gather performance data after enabling navigation_top_bar.
    $performance_data_after_top_bar = $this->collectPerformanceData(function () {
    $this->drupalGet('');
    }, 'navigationFrontPageTopBarEnabled');
    // Ensure that there is no change to performance metrics from the Top Bar.
    // Anonymous users should never see the Top Bar.
    $this->assertSame($performance_data_before_top_bar->getQueryCount(), $performance_data_after_top_bar->getQueryCount());
    $this->assertSame($performance_data_before_top_bar->getCacheGetCount(), $performance_data_after_top_bar->getCacheGetCount());
    $this->assertSame($performance_data_before_top_bar->getCacheSetCount(), $performance_data_after_top_bar->getCacheSetCount());
    $this->assertSame($performance_data_before_top_bar->getCacheDeleteCount(), $performance_data_after_top_bar->getCacheDeleteCount());
    $this->assertSame($performance_data_before_top_bar->getCacheTagChecksumCount(), $performance_data_after_top_bar->getCacheTagChecksumCount());
    $this->assertSame($performance_data_before_top_bar->getCacheTagIsValidCount(), $performance_data_after_top_bar->getCacheTagIsValidCount());
    $this->assertSame($performance_data_before_top_bar->getCacheTagInvalidationCount(), $performance_data_after_top_bar->getCacheTagInvalidationCount());
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment