This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add existing TaskList component to new home screen (#4378)
* Move TaskList component up in directory tree. * Render the TaskList on the new home screen. * Render single tasks in isolation on new home screen. * Fix "is requesting" selection for options API. * Add loading placeholder for TaskList. * Add initial test for the task list on the home screen. * Fix dynamic imports under test. * Add test for inline TaskList on home screen. * Test that single task view works on new home screen. * Restore Jest mocks between tests. * Fix linting errors.
- Loading branch information
1 parent
7a73ef4
commit 4cf137f
Showing
34 changed files
with
942 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { render, screen } from '@testing-library/react'; | ||
import { Layout } from '../layout'; | ||
|
||
// Rendering <StatsOverview /> breaks tests. | ||
jest.mock( 'homepage/stats-overview', () => jest.fn().mockReturnValue( null ) ); | ||
|
||
// We aren't testing the <TaskList /> component here. | ||
jest.mock( 'task-list', () => jest.fn().mockReturnValue( '[TaskList]' ) ); | ||
|
||
describe( 'Homepage Layout', () => { | ||
it( 'should show TaskList placeholder when loading', () => { | ||
const { container } = render( | ||
<Layout | ||
requestingTaskList | ||
taskListHidden={ false } | ||
query={ {} } | ||
/> | ||
); | ||
|
||
const placeholder = container.querySelector( '.woocommerce-task-card.is-loading' ); | ||
expect( placeholder ).not.toBeNull(); | ||
} ); | ||
|
||
it( 'should show TaskList inline', async () => { | ||
const { container } = render( | ||
<Layout | ||
requestingTaskList={ false } | ||
taskListHidden={ false } | ||
query={ {} } | ||
/> | ||
); | ||
|
||
// Expect that we're rendering the "full" home screen (with columns). | ||
const columns = container.querySelector( '.woocommerce-homepage-column' ); | ||
expect( columns ).not.toBeNull(); | ||
|
||
// Expect that the <TaskList /> is there too. | ||
const taskList = await screen.findByText( '[TaskList]' ) | ||
expect( taskList ).toBeDefined(); | ||
} ); | ||
|
||
it( 'should render TaskList alone when on task', async () => { | ||
const { container } = render( | ||
<Layout | ||
requestingTaskList={ false } | ||
taskListHidden={ false } | ||
query={ { | ||
task: 'products', | ||
} } | ||
/> | ||
); | ||
|
||
// Expect that we're NOT rendering the "full" home screen (with columns). | ||
const columns = container.querySelector( '.woocommerce-homepage-column' ); | ||
expect( columns ).toBeNull(); | ||
|
||
// Expect that the <TaskList /> is there though. | ||
const taskList = await screen.findByText( '[TaskList]' ) | ||
expect( taskList ).toBeDefined(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.