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( {
|
|
|
|
countUnreadOrders: 0,
|
|
|
|
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( {
|
|
|
|
countUnreadOrders: 0,
|
|
|
|
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( {
|
|
|
|
countUnreadOrders: 0,
|
|
|
|
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',
|
|
|
|
isTaskListHidden: 'no',
|
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( {
|
|
|
|
countUnreadOrders: 1,
|
|
|
|
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( {
|
|
|
|
countUnreadOrders: 1,
|
|
|
|
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' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should include the reviews panel when there are products and reviews are enabled', () => {
|
|
|
|
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
|
|
|
} );
|
|
|
|
|
|
|
|
expect( panels ).toEqual(
|
|
|
|
expect.arrayContaining( [
|
|
|
|
expect.objectContaining( { id: 'reviews-panel' } ),
|
|
|
|
] )
|
|
|
|
);
|
|
|
|
} );
|
2020-11-23 15:06:55 +00:00
|
|
|
} );
|