2020-11-23 15:06:55 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { getAllPanels } from '../panels';
|
|
|
|
|
|
|
|
describe( 'ActivityPanel', () => {
|
2020-12-29 16:19:13 +00:00
|
|
|
it( 'should exclude the orders and stock panels when there are no orders', () => {
|
2020-11-23 15:06:55 +00:00
|
|
|
const panels = getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
unreadOrdersCount: 0,
|
2020-11-23 15:06:55 +00:00
|
|
|
orderStatuses: [],
|
|
|
|
totalOrderCount: 0,
|
2020-12-29 16:19:13 +00:00
|
|
|
publishedProductCount: 1,
|
|
|
|
manageStock: 'yes',
|
2021-01-29 14:23:02 +00:00
|
|
|
isTaskListHidden: 'yes',
|
2020-11-23 15:06:55 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'orders-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
2020-12-29 16:19:13 +00:00
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'stock-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should exclude the reviews and stock panels when there are no published products', () => {
|
|
|
|
const panels = getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
unreadOrdersCount: 0,
|
2020-12-29 16:19:13 +00:00
|
|
|
orderStatuses: [],
|
|
|
|
totalOrderCount: 1, // Yes, I realize this isn't "possible".
|
|
|
|
publishedProductCount: 0,
|
|
|
|
manageStock: 'yes',
|
|
|
|
reviewsEnabled: 'yes',
|
2021-01-27 21:40:27 +00:00
|
|
|
isTaskListHidden: 'yes',
|
|
|
|
} );
|
|
|
|
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'reviews-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'stock-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2021-01-29 14:23:02 +00:00
|
|
|
it( 'should exclude any panel when the setup task list is visible', () => {
|
2021-01-27 21:40:27 +00:00
|
|
|
const panels = getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
unreadOrdersCount: 0,
|
2021-01-27 21:40:27 +00:00
|
|
|
orderStatuses: [],
|
2021-01-29 14:23:02 +00:00
|
|
|
totalOrderCount: 1,
|
2021-01-27 21:40:27 +00:00
|
|
|
publishedProductCount: 0,
|
|
|
|
manageStock: 'yes',
|
|
|
|
reviewsEnabled: 'yes',
|
2021-10-04 17:02:01 +00:00
|
|
|
isTaskListHidden: false,
|
2020-12-29 16:19:13 +00:00
|
|
|
} );
|
|
|
|
|
2021-01-29 14:23:02 +00:00
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'orders-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
2020-12-29 16:19:13 +00:00
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'reviews-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'stock-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
2020-11-23 15:06:55 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should include the orders panel when there are orders', () => {
|
|
|
|
const panels = getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
unreadOrdersCount: 1,
|
2020-11-23 15:06:55 +00:00
|
|
|
orderStatuses: [],
|
|
|
|
totalOrderCount: 10,
|
2021-01-29 14:23:02 +00:00
|
|
|
isTaskListHidden: 'yes',
|
2020-11-23 15:06:55 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'orders-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
2020-12-29 16:19:13 +00:00
|
|
|
|
|
|
|
it( 'should include the stock panel when there are orders, products, and inventory management is enabled', () => {
|
|
|
|
const panels = getAllPanels( {
|
2022-01-19 16:45:17 +00:00
|
|
|
unreadOrdersCount: 1,
|
2020-12-29 16:19:13 +00:00
|
|
|
orderStatuses: [],
|
|
|
|
totalOrderCount: 10,
|
|
|
|
publishedProductCount: 2,
|
|
|
|
manageStock: 'yes',
|
2021-01-27 21:40:27 +00:00
|
|
|
isTaskListHidden: 'yes',
|
2020-12-29 16:19:13 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'stock-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
2022-01-19 16:45:17 +00:00
|
|
|
it( 'should exclude the reviews panel when there are no reviews', () => {
|
2020-12-29 16:19:13 +00:00
|
|
|
const panels = getAllPanels( {
|
|
|
|
publishedProductCount: 5,
|
|
|
|
reviewsEnabled: 'yes',
|
2021-01-27 21:40:27 +00:00
|
|
|
isTaskListHidden: 'yes',
|
2020-12-29 16:19:13 +00:00
|
|
|
} );
|
|
|
|
|
2022-01-19 16:45:17 +00:00
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.not.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'reviews-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should include the reviews panel when they are enabled, there are products and reviews', () => {
|
|
|
|
const panels = getAllPanels( {
|
|
|
|
publishedProductCount: 5,
|
|
|
|
reviewsEnabled: 'yes',
|
|
|
|
isTaskListHidden: 'yes',
|
|
|
|
unapprovedReviewsCount: 3,
|
|
|
|
} );
|
|
|
|
|
2020-12-29 16:19:13 +00:00
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'reviews-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
2020-11-23 15:06:55 +00:00
|
|
|
} );
|