| 1 |
export const closeWelcomeGuide = () => { |
| 2 |
cy.window().then((win) => { |
| 3 |
if ( |
| 4 |
win.wp.data.select('core/edit-post').isFeatureActive('welcomeGuide') |
| 5 |
) { |
| 6 |
win.wp.data |
| 7 |
.dispatch('core/edit-post') |
| 8 |
.toggleFeature('welcomeGuide'); |
| 9 |
} |
| 10 |
}); |
| 11 |
}; |
| 12 |
|
| 13 |
export const saveDraft = () => { |
| 14 |
cy.get('body').then((body) => { |
| 15 |
if (body.find('.editor-post-save-draft').length > 0) { |
| 16 |
cy.get('.editor-post-save-draft').click(); |
| 17 |
cy.get('.editor-post-saved-state.is-saved'); |
| 18 |
} |
| 19 |
}); |
| 20 |
}; |
| 21 |
|
| 22 |
export const setPostContent = (content) => { |
| 23 |
cy.window().then((win) => { |
| 24 |
const { dispatch } = win.wp.data; |
| 25 |
const blocks = win.wp.blocks.parse(content); |
| 26 |
dispatch('core/block-editor').resetBlocks(blocks); |
| 27 |
}); |
| 28 |
}; |
| 29 |
export const openBlockInserter = () => { |
| 30 |
cy.get('button[aria-label="Toggle block inserter"]').then((button) => { |
| 31 |
if (button.attr('aria-pressed') === 'false') { |
| 32 |
button.click(); |
| 33 |
} |
| 34 |
}); |
| 35 |
}; |
| 36 |
export const closeBlockInserter = () => { |
| 37 |
cy.get('button[aria-label="Toggle block inserter"]').then((button) => { |
| 38 |
if (button.attr('aria-pressed') === 'true') { |
| 39 |
button.click(); |
| 40 |
} |
| 41 |
}); |
| 42 |
}; |
| 43 |
export const addBlock = (slug) => { |
| 44 |
cy.openBlockInserter(); |
| 45 |
cy.get(`button[class*="${slug}"]`).click(); |
| 46 |
}; |
| 47 |
export const wpDataSelect = (store, selector, ...parameters) => { |
| 48 |
cy.window().then((win) => { |
| 49 |
return win.wp.data.select(store)[selector](...parameters); |
| 50 |
}); |
| 51 |
}; |
| 52 |
|