Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7cc241
Add PrePublish panel option to the general menu tools section
oandregal Sep 7, 2018
e3f0c24
Add data API
oandregal Sep 7, 2018
85edadc
Rename PublishPanel to PrePublishPanel
oandregal Sep 7, 2018
0488595
Implement core/edit-post actions and selector
oandregal Sep 10, 2018
14ea423
Rename pre-publish-panel-toggle to publish-sidebar-toggle
oandregal Sep 10, 2018
f4c237e
Connect the dots: publish toggles publish sidebar or publish directly
oandregal Sep 10, 2018
1a00c13
Update test for isPublishSidebarEnable preference
oandregal Sep 11, 2018
c659529
Expose dismissing option as a checkbox in the sidebar
oandregal Sep 11, 2018
e888220
Move publish sidebar logic to core/editor store
oandregal Sep 11, 2018
b3e9fa8
docs: tweak comment on isPublishSidebarEnabled
tofumatt Sep 11, 2018
f78a332
Use arrow function instead of traditional function
oandregal Sep 11, 2018
3e2877f
Fix linting issue that went undetected by eslint
oandregal Sep 11, 2018
dbd6090
Use english apostrophe, not single commas
oandregal Sep 11, 2018
ea5dc6a
Make enable/disable actions more obvious
oandregal Sep 11, 2018
afae18d
Inline PostPublish button / toggle logic
oandregal Sep 11, 2018
2f45e20
Add padding to align and give it space
oandregal Sep 11, 2018
7bfc2a5
Align to bottom
oandregal Sep 11, 2018
c65ea7c
Update wording
oandregal Sep 11, 2018
18036e2
Update copy
oandregal Sep 12, 2018
c37b6a8
Tweak microcopy for pre-publish checks.
sarahmonster Sep 12, 2018
d1c69c5
Remove outdated docs
oandregal Sep 13, 2018
1be0b54
Preventive measure
oandregal Sep 14, 2018
79ced01
Fix and add tests
oandregal Sep 14, 2018
78ebeec
Add e2e test
oandregal Sep 17, 2018
87b372d
Refactor code to avoid duplication
oandregal Sep 17, 2018
acffe70
chore: Tweak styles
tofumatt Sep 18, 2018
37900cc
Disable pre-publish checks after test
oandregal Sep 19, 2018
6637b7e
Add enable/disable functions
oandregal Sep 19, 2018
d7c7151
Use specific selector to target pre-publish checks menu item
oandregal Sep 19, 2018
b50ca1d
Do not make assumptions about previous states
oandregal Sep 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add e2e test
  • Loading branch information
oandregal committed Sep 17, 2018
commit 78ebeeca0d65ab72b9c3bb949665fea74af082c3
42 changes: 42 additions & 0 deletions test/e2e/specs/publishing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import {
newPost,
publishPost,
publishPostWithoutPrePublishChecks,
disablePrePublishChecks,
} from '../support/utils';

describe( 'Publishing', () => {
Expand All @@ -28,6 +30,26 @@ describe( 'Publishing', () => {
} );
} );

describe( 'a post when pre-publish checks are disabled', () => {
beforeEach( async () => {
await newPost();
await disablePrePublishChecks();
} );

it( 'should publish it without opening the post-publish sidebar.', async () => {
await page.type( '.editor-post-title__input', 'E2E Test Post' );

// The "Publish" button should be shown instead of the "Publish..." toggle
expect( await page.$( '.editor-post-publish-panel__toggle' ) ).toBeNull();
expect( await page.$( '.editor-post-publish-button' ) ).not.toBeNull();

await publishPostWithoutPrePublishChecks();

// The post-publishing panel should have been not shown.
expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
} );
} );

describe( 'a page', () => {
beforeEach( async () => {
await newPost( 'page' );
Expand All @@ -48,4 +70,24 @@ describe( 'Publishing', () => {
expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
} );
} );

describe( 'a page when pre-publish checks are disabled', () => {
beforeEach( async () => {
await newPost( 'page' );
await disablePrePublishChecks();
} );

it( 'should publish it without opening the post-publish sidebar', async () => {
await page.type( '.editor-post-title__input', 'E2E Test Page' );

// The "Publish" button should be shown instead of the "Publish..." toggle
expect( await page.$( '.editor-post-publish-panel__toggle' ) ).toBeNull();
expect( await page.$( '.editor-post-publish-button' ) ).not.toBeNull();

await publishPostWithoutPrePublishChecks();

// The post-publishing panel should have been not shown.
expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
} );
} );
} );
17 changes: 17 additions & 0 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ export async function newPost( { postType, enableTips = false } = {} ) {
}
}

export async function disablePrePublishChecks( ) {
await page.click( '.edit-post-more-menu' );
await page.waitForSelector( '.components-popover__content' );
await page.click( '.components-popover__content > .components-menu-group:nth-child(3) button:nth-child(3)' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a fragile selector, is there anything better/better-named we could use to select the "Don't show this again" checkbox? It looks like . editor-post-publish-panel__footer input[type=checkbox] would work assuming CheckboxControl outputs an actual checkbox.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved at d7c7151

I was reluctant to introduce a specific selector just for testing but, on a second thought, it's totally worth it in this case. Note also that the code uses the general menu, not the actual checkbox within the publish sidebar. We can't guarantee the publish sidebar is enabled unless we use the general menu.

}

export async function setViewport( type ) {
const allowedDimensions = {
large: { width: 960, height: 700 },
Expand Down Expand Up @@ -294,6 +300,17 @@ export async function publishPost() {
return page.waitForSelector( '.components-notice.is-success' );
}

/**
* Publishes the post without the pre-publish checks,
* resolving once the request is complete (once a notice is displayed).
*
* @return {Promise} Promise resolving when publish is complete.
*/
export async function publishPostWithoutPrePublishChecks() {
await page.click( '.editor-post-publish-button' );
return page.waitForSelector( '.components-notice.is-success' );
}

/**
* Saves the post as a draft, resolving once the request is complete (once the
* "Saved" indicator is displayed).
Expand Down