From 84fcf86150014a002aa1f321c765e54ab157f97b Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Fri, 30 Jul 2021 13:24:37 +0300 Subject: [PATCH] Skip including Gutenberg in summary if there is another plugin --- assets/src/utils/sources/summarize.js | 5 +++ assets/src/utils/sources/test/summarize.js | 38 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/assets/src/utils/sources/summarize.js b/assets/src/utils/sources/summarize.js index 6913da8dbde..b152f9e58f6 100644 --- a/assets/src/utils/sources/summarize.js +++ b/assets/src/utils/sources/summarize.js @@ -58,6 +58,11 @@ export default function summarizeSources( raw ) { if ( sources[ SOURCE_TYPE_PLUGIN ] ) { result[ SOURCE_TYPE_PLUGIN ] = sources[ SOURCE_TYPE_PLUGIN ]; + + // Skip including Gutenberg in the summary if there is another plugin, since Gutenberg is like core. + if ( result[ SOURCE_TYPE_PLUGIN ].length > 1 && result[ SOURCE_TYPE_PLUGIN ].includes( 'gutenberg' ) ) { + result[ SOURCE_TYPE_PLUGIN ] = result[ SOURCE_TYPE_PLUGIN ].filter( ( plugin ) => plugin !== 'gutenberg' ); + } } if ( sources[ SOURCE_TYPE_MU_PLUGIN ] ) { result[ SOURCE_TYPE_MU_PLUGIN ] = sources[ SOURCE_TYPE_MU_PLUGIN ]; diff --git a/assets/src/utils/sources/test/summarize.js b/assets/src/utils/sources/test/summarize.js index a74a365a79a..d856954a541 100644 --- a/assets/src/utils/sources/test/summarize.js +++ b/assets/src/utils/sources/test/summarize.js @@ -166,4 +166,42 @@ describe( 'summarizeSources', () => { [ SOURCE_TYPE_THEME ]: [ 'baz' ], } ); } ); + + it( 'returns Gutenberg if there is no other plugin', () => { + const result = summarizeSources( [ + { + type: 'plugin', + name: 'gutenberg', + }, + { + type: 'theme', + name: 'baz', + }, + ] ); + expect( result ).toStrictEqual( { + [ SOURCE_TYPE_PLUGIN ]: [ 'gutenberg' ], + [ SOURCE_TYPE_THEME ]: [ 'baz' ], + } ); + } ); + + it( 'does not return Gutenberg if there is another plugin', () => { + const result = summarizeSources( [ + { + type: 'plugin', + name: 'foo', + }, + { + type: 'plugin', + name: 'gutenberg', + }, + { + type: 'theme', + name: 'baz', + }, + ] ); + expect( result ).toStrictEqual( { + [ SOURCE_TYPE_PLUGIN ]: [ 'foo' ], + [ SOURCE_TYPE_THEME ]: [ 'baz' ], + } ); + } ); } );