This commit fixes the home screen panels check

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
This commit is contained in:
Fernando 2021-01-29 11:23:02 -03:00 committed by GitHub
parent bc1f0699c2
commit 1f368b73f8
2 changed files with 13 additions and 4 deletions

View File

@ -21,6 +21,10 @@ export function getAllPanels( {
reviewsEnabled,
totalOrderCount,
} ) {
if ( isTaskListHidden !== 'yes' ) {
return [];
}
return [
totalOrderCount > 0 && {
className: 'woocommerce-homescreen-card',
@ -38,7 +42,6 @@ export function getAllPanels( {
},
totalOrderCount > 0 &&
publishedProductCount > 0 &&
isTaskListHidden === 'yes' &&
manageStock === 'yes' && {
className: 'woocommerce-homescreen-card',
count: countLowStockProducts,
@ -53,7 +56,6 @@ export function getAllPanels( {
title: __( 'Stock', 'woocommerce-admin' ),
},
publishedProductCount > 0 &&
isTaskListHidden === 'yes' &&
reviewsEnabled === 'yes' && {
className: 'woocommerce-homescreen-card',
id: 'reviews-panel',

View File

@ -11,6 +11,7 @@ describe( 'ActivityPanel', () => {
totalOrderCount: 0,
publishedProductCount: 1,
manageStock: 'yes',
isTaskListHidden: 'yes',
} );
expect( panels ).toEqual(
@ -48,17 +49,22 @@ describe( 'ActivityPanel', () => {
);
} );
it( 'should exclude the reviews and stock panels when the setup task list is visible', () => {
it( 'should exclude any panel when the setup task list is visible', () => {
const panels = getAllPanels( {
countUnreadOrders: 0,
orderStatuses: [],
totalOrderCount: 1, // Yes, I realize this isn't "possible".
totalOrderCount: 1,
publishedProductCount: 0,
manageStock: 'yes',
reviewsEnabled: 'yes',
isTaskListHidden: 'no',
} );
expect( panels ).toEqual(
expect.not.arrayContaining( [
expect.objectContaining( { id: 'orders-panel' } ),
] )
);
expect( panels ).toEqual(
expect.not.arrayContaining( [
expect.objectContaining( { id: 'reviews-panel' } ),
@ -76,6 +82,7 @@ describe( 'ActivityPanel', () => {
countUnreadOrders: 1,
orderStatuses: [],
totalOrderCount: 10,
isTaskListHidden: 'yes',
} );
expect( panels ).toEqual(