2020-07-14 12:20:51 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { ActivityPanel } from '../';
|
|
|
|
|
|
|
|
describe( 'Activity Panel', () => {
|
|
|
|
it( 'should render inbox tab on embedded pages', () => {
|
2020-07-28 02:32:58 +00:00
|
|
|
render( <ActivityPanel isEmbedded query={ {} } /> );
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
expect( screen.getByText( 'Inbox' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should render inbox tab if not on home screen', () => {
|
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
getHistory={ () => ( {
|
|
|
|
location: {
|
|
|
|
pathname: '/customers',
|
|
|
|
},
|
|
|
|
} ) }
|
|
|
|
query={ {} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( screen.getByText( 'Inbox' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not render inbox tab on home screen', () => {
|
2020-07-28 02:32:58 +00:00
|
|
|
render( <ActivityPanel query={ {} } /> );
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
expect( screen.queryByText( 'Inbox' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
it( 'should render help tab before options load', async () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const tabs = await screen.findAllByRole( 'tab' );
|
|
|
|
|
|
|
|
// Expect that the only tab is "Help".
|
|
|
|
expect( tabs ).toHaveLength( 1 );
|
|
|
|
expect( screen.getByText( 'Help' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
it( 'should render help tab when on single task', async () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete={ false }
|
|
|
|
taskListHidden={ false }
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const tabs = await screen.findAllByRole( 'tab' );
|
|
|
|
|
|
|
|
// Expect that the only tab is "Help".
|
|
|
|
expect( tabs ).toHaveLength( 1 );
|
|
|
|
expect( screen.getByText( 'Help' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
it( 'should not render help tab when not on main route', () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete={ false }
|
|
|
|
taskListHidden={ false }
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
path: '/customers',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
// Expect that "Help" tab is absent.
|
|
|
|
expect( screen.queryByText( 'Help' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
it( 'should not render help tab when TaskList is hidden', () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete={ false }
|
|
|
|
taskListHidden
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
// Expect that "Help" tab is absent.
|
|
|
|
expect( screen.queryByText( 'Help' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
2020-07-28 02:32:58 +00:00
|
|
|
it( 'should not render help tab when TaskList is complete', () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete
|
|
|
|
taskListHidden={ false }
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
// Expect that "Help" tab is absent.
|
|
|
|
expect( screen.queryByText( 'Help' ) ).toBeNull();
|
|
|
|
} );
|
2020-09-24 21:23:27 +00:00
|
|
|
|
|
|
|
it( 'should only render the store setup link when TaskList is not complete', () => {
|
|
|
|
const { queryByText, rerender } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete={ false }
|
|
|
|
taskListHidden={ false }
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( queryByText( 'Store Setup' ) ).toBeDefined();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<ActivityPanel
|
|
|
|
requestingTaskListOptions={ false }
|
|
|
|
taskListComplete
|
|
|
|
taskListHidden={ false }
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( queryByText( 'Store Setup' ) ).toBeNull();
|
|
|
|
} );
|
2020-07-14 12:20:51 +00:00
|
|
|
} );
|