Skip to content

Commit

Permalink
Merge pull request #56 from KevinBatdorf/add-basic-line-number-support
Browse files Browse the repository at this point in the history
Add line number support
  • Loading branch information
KevinBatdorf committed Nov 10, 2022
2 parents caea000 + 4586cf1 commit e112fa9
Show file tree
Hide file tree
Showing 17 changed files with 2,062 additions and 2,235 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
wp-version: [null, '"WordPress/WordPress#master"']
steps:
- name: Clone repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install server
run: |
npm ci
npm install -g @wordpress/env
npm run build
rm .wp-env.json
- name: Change WP version
uses: jsdaniell/create-json@1.1.2
uses: jsdaniell/create-json@v1.2.1
with:
name: 'wp-env.json'
json: '{"core": ${{ matrix.wp-version }},"plugins":["."]}'
Expand Down
1 change: 1 addition & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'cypress-wait-until';
import './commands';
import './globals';
import './helpers';
46 changes: 39 additions & 7 deletions cypress/support/gutenberg.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
export const closeWelcomeGuide = () => {
cy.window().then((win) => {
if (
win.wp.data.select('core/edit-post').isFeatureActive('welcomeGuide')
) {
// If it's not open, open it first
cy.waitUntil(() => {
if (
win.wp.data
.select('core/edit-post')
.isFeatureActive('welcomeGuide')
) {
return true;
}
win.wp.data
.dispatch('core/edit-post')
.toggleFeature('welcomeGuide');
}
return false;
});
const className = '[aria-label="Welcome to the block editor"]';
// It's important we open it then wait for the animation to finish
cy.get(className).should('be.visible');
// Then close it
cy.waitUntil(() => {
if (
!win.wp.data
.select('core/edit-post')
.isFeatureActive('welcomeGuide')
) {
return true;
}
win.wp.data
.dispatch('core/edit-post')
.toggleFeature('welcomeGuide');

// And wait again for the animation to finish
cy.get(className).should('not.exist');
});
});
};

Expand All @@ -29,14 +55,14 @@ export const setPostContent = (content) => {
export const openBlockInserter = () => {
cy.get('button[aria-label="Toggle block inserter"]').then((button) => {
if (button.attr('aria-pressed') === 'false') {
button.click();
cy.get('button[aria-label="Toggle block inserter"]').click();
}
});
};
export const closeBlockInserter = () => {
cy.get('button[aria-label="Toggle block inserter"]').then((button) => {
if (button.attr('aria-pressed') === 'true') {
button.click();
cy.get('button[aria-label="Toggle block inserter"]').click();
}
});
};
Expand Down Expand Up @@ -67,7 +93,13 @@ export const openThemesPanel = () => {
};
export const addBlock = (slug) => {
cy.openBlockInserter();
cy.get(`button[class*="${slug}"]`).click();
cy.window().then((win) => {
// If it's not open, open it first
cy.waitUntil(() =>
win.document.querySelector(`button[class*="${slug}"]`),
);
cy.get(`button[class*="${slug}"]`).click();
});
};
export const wpDataSelect = (store, selector, ...parameters) => {
cy.window().then((win) => {
Expand Down
Loading

0 comments on commit e112fa9

Please sign in to comment.