Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tasklist completion message when no tasks are completed (#38092)
* Fix task list progress title * Add changelog
- Loading branch information
Showing
3 changed files
with
115 additions
and
1 deletion.
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
110 changes: 110 additions & 0 deletions
110
...s/woocommerce-admin/client/task-lists/progress-title/test/default-progress-title.test.tsx
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,110 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { render, screen } from '@testing-library/react'; | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { DefaultProgressTitle } from '../default-progress-title'; | ||
|
||
jest.mock( '@wordpress/data', () => ( { | ||
...jest.requireActual( '@wordpress/data' ), | ||
useSelect: jest.fn(), | ||
} ) ); | ||
|
||
describe( 'default-progress-title', () => { | ||
( useSelect as jest.Mock ).mockImplementation( ( fn ) => | ||
fn( () => ( { | ||
getTaskList: () => ( { | ||
tasks: [], | ||
} ), | ||
hasFinishedResolution: () => true, | ||
} ) ) | ||
); | ||
|
||
it( 'should render "Welcome to your store" when no tasks are completed and visited', () => { | ||
render( <DefaultProgressTitle taskListId="1" /> ); | ||
expect( | ||
screen.getByText( 'Welcome to your store' ) | ||
).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'should render "Welcome to your store" when all tasks are completed', () => { | ||
( useSelect as jest.Mock ).mockImplementation( ( fn ) => | ||
fn( () => ( { | ||
getTaskList: () => ( { | ||
tasks: [ | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
], | ||
} ), | ||
hasFinishedResolution: () => true, | ||
} ) ) | ||
); | ||
render( <DefaultProgressTitle taskListId="1" /> ); | ||
expect( | ||
screen.getByText( 'Welcome to your store' ) | ||
).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'should render "Let\'s get you started" when has task visited and task completed count <= 3', () => { | ||
( useSelect as jest.Mock ).mockImplementation( ( fn ) => | ||
fn( () => ( { | ||
getTaskList: () => ( { | ||
tasks: [ { isVisited: true, isComplete: false } ], | ||
} ), | ||
hasFinishedResolution: () => true, | ||
} ) ) | ||
); | ||
render( <DefaultProgressTitle taskListId="1" /> ); | ||
expect( | ||
screen.getByText( "Let's get you started", { exact: false } ) | ||
).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'should render "You are on the right track" when has task visited and task completed count > 3', () => { | ||
( useSelect as jest.Mock ).mockImplementation( ( fn ) => | ||
fn( () => ( { | ||
getTaskList: () => ( { | ||
tasks: [ | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: false }, | ||
], | ||
} ), | ||
hasFinishedResolution: () => true, | ||
} ) ) | ||
); | ||
render( <DefaultProgressTitle taskListId="1" /> ); | ||
expect( | ||
screen.getByText( 'You are on the right track', { exact: false } ) | ||
).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'should render "You are almost there" when has task visited and task completed count > 5', () => { | ||
( useSelect as jest.Mock ).mockImplementation( ( fn ) => | ||
fn( () => ( { | ||
getTaskList: () => ( { | ||
tasks: [ | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: true }, | ||
{ isVisited: true, isComplete: false }, | ||
], | ||
} ), | ||
hasFinishedResolution: () => true, | ||
} ) ) | ||
); | ||
render( <DefaultProgressTitle taskListId="1" /> ); | ||
expect( | ||
screen.getByText( 'You are almost there', { exact: false } ) | ||
).toBeInTheDocument(); | ||
} ); | ||
} ); |
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/fix-tasklist-completion-message
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,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Fix task list progress title when no tasks are completed |