Skip to content

Commit

Permalink
Address CR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitrox committed Jan 10, 2025
1 parent bc1e5ac commit f7d5254
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 55 deletions.
12 changes: 2 additions & 10 deletions includes/Modules/Reader_Revenue_Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,10 @@ protected function setup_assets() {

if ( Feature_Flags::enabled( 'rrmModuleV2' ) ) {
$assets[] = new Script(
'googlesitekit-reader-revenue-manager-block-editor.js',
'googlesitekit-reader-revenue-manager-block-editor',
array(
'src' => $base_url . 'js/googlesitekit-reader-revenue-manager-block-editor.js',
'dependencies' => array(
'googlesitekit-data',
'googlesitekit-i18n',
'googlesitekit-modules',
'wp-components',
'wp-editor',
'wp-element',
'wp-plugins',
),
'dependencies' => array(),
'load_contexts' => array( Asset::CONTEXT_ADMIN_POST_EDITOR ),
)
);
Expand Down
52 changes: 18 additions & 34 deletions tests/phpunit/integration/Modules/Reader_Revenue_ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Google\Site_Kit\Core\REST_API\Exception\Missing_Required_Param_Exception;
use Google\Site_Kit\Core\Storage\Options;
use Google\Site_Kit\Core\Storage\User_Options;
use Google\Site_Kit\Core\Util\Feature_Flags;
use Google\Site_Kit\Core\Util\URL;
use Google\Site_Kit\Modules\Reader_Revenue_Manager;
use Google\Site_Kit\Modules\Reader_Revenue_Manager\Settings;
Expand Down Expand Up @@ -488,47 +487,32 @@ public function test_check_service_entity_access_no_access_unavailable_publicati
}

public function test_block_editor_script_enqueued() {
Feature_Flags::set_features(
array(
'rrmModuleV2',
)
);
add_filter(
'googlesitekit_is_feature_enabled',
function ( $enabled, $feature_name ) {
return 'rrmModuleV2' === $feature_name;
$this->enable_feature( 'rrmModuleV2' );

$registerable_asset_handles = array_map(
function ( $asset ) {
return $asset->get_handle();
},
10,
2
$this->reader_revenue_manager->get_assets()
);

$registerable_scripts_with_feature = $this->reader_revenue_manager->get_assets();

$this->assertIsArray( $registerable_scripts_with_feature );

$rrm_block_editor_script = array_filter(
$registerable_scripts_with_feature,
function ( $script ) {
return 'googlesitekit-reader-revenue-manager-block-editor.js' === $script->get_handle();
}
$this->assertContains(
'googlesitekit-reader-revenue-manager-block-editor',
$registerable_asset_handles
);

$this->assertNotEmpty( $rrm_block_editor_script );
}

public function test_block_editor_script_not_enqueued() {
$registerable_scripts_without_feature = $this->reader_revenue_manager->get_assets();

$this->assertIsArray( $registerable_scripts_without_feature );

$rrm_block_editor_script = array_filter(
$registerable_scripts_without_feature,
function ( $script ) {
return 'googlesitekit-reader-revenue-manager-block-editor.js' === $script->get_handle();
}
$registerable_asset_handles = array_map(
function ( $asset ) {
return $asset->get_handle();
},
$this->reader_revenue_manager->get_assets()
);

$this->assertEmpty( $rrm_block_editor_script );
$this->assertNotContains(
'googlesitekit-reader-revenue-manager-block-editor',
$registerable_asset_handles
);
}

/**
Expand Down
8 changes: 0 additions & 8 deletions webpack/blockEditor.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ module.exports = ( mode ) => ( {
mode === 'production' ? '[name]-[contenthash].js' : '[name].js',
path: rootDir + '/dist/assets/js',
publicPath: '',
// If multiple webpack runtimes (from different compilations) are used on the
// same webpage, there is a risk of conflicts of on-demand chunks in the global
// namespace.
// See: https://webpack.js.org/configuration/output/#outputjsonpfunction.
jsonpFunction: '__googlesitekit_block_editor_webpackJsonp',
},
performance: {
maxEntrypointSize: 175000,
},
module: {
rules: createRules( mode ),
Expand Down
4 changes: 2 additions & 2 deletions webpack/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ const gutenbergExternals = {
'@wordpress/i18n': [ 'googlesitekit', 'i18n' ],
};

exports.gutenbergExternals = gutenbergExternals;

corePackages.forEach( ( name ) => {
gutenbergExternals[ `@wordpress-core/${ name }` ] = [
'wp',
name.replace( /-([a-z])/g, ( match, letter ) => letter.toUpperCase() ),
];
} );

exports.gutenbergExternals = gutenbergExternals;
2 changes: 1 addition & 1 deletion webpack/modules.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = ( mode, rules, ANALYZE ) => {
// If multiple webpack runtimes (from different compilations) are used on the
// same webpage, there is a risk of conflicts of on-demand chunks in the global
// namespace.
// See: https://webpack.js.org/configuration/output/#outputjsonpfunction.
// See: https://v4.webpack.js.org/configuration/output/#outputjsonpfunction.
jsonpFunction: '__googlesitekit_webpackJsonp',
},
performance: {
Expand Down

0 comments on commit f7d5254

Please sign in to comment.