2020-07-14 12:20:51 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2021-02-25 12:56:00 +00:00
|
|
|
import {
|
|
|
|
render,
|
|
|
|
screen,
|
|
|
|
fireEvent,
|
|
|
|
act,
|
|
|
|
createEvent,
|
|
|
|
} from '@testing-library/react';
|
2021-02-19 13:57:17 +00:00
|
|
|
import { useSelect } from '@wordpress/data';
|
2021-12-14 16:56:42 +00:00
|
|
|
import { useUser, useUserPreferences } from '@woocommerce/data';
|
2021-02-25 12:56:00 +00:00
|
|
|
import { useState } from '@wordpress/element';
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-12-14 16:56:42 +00:00
|
|
|
import { ActivityPanel } from '../activity-panel';
|
2021-02-25 12:56:00 +00:00
|
|
|
import { Panel } from '../panel';
|
2020-07-14 12:20:51 +00:00
|
|
|
|
2023-04-25 22:17:33 +00:00
|
|
|
jest.mock( '@woocommerce/admin-layout', () => {
|
|
|
|
const mockContext = {
|
|
|
|
layoutPath: [ 'home' ],
|
|
|
|
layoutString: 'home',
|
|
|
|
extendLayout: () => {},
|
|
|
|
isDescendantOf: () => false,
|
|
|
|
};
|
|
|
|
return {
|
|
|
|
...jest.requireActual( '@woocommerce/admin-layout' ),
|
|
|
|
useLayoutContext: jest.fn().mockReturnValue( mockContext ),
|
|
|
|
useExtendLayout: jest.fn().mockReturnValue( mockContext ),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
2020-10-22 22:13:14 +00:00
|
|
|
jest.mock( '@woocommerce/data', () => ( {
|
|
|
|
...jest.requireActual( '@woocommerce/data' ),
|
2021-02-19 13:57:17 +00:00
|
|
|
useUser: jest.fn().mockReturnValue( { currentUserCan: () => true } ),
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences: jest.fn().mockReturnValue( {
|
|
|
|
updateUserPreferences: () => {},
|
|
|
|
} ),
|
2020-10-22 22:13:14 +00:00
|
|
|
} ) );
|
|
|
|
|
2020-11-06 17:53:03 +00:00
|
|
|
// We aren't testing the <DisplayOptions /> component here.
|
|
|
|
jest.mock( '../display-options', () => ( {
|
|
|
|
DisplayOptions: jest.fn().mockReturnValue( '[DisplayOptions]' ),
|
|
|
|
} ) );
|
|
|
|
|
2020-12-18 13:17:07 +00:00
|
|
|
jest.mock( '../highlight-tooltip', () => ( {
|
|
|
|
HighlightTooltip: jest.fn().mockReturnValue( '[HighlightTooltip]' ),
|
|
|
|
} ) );
|
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
jest.mock( '@wordpress/data', () => {
|
|
|
|
// Require the original module to not be mocked...
|
|
|
|
const originalModule = jest.requireActual( '@wordpress/data' );
|
|
|
|
|
|
|
|
return {
|
|
|
|
__esModule: true, // Use it when dealing with esModules
|
|
|
|
...originalModule,
|
|
|
|
useSelect: jest.fn().mockReturnValue( {} ),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
2021-02-25 12:56:00 +00:00
|
|
|
jest.mock( '../panel', () => {
|
|
|
|
const originalModule = jest.requireActual( '../panel' );
|
|
|
|
return {
|
|
|
|
__esModule: true,
|
|
|
|
...originalModule,
|
|
|
|
Panel: jest.fn(),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
2020-07-14 12:20:51 +00:00
|
|
|
describe( 'Activity Panel', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
beforeEach( () => {
|
|
|
|
useSelect.mockImplementation( () => ( {
|
2021-06-09 13:56:45 +00:00
|
|
|
hasUnreadNotifications: false,
|
2021-02-19 13:57:17 +00:00
|
|
|
requestingTaskListOptions: false,
|
|
|
|
setupTaskListComplete: false,
|
|
|
|
setupTaskListHidden: false,
|
|
|
|
trackedCompletedTasks: [],
|
|
|
|
} ) );
|
2021-02-25 12:56:00 +00:00
|
|
|
Panel.mockImplementation( jest.requireActual( '../panel' ).Panel );
|
2021-10-14 14:04:17 +00:00
|
|
|
useUser.mockImplementation( () => ( {
|
|
|
|
currentUserCan: () => true,
|
|
|
|
} ) );
|
2021-02-19 13:57:17 +00:00
|
|
|
} );
|
|
|
|
|
2020-07-14 12:20:51 +00:00
|
|
|
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
|
|
|
|
2021-11-17 05:56:25 +00:00
|
|
|
expect( screen.getByText( 'Activity' ) ).toBeDefined();
|
2020-07-14 12:20:51 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should render inbox tab if not on home screen', () => {
|
|
|
|
render(
|
2021-02-19 13:57:17 +00:00
|
|
|
<ActivityPanel query={ { page: 'wc-admin', path: '/customers' } } />
|
2020-07-14 12:20:51 +00:00
|
|
|
);
|
|
|
|
|
2021-11-17 05:56:25 +00:00
|
|
|
expect( screen.getByText( 'Activity' ) ).toBeDefined();
|
2020-07-14 12:20:51 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not render inbox tab on home screen', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
render( <ActivityPanel query={ { page: 'wc-admin' } } /> );
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
expect( screen.queryByText( 'Inbox' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
2022-04-22 13:53:46 +00:00
|
|
|
it( 'should render preview store tab on home screen', () => {
|
2022-04-22 13:09:32 +00:00
|
|
|
render( <ActivityPanel query={ { page: 'wc-admin' } } /> );
|
|
|
|
|
|
|
|
expect( screen.getByText( 'Preview store' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
2020-11-10 13:36:04 +00:00
|
|
|
it( 'should not render help tab if not on home screen', () => {
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
2021-02-19 13:57:17 +00:00
|
|
|
<ActivityPanel query={ { page: 'wc-admin', path: '/customers' } } />
|
2020-07-14 12:20:51 +00:00
|
|
|
);
|
|
|
|
|
2020-11-10 13:36:04 +00:00
|
|
|
expect( screen.queryByText( 'Help' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should render help tab if on home screen', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
render( <ActivityPanel query={ { page: 'wc-admin' } } /> );
|
2020-07-14 12:20:51 +00:00
|
|
|
|
|
|
|
expect( screen.getByText( 'Help' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
2020-11-10 13:36:04 +00:00
|
|
|
it( 'should render help tab before options load', async () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
useSelect.mockImplementation( () => ( {
|
|
|
|
requestingTaskListOptions: true,
|
|
|
|
} ) );
|
2020-07-14 12:20:51 +00:00
|
|
|
render(
|
|
|
|
<ActivityPanel
|
|
|
|
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
|
|
|
|
query={ {
|
2021-02-19 13:57:17 +00:00
|
|
|
page: 'wc-admin',
|
2020-07-14 12:20:51 +00:00
|
|
|
task: 'products',
|
|
|
|
path: '/customers',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
// Expect that "Help" tab is absent.
|
|
|
|
expect( screen.queryByText( 'Help' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
2020-11-16 13:48:50 +00:00
|
|
|
it( 'should render display options if on home screen', () => {
|
|
|
|
render(
|
|
|
|
<ActivityPanel
|
2021-02-19 13:57:17 +00:00
|
|
|
query={ {
|
|
|
|
page: 'wc-admin',
|
|
|
|
} }
|
2020-11-16 13:48:50 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( screen.getByText( '[DisplayOptions]' ) ).toBeDefined();
|
|
|
|
} );
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
it( 'should only render the finish setup link when TaskList is not complete', () => {
|
2020-09-24 21:23:27 +00:00
|
|
|
const { queryByText, rerender } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
expect( queryByText( 'Finish setup' ) ).toBeDefined();
|
2020-09-24 21:23:27 +00:00
|
|
|
|
2021-02-19 13:57:17 +00:00
|
|
|
useSelect.mockImplementation( () => ( {
|
|
|
|
requestingTaskListOptions: false,
|
|
|
|
setupTaskListComplete: true,
|
|
|
|
setupTaskListHidden: false,
|
|
|
|
} ) );
|
|
|
|
|
2020-09-24 21:23:27 +00:00
|
|
|
rerender(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
expect( queryByText( 'Finish setup' ) ).toBeNull();
|
2020-09-24 21:23:27 +00:00
|
|
|
} );
|
2020-12-03 01:13:36 +00:00
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
it( 'should not render the finish setup link when on the home screen and TaskList is not complete', () => {
|
2020-12-03 01:13:36 +00:00
|
|
|
const { queryByText } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
2021-02-19 13:57:17 +00:00
|
|
|
page: 'wc-admin',
|
2020-12-03 01:13:36 +00:00
|
|
|
task: '',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
expect( queryByText( 'Finish setup' ) ).toBeNull();
|
2020-12-03 01:13:36 +00:00
|
|
|
} );
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
it( 'should render the finish setup link when on embedded pages and TaskList is not complete', () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
const { getByText } = render(
|
2021-02-19 13:57:17 +00:00
|
|
|
<ActivityPanel isEmbedded query={ {} } />
|
|
|
|
);
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
expect( getByText( 'Finish setup' ) ).toBeInTheDocument();
|
2021-02-19 13:57:17 +00:00
|
|
|
} );
|
|
|
|
|
2023-05-08 07:55:09 +00:00
|
|
|
it( 'should not render the finish setup link when a user does not have capabilities', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
useUser.mockImplementation( () => ( {
|
|
|
|
currentUserCan: () => false,
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
const { queryByText } = render(
|
2020-12-03 01:13:36 +00:00
|
|
|
<ActivityPanel
|
2021-02-19 13:57:17 +00:00
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
2020-12-03 01:13:36 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2021-03-09 22:50:37 +00:00
|
|
|
expect( queryByText( 'Finish setup' ) ).toBeDefined();
|
2020-12-18 13:17:07 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'help panel tooltip', () => {
|
|
|
|
it( 'should render highlight tooltip when task count is at-least 2, task is not completed, and tooltip not shown yet', () => {
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences.mockReturnValue( {
|
|
|
|
updateUserPreferences: () => {},
|
|
|
|
task_list_tracked_started_tasks: { payment: 2 },
|
|
|
|
} );
|
2020-12-18 13:17:07 +00:00
|
|
|
const { getByText } = render(
|
2021-12-14 16:56:42 +00:00
|
|
|
<ActivityPanel isEmbedded query={ { task: 'payment' } } />
|
2020-12-18 13:17:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect( getByText( '[HighlightTooltip]' ) ).toBeInTheDocument();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not render highlight tooltip when task is not visited more then once', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
useSelect.mockImplementation( () => ( {
|
|
|
|
requestingTaskListOptions: false,
|
|
|
|
setupTaskListComplete: false,
|
|
|
|
setupTaskListHidden: false,
|
|
|
|
trackedCompletedTasks: [],
|
|
|
|
} ) );
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences.mockReturnValue( {
|
|
|
|
updateUserPreferences: () => {},
|
|
|
|
task_list_tracked_started_tasks: { payment: 1 },
|
|
|
|
} );
|
2020-12-18 13:17:07 +00:00
|
|
|
render(
|
2021-12-14 16:56:42 +00:00
|
|
|
<ActivityPanel isEmbedded query={ { task: 'payment' } } />
|
2020-12-18 13:17:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect( screen.queryByText( '[HighlightTooltip]' ) ).toBeNull();
|
|
|
|
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences.mockReturnValue( {
|
|
|
|
updateUserPreferences: () => {},
|
|
|
|
task_list_tracked_started_tasks: {},
|
|
|
|
} );
|
|
|
|
|
2020-12-18 13:17:07 +00:00
|
|
|
render(
|
2021-12-14 16:56:42 +00:00
|
|
|
<ActivityPanel isEmbedded query={ { task: 'payment' } } />
|
2020-12-18 13:17:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect( screen.queryByText( '[HighlightTooltip]' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not render highlight tooltip when task is visited twice, but completed already', () => {
|
2021-02-19 13:57:17 +00:00
|
|
|
useSelect.mockImplementation( () => ( {
|
|
|
|
requestingTaskListOptions: false,
|
|
|
|
setupTaskListComplete: false,
|
|
|
|
setupTaskListHidden: false,
|
2021-11-15 20:57:13 +00:00
|
|
|
isCompletedTask: true,
|
2021-02-19 13:57:17 +00:00
|
|
|
} ) );
|
|
|
|
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences.mockReturnValue( {
|
|
|
|
updateUserPreferences: () => {},
|
|
|
|
task_list_tracked_started_tasks: { payment: 2 },
|
|
|
|
} );
|
|
|
|
|
2020-12-18 13:17:07 +00:00
|
|
|
const { queryByText } = render(
|
2021-12-14 16:56:42 +00:00
|
|
|
<ActivityPanel isEmbedded query={ { task: 'payment' } } />
|
2020-12-18 13:17:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect( queryByText( '[HighlightTooltip]' ) ).toBeNull();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should not render highlight tooltip when task is visited twice, not completed, but already shown', () => {
|
2021-12-14 16:56:42 +00:00
|
|
|
useUserPreferences.mockReturnValue( {
|
|
|
|
task_list_tracked_started_tasks: { payment: 2 },
|
|
|
|
help_panel_highlight_shown: 'yes',
|
|
|
|
} );
|
|
|
|
|
2020-12-18 13:17:07 +00:00
|
|
|
const { queryByText } = render(
|
2021-12-14 16:56:42 +00:00
|
|
|
<ActivityPanel isEmbedded query={ { task: 'payment' } } />
|
2020-12-18 13:17:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
expect( queryByText( '[HighlightTooltip]' ) ).toBeNull();
|
|
|
|
} );
|
2020-12-03 01:13:36 +00:00
|
|
|
} );
|
2021-02-25 12:56:00 +00:00
|
|
|
|
|
|
|
describe( 'panel', () => {
|
|
|
|
it( 'should set focus when panel opened/closed without removing element when onTransitionEnd is triggered', () => {
|
|
|
|
const content = 'test';
|
|
|
|
const TestComponent = () => {
|
|
|
|
const [ panelOpen, setPanelOpen ] = useState( true );
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<button onClick={ () => setPanelOpen( ! panelOpen ) }>
|
|
|
|
Toggle
|
|
|
|
</button>
|
|
|
|
<Panel
|
|
|
|
isPanelOpen={ panelOpen }
|
|
|
|
tab={ {} }
|
|
|
|
content={ content }
|
|
|
|
clearPanel={ () => {} }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
const { container, queryByText, getByRole } = render(
|
|
|
|
<TestComponent />
|
|
|
|
);
|
|
|
|
expect( queryByText( 'test' ) ).toBeInTheDocument();
|
|
|
|
expect( document.activeElement ).toEqual(
|
|
|
|
container.getElementsByClassName(
|
|
|
|
'woocommerce-layout__activity-panel-wrapper'
|
|
|
|
)[ 0 ]
|
|
|
|
);
|
|
|
|
getByRole( 'button' ).focus();
|
|
|
|
expect( document.activeElement ).not.toEqual(
|
|
|
|
container.getElementsByClassName(
|
|
|
|
'woocommerce-layout__activity-panel-wrapper'
|
|
|
|
)[ 0 ]
|
|
|
|
);
|
|
|
|
fireEvent.click( getByRole( 'button' ) );
|
|
|
|
fireEvent.click( getByRole( 'button' ) );
|
|
|
|
const event = createEvent.transitionEnd(
|
|
|
|
container.getElementsByClassName(
|
|
|
|
'woocommerce-layout__activity-panel-wrapper'
|
|
|
|
)[ 0 ]
|
|
|
|
);
|
|
|
|
Object.defineProperty( event, 'propertyName', {
|
|
|
|
value: 'transform',
|
|
|
|
} );
|
|
|
|
|
|
|
|
fireEvent(
|
|
|
|
container.getElementsByClassName(
|
|
|
|
'woocommerce-layout__activity-panel-wrapper'
|
|
|
|
)[ 0 ],
|
|
|
|
event
|
|
|
|
);
|
|
|
|
expect( document.activeElement ).toEqual(
|
|
|
|
container.getElementsByClassName(
|
|
|
|
'woocommerce-layout__activity-panel-wrapper'
|
|
|
|
)[ 0 ]
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'panel open and closing', () => {
|
|
|
|
let clearPanel;
|
|
|
|
beforeEach( () => {
|
|
|
|
Panel.mockImplementation(
|
|
|
|
( { isPanelOpen, isPanelSwitching, tab, ...props } ) => {
|
|
|
|
clearPanel = props.clearPanel;
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<span>[panel]</span>
|
|
|
|
<span>[panelOpen={ isPanelOpen.toString() }]</span>
|
|
|
|
<span>
|
|
|
|
[panelSwitching={ isPanelSwitching.toString() }]
|
|
|
|
</span>
|
|
|
|
<span>[hasTab={ tab ? 'true' : 'false' }]</span>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should have panel open and panel switching as false by default', () => {
|
|
|
|
const { queryByText, getByRole } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
|
|
|
task: 'products',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
expect( queryByText( '[panel]' ) ).toBeInTheDocument();
|
|
|
|
expect( queryByText( '[panelOpen=false]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
fireEvent.click( getByRole( 'tab', { name: 'Help' } ) );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should allow user to toggle, an individual panel without setting panelSwitching to true', () => {
|
|
|
|
const { queryByText, getByRole } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
|
|
|
task: '',
|
|
|
|
page: 'wc-admin',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
expect( queryByText( '[panel]' ) ).toBeInTheDocument();
|
|
|
|
expect( queryByText( '[panelOpen=false]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
// toggle open
|
|
|
|
fireEvent.click( getByRole( 'tab', { name: 'Help' } ) );
|
|
|
|
expect( queryByText( '[panelOpen=true]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
// toggle close
|
|
|
|
fireEvent.click( getByRole( 'tab', { name: 'Help' } ) );
|
|
|
|
expect( queryByText( '[panelOpen=false]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'should remove panel element after clearPanel is triggered', () => {
|
|
|
|
const { queryByText, getByRole } = render(
|
|
|
|
<ActivityPanel
|
|
|
|
query={ {
|
|
|
|
task: '',
|
|
|
|
page: 'wc-admin',
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
// toggle open
|
|
|
|
fireEvent.click( getByRole( 'tab', { name: 'Help' } ) );
|
|
|
|
expect( queryByText( '[panelOpen=true]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
// toggle close
|
|
|
|
fireEvent.click( getByRole( 'tab', { name: 'Help' } ) );
|
|
|
|
expect( queryByText( '[panelOpen=false]' ) ).toBeInTheDocument();
|
|
|
|
expect( queryByText( '[hasTab=true]' ) ).toBeInTheDocument();
|
|
|
|
expect(
|
|
|
|
queryByText( '[panelSwitching=false]' )
|
|
|
|
).toBeInTheDocument();
|
|
|
|
act( () => {
|
|
|
|
clearPanel();
|
|
|
|
} );
|
|
|
|
expect( queryByText( '[hasTab=false]' ) ).toBeInTheDocument();
|
|
|
|
} );
|
|
|
|
} );
|
2020-07-14 12:20:51 +00:00
|
|
|
} );
|