# code-block-pro/1.1.0/cypress/support/gutenberg.js

Code Block Pro – Beautiful Syntax Highlighting, version 1.1.0. 52 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.1.0/code/cypress/support/gutenberg.js
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.1.0/raw/cypress/support/gutenberg.js
- Modified: 2022-08-22T22:25:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.1.0/code/cypress/support/gutenberg.js#L10-L20`.

```javascript
export const closeWelcomeGuide = () => {
    cy.window().then((win) => {
        if (
            win.wp.data.select('core/edit-post').isFeatureActive('welcomeGuide')
        ) {
            win.wp.data
                .dispatch('core/edit-post')
                .toggleFeature('welcomeGuide');
        }
    });
};

export const saveDraft = () => {
    cy.get('body').then((body) => {
        if (body.find('.editor-post-save-draft').length > 0) {
            cy.get('.editor-post-save-draft').click();
            cy.get('.editor-post-saved-state.is-saved');
        }
    });
};

export const setPostContent = (content) => {
    cy.window().then((win) => {
        const { dispatch } = win.wp.data;
        const blocks = win.wp.blocks.parse(content);
        dispatch('core/block-editor').resetBlocks(blocks);
    });
};
export const openBlockInserter = () => {
    cy.get('button[aria-label="Toggle block inserter"]').then((button) => {
        if (button.attr('aria-pressed') === 'false') {
            button.click();
        }
    });
};
export const closeBlockInserter = () => {
    cy.get('button[aria-label="Toggle block inserter"]').then((button) => {
        if (button.attr('aria-pressed') === 'true') {
            button.click();
        }
    });
};
export const addBlock = (slug) => {
    cy.openBlockInserter();
    cy.get(`button[class*="${slug}"]`).click();
};
export const wpDataSelect = (store, selector, ...parameters) => {
    cy.window().then((win) => {
        return win.wp.data.select(store)[selector](...parameters);
    });
};

```
