Randomize the sections in the recommended marketing extensions (#33851)
This commit is contained in:
parent
9d6bf48964
commit
4ab95678ab
|
@ -54,7 +54,11 @@ export const getMarketingExtensionLists = (
|
|||
): [ PluginProps[], PluginListProps[] ] => {
|
||||
const installed: PluginProps[] = [];
|
||||
const lists: PluginListProps[] = [];
|
||||
freeExtensions.forEach( ( list ) => {
|
||||
const freeExtensionsRandomized: ExtensionList[] = freeExtensions.sort(
|
||||
() => Math.random() - 0.5
|
||||
); // Randomize the order sections appear.
|
||||
|
||||
freeExtensionsRandomized.forEach( ( list ) => {
|
||||
if ( ! ALLOWED_PLUGIN_LISTS.includes( list.key ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -133,6 +137,9 @@ const Marketing: React.FC< MarketingProps > = ( { onComplete } ) => {
|
|||
installed_extensions: installedExtensions.map(
|
||||
( extension ) => extension.slug
|
||||
),
|
||||
section_order: pluginLists
|
||||
.map( ( list ) => list.key )
|
||||
.join( ', ' ),
|
||||
} );
|
||||
|
||||
createNoticesFromResponse( response );
|
||||
|
|
|
@ -117,10 +117,11 @@ describe( 'getMarketingExtensionLists', () => {
|
|||
[],
|
||||
[]
|
||||
);
|
||||
const listKeys = lists.map( ( list ) => list.key );
|
||||
|
||||
expect( lists.length ).toBe( 2 );
|
||||
expect( lists[ 0 ].key ).toBe( 'task-list/reach' );
|
||||
expect( lists[ 1 ].key ).toBe( 'task-list/grow' );
|
||||
expect( listKeys ).toContain( 'task-list/reach' );
|
||||
expect( listKeys ).toContain( 'task-list/grow' );
|
||||
} );
|
||||
|
||||
test( 'should separate installed plugins', () => {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Randomize the order of sections in Recommended Marketing Extensions
|
Loading…
Reference in New Issue