Loading core/misc/cspell/dictionary.txt +1 Changes for core/misc/cspell/dictionary.txt: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -793,6 +793,7 @@ optin optionchecker orgchart ossp otel otlp otsikko outdent Loading core/modules/system/tests/src/FunctionalJavascript/NoJavaScriptAnonymousTest.php +15 −5 Changes for core/modules/system/tests/src/FunctionalJavascript/NoJavaScriptAnonymousTest.php: 15 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\FunctionalJavascript; use Drupal\Tests\PerformanceData; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; use Drupal\node\NodeInterface; Loading Loading @@ -46,30 +47,39 @@ public function testNoJavaScript() { ]); // Test frontpage. $performance_data = $this->collectPerformanceData(function () { $this->drupalGet(''); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); // Test node page. $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); // Test user profile page. $user = $this->drupalCreateUser(); $performance_data = $this->collectPerformanceData(function () use ($user) { $this->drupalGet('user/' . $user->id()); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); } /** * Passes if no JavaScript is found on the page. * * @param Drupal\Tests\PerformanceData $performance_data * A PerformanceData value object. * * @internal */ protected function assertNoJavaScript(): void { protected function assertNoJavaScript(PerformanceData $performance_data): void { // Ensure drupalSettings is not set. $settings = $this->getDrupalSettings(); $this->assertEmpty($settings, 'drupalSettings is not set.'); $this->assertSession()->responseNotMatches('/\.js/'); $this->assertSame(0, $this->scriptCount); $this->assertSame(0, $performance_data->getScriptCount()); } } core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +71 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php: 71 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group OpenTelemetry * @group #slow */ class OpenTelemetryFrontPagePerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Logs front page tracing data with a cold cache. */ public function testFrontPageColdCache() { // @todo: Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // See https://www.drupal.org/project/drupal/issues/3379750 $this->drupalGet('user/login'); $this->rebuildAll(); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageColdCache'); $this->assertSession()->pageTextContains('Umami'); } /** * Logs front page tracing data with a hot cache. * * Hot here means that all possible caches are warmed. */ public function testFrontPageHotCache() { // Request the page twice so that asset aggregates and image derivatives are // definitely cached in the browser cache. The first response builds the // file and serves from PHP with private, no-store headers. The second // request will get the file served directly from disk by the browser with // cacheable headers, so only the third request actually has the files // in the browser cache. $this->drupalGet('<front>'); $this->drupalGet('<front>'); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageWarmCache'); } /** * Logs front page tracing data with a lukewarm cache. * * Cool here means that 'global' site caches are warm but anything * specific to the front page is cold. */ public function testFrontPageCoolCache() { // First of all visit the front page to ensure the image style exists. $this->drupalGet('<front>'); $this->rebuildAll(); // Now visit a different page to warm non-route-specific caches. $this->drupalGet('/user/login'); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageCoolCache'); } } core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +87 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php: 87 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group OpenTelemetry * @group #slow */ class OpenTelemetryNodePagePerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Logs node page tracing data with a cold cache. */ public function testNodePageColdCache() { // @todo: Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // See https://www.drupal.org/project/drupal/issues/3379750 $this->drupalGet('user/login'); $this->rebuildAll(); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageColdCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Logs node page tracing data with a hot cache. * * Hot here means that all possible caches are warmed. */ public function testNodePageHotCache() { // Request the page twice so that asset aggregates are definitely cached in // the browser cache. $this->drupalGet('node/1'); $this->drupalGet('node/1'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageHotCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Logs node/1 tracing data with a cool cache. * * Cool here means that 'global' site caches are warm but anything * specific to the route or path is cold. */ public function testNodePageCoolCache() { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); // Now visit a non-node page to warm non-route-specific caches. $this->drupalGet('/user/login'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageCoolCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Log node/1 tracing data with a warm cache. * * Warm here means that 'global' site caches and route-specific caches are * warm but caches specific to this particular node/path are not. */ public function testNodePageWarmCache() { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); // Now visit a different node page to warm non-path-specific caches. $this->drupalGet('/node/2'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageWarmCache'); $this->assertSession()->pageTextContains('quiche'); } } core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php +16 −6 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php: 16 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ /** * Tests demo_umami profile performance. * * @group performance * @group Performance */ class PerformanceTest extends PerformanceTestBase { Loading @@ -19,11 +19,19 @@ class PerformanceTest extends PerformanceTestBase { /** * Just load the front page. */ public function testFrontPage(): void { public function testPagesAnonymous(): void { $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $this->stylesheetCount); $this->assertSame(1, $this->scriptCount); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); }); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); } /** Loading @@ -32,10 +40,12 @@ public function testFrontPage(): void { public function testFrontPagePerformance(): void { $admin_user = $this->drupalCreateUser(['access toolbar']); $this->drupalLogin($admin_user); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $this->stylesheetCount); $this->assertSame(2, $this->scriptCount); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(2, $performance_data->getScriptCount()); } } Loading
core/misc/cspell/dictionary.txt +1 Changes for core/misc/cspell/dictionary.txt: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -793,6 +793,7 @@ optin optionchecker orgchart ossp otel otlp otsikko outdent Loading
core/modules/system/tests/src/FunctionalJavascript/NoJavaScriptAnonymousTest.php +15 −5 Changes for core/modules/system/tests/src/FunctionalJavascript/NoJavaScriptAnonymousTest.php: 15 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Tests\system\FunctionalJavascript; use Drupal\Tests\PerformanceData; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; use Drupal\node\NodeInterface; Loading Loading @@ -46,30 +47,39 @@ public function testNoJavaScript() { ]); // Test frontpage. $performance_data = $this->collectPerformanceData(function () { $this->drupalGet(''); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); // Test node page. $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); // Test user profile page. $user = $this->drupalCreateUser(); $performance_data = $this->collectPerformanceData(function () use ($user) { $this->drupalGet('user/' . $user->id()); $this->assertNoJavaScript(); }); $this->assertNoJavaScript($performance_data); } /** * Passes if no JavaScript is found on the page. * * @param Drupal\Tests\PerformanceData $performance_data * A PerformanceData value object. * * @internal */ protected function assertNoJavaScript(): void { protected function assertNoJavaScript(PerformanceData $performance_data): void { // Ensure drupalSettings is not set. $settings = $this->getDrupalSettings(); $this->assertEmpty($settings, 'drupalSettings is not set.'); $this->assertSession()->responseNotMatches('/\.js/'); $this->assertSame(0, $this->scriptCount); $this->assertSame(0, $performance_data->getScriptCount()); } }
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php +71 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryFrontPagePerformanceTest.php: 71 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group OpenTelemetry * @group #slow */ class OpenTelemetryFrontPagePerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Logs front page tracing data with a cold cache. */ public function testFrontPageColdCache() { // @todo: Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // See https://www.drupal.org/project/drupal/issues/3379750 $this->drupalGet('user/login'); $this->rebuildAll(); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageColdCache'); $this->assertSession()->pageTextContains('Umami'); } /** * Logs front page tracing data with a hot cache. * * Hot here means that all possible caches are warmed. */ public function testFrontPageHotCache() { // Request the page twice so that asset aggregates and image derivatives are // definitely cached in the browser cache. The first response builds the // file and serves from PHP with private, no-store headers. The second // request will get the file served directly from disk by the browser with // cacheable headers, so only the third request actually has the files // in the browser cache. $this->drupalGet('<front>'); $this->drupalGet('<front>'); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageWarmCache'); } /** * Logs front page tracing data with a lukewarm cache. * * Cool here means that 'global' site caches are warm but anything * specific to the front page is cold. */ public function testFrontPageCoolCache() { // First of all visit the front page to ensure the image style exists. $this->drupalGet('<front>'); $this->rebuildAll(); // Now visit a different page to warm non-route-specific caches. $this->drupalGet('/user/login'); $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }, 'umamiFrontPageCoolCache'); } }
core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php +87 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php: 87 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Drupal\Tests\demo_umami\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\PerformanceTestBase; /** * Tests demo_umami profile performance. * * @group OpenTelemetry * @group #slow */ class OpenTelemetryNodePagePerformanceTest extends PerformanceTestBase { /** * {@inheritdoc} */ protected $profile = 'demo_umami'; /** * Logs node page tracing data with a cold cache. */ public function testNodePageColdCache() { // @todo: Chromedriver doesn't collect tracing performance logs for the very // first request in a test, so warm it up. // See https://www.drupal.org/project/drupal/issues/3379750 $this->drupalGet('user/login'); $this->rebuildAll(); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageColdCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Logs node page tracing data with a hot cache. * * Hot here means that all possible caches are warmed. */ public function testNodePageHotCache() { // Request the page twice so that asset aggregates are definitely cached in // the browser cache. $this->drupalGet('node/1'); $this->drupalGet('node/1'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageHotCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Logs node/1 tracing data with a cool cache. * * Cool here means that 'global' site caches are warm but anything * specific to the route or path is cold. */ public function testNodePageCoolCache() { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); // Now visit a non-node page to warm non-route-specific caches. $this->drupalGet('/user/login'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageCoolCache'); $this->assertSession()->pageTextContains('quiche'); } /** * Log node/1 tracing data with a warm cache. * * Warm here means that 'global' site caches and route-specific caches are * warm but caches specific to this particular node/path are not. */ public function testNodePageWarmCache() { // First of all visit the node page to ensure the image style exists. $this->drupalGet('node/1'); $this->rebuildAll(); // Now visit a different node page to warm non-path-specific caches. $this->drupalGet('/node/2'); $this->collectPerformanceData(function () { $this->drupalGet('/node/1'); }, 'umamiNodePageWarmCache'); $this->assertSession()->pageTextContains('quiche'); } }
core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php +16 −6 Changes for core/profiles/demo_umami/tests/src/FunctionalJavascript/PerformanceTest.php: 16 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ /** * Tests demo_umami profile performance. * * @group performance * @group Performance */ class PerformanceTest extends PerformanceTestBase { Loading @@ -19,11 +19,19 @@ class PerformanceTest extends PerformanceTestBase { /** * Just load the front page. */ public function testFrontPage(): void { public function testPagesAnonymous(): void { $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $this->stylesheetCount); $this->assertSame(1, $this->scriptCount); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('node/1'); }); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(1, $performance_data->getScriptCount()); } /** Loading @@ -32,10 +40,12 @@ public function testFrontPage(): void { public function testFrontPagePerformance(): void { $admin_user = $this->drupalCreateUser(['access toolbar']); $this->drupalLogin($admin_user); $performance_data = $this->collectPerformanceData(function () { $this->drupalGet('<front>'); }); $this->assertSession()->pageTextContains('Umami'); $this->assertSame(2, $this->stylesheetCount); $this->assertSame(2, $this->scriptCount); $this->assertSame(2, $performance_data->getStylesheetCount()); $this->assertSame(2, $performance_data->getScriptCount()); } }