mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-09-23 10:21:40 +00:00
Merge "Restore test and increase budget with debug information"
This commit is contained in:
commit
e4581e03e6
|
@ -2,11 +2,11 @@
|
||||||
"total": {
|
"total": {
|
||||||
"vector-2022": {
|
"vector-2022": {
|
||||||
"scripts": "70.1KB",
|
"scripts": "70.1KB",
|
||||||
"styles": "15KB"
|
"styles": "17.0KB"
|
||||||
},
|
},
|
||||||
"vector": {
|
"vector": {
|
||||||
"scripts": "57.3KB",
|
"scripts": "70.1KB",
|
||||||
"styles": "8.6KB"
|
"styles": "17.0KB"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modules": [
|
"modules": [
|
||||||
|
|
|
@ -78,6 +78,11 @@ class PerformanceBudgetTest extends MediaWikiIntegrationTestCase {
|
||||||
* @throws \SkinException
|
* @throws \SkinException
|
||||||
*/
|
*/
|
||||||
protected function prepareSkin( string $skinName ): \Skin {
|
protected function prepareSkin( string $skinName ): \Skin {
|
||||||
|
// FIXME: disable flagged revisions for purpose of this test by making
|
||||||
|
// sure the page is not "reviewable" until T350514 is resolved.
|
||||||
|
$this->overrideConfigValue( 'FlaggedRevsNamespaces', [] );
|
||||||
|
// END FIXME
|
||||||
|
|
||||||
$skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
|
$skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
|
||||||
$skin = $skinFactory->makeSkin( $skinName );
|
$skin = $skinFactory->makeSkin( $skinName );
|
||||||
$title = $this->getExistingTestPage()->getTitle();
|
$title = $this->getExistingTestPage()->getTitle();
|
||||||
|
@ -143,34 +148,36 @@ class PerformanceBudgetTest extends MediaWikiIntegrationTestCase {
|
||||||
* @throws MediaWiki\Config\ConfigException
|
* @throws MediaWiki\Config\ConfigException
|
||||||
*/
|
*/
|
||||||
public function testTotalModulesSize( $skinName, $maxSizes ) {
|
public function testTotalModulesSize( $skinName, $maxSizes ) {
|
||||||
$this->markTestSkipped( 'T350338' );
|
|
||||||
|
|
||||||
$skin = $this->prepareSkin( $skinName );
|
$skin = $this->prepareSkin( $skinName );
|
||||||
$moduleStyles = $skin->getOutput()->getModuleStyles();
|
$moduleStyles = $skin->getOutput()->getModuleStyles();
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach ( $moduleStyles as $moduleName ) {
|
foreach ( $moduleStyles as $moduleName ) {
|
||||||
$size += $this->getContentTransferSize( $moduleName, $skinName );
|
$size += $this->getContentTransferSize( $moduleName, $skinName );
|
||||||
}
|
}
|
||||||
|
$debugInformation = "The following modules are enabled on page load:\n" .
|
||||||
|
implode( "\n", $moduleStyles );
|
||||||
$stylesMaxSize = $this->getSizeInBytes( $maxSizes[ 'styles' ] );
|
$stylesMaxSize = $this->getSizeInBytes( $maxSizes[ 'styles' ] );
|
||||||
$message = "T346813: Performance budget for style in skin" .
|
$message = "T346813: Performance budget for style in skin" .
|
||||||
" $skinName on main article namespace has been exceeded." .
|
" $skinName on main article namespace has been exceeded." .
|
||||||
" Total size of style modules is $size bytes is greater" .
|
" Total size of style modules is $size bytes is greater" .
|
||||||
" than the current budget size of $stylesMaxSize bytes" .
|
" than the current budget size of $stylesMaxSize bytes" .
|
||||||
" Please reduce styles that you are loading on page load" .
|
" Please reduce styles that you are loading on page load" .
|
||||||
" or talk to the skin maintainer about modifying the budget.";
|
" or talk to the skin maintainer about modifying the budget. $debugInformation";
|
||||||
$this->assertLessThanOrEqual( $stylesMaxSize, $size, $message );
|
$this->assertLessThanOrEqual( $stylesMaxSize, $size, $message );
|
||||||
$modulesScripts = $skin->getOutput()->getModules();
|
$modulesScripts = $skin->getOutput()->getModules();
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach ( $modulesScripts as $moduleName ) {
|
foreach ( $modulesScripts as $moduleName ) {
|
||||||
$size += $this->getContentTransferSize( $moduleName, $skinName );
|
$size += $this->getContentTransferSize( $moduleName, $skinName );
|
||||||
}
|
}
|
||||||
|
$debugInformation = "The following modules are enabled on page load:\n" .
|
||||||
|
implode( "\n", $modulesScripts );
|
||||||
$scriptsMaxSize = $this->getSizeInBytes( $maxSizes[ 'scripts' ] );
|
$scriptsMaxSize = $this->getSizeInBytes( $maxSizes[ 'scripts' ] );
|
||||||
$message = "T346813: Performance budget for scripts in skin" .
|
$message = "T346813: Performance budget for scripts in skin" .
|
||||||
" $skinName on main article namespace has been exceeded." .
|
" $skinName on main article namespace has been exceeded." .
|
||||||
" Total size of script modules is $size bytes is greater" .
|
" Total size of script modules is $size bytes is greater" .
|
||||||
" than the current budget size of $scriptsMaxSize bytes" .
|
" than the current budget size of $scriptsMaxSize bytes" .
|
||||||
" Please reduce scripts that you are loading on page load" .
|
" Please reduce scripts that you are loading on page load" .
|
||||||
" or talk to the skin maintainer about modifying the budget.";
|
" or talk to the skin maintainer about modifying the budget. $debugInformation";
|
||||||
$this->assertLessThanOrEqual( $scriptsMaxSize, $size, $message );
|
$this->assertLessThanOrEqual( $scriptsMaxSize, $size, $message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue