-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Publishing UX for contributors (#6729)
* Fix publishing UX for contributors * Merge #6724 into PR * Removed compose from prepublish.js, improved the conditions checking publish action * Avoid ternaries from toggle label * Introduce unit tests to post publish panel toggle * Add explicit tests for button text * Restore publish toggle label, update publish panel copy for contributors * Update unit tests according to changed toggle label * Fix a unit test description
- Loading branch information
1 parent
555f2ea
commit 6bf15a3
Showing
3 changed files
with
114 additions
and
18 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 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,75 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { shallow } from 'enzyme'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { PostPublishPanelToggle } from '../toggle'; | ||
|
||
describe( 'PostPublishPanelToggle', () => { | ||
describe( 'disabled', () => { | ||
it( 'should be disabled if post is currently saving', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isSaving /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'should be disabled if post is currently force saving', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle forceIsSaving /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'should be disabled if post is not publishable', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isPublishable={ false } /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'should be disabled if post is not saveable', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isSaveable={ false } /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'should be disabled if post is not published', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isPublished={ false } /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'should be enabled otherwise', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isPublishable isSaveable /> | ||
); | ||
|
||
expect( wrapper.prop( 'disabled' ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'should display Schedule… if able to be scheduled', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isPublishable isSaveable isBeingScheduled /> | ||
); | ||
expect( wrapper.childAt( 0 ).text() ).toBe( 'Schedule…' ); | ||
} ); | ||
|
||
it( 'should display Publish… if able to be published', () => { | ||
const wrapper = shallow( | ||
<PostPublishPanelToggle isPublishable isSaveable hasPublishAction /> | ||
); | ||
expect( wrapper.childAt( 0 ).text() ).toBe( 'Publish…' ); | ||
} ); | ||
} ); | ||
} ); |
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