Skip to content

Commit

Permalink
Merge pull request #250 from 10up/fix/e2e-tests
Browse files Browse the repository at this point in the history
Fix e2e test setup
  • Loading branch information
fabiankaegy authored Aug 23, 2023
2 parents e98d388 + 384109c commit c38732c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const { defineConfig } = require('cypress')
module.exports = defineConfig({
projectId: 'dnr1ke',
videoCompression: 15,
viewportWidth: 1536,
viewportHeight: 960,
env: {
username: 'admin',
password: 'password',
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/IconPicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ context('IconPicker', () => {
cy.insertBlock('Icon Picker Example');
cy.get('.component-icon-picker-inline-button').click();
cy.get('.component-icon-picker-inline__content [placeholder="Search"]').type('tool');
cy.get('.component-icon-picker-inline__content').contains('Tool').click({force: true});
cy.get('.component-icon-picker-inline__content .components-checkbox-control').first().click({force: true});

cy.savePost();

Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/Image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ context('Image', () => {
cy.get('#attachment-details-alt-text').type('Test Alt Text');
cy.get('.media-button-select').contains('Select').click();

cy.get('.wp-block-example-image-example img').scrollIntoView().should('be.visible');
cy.get('.wp-block-example-image-example img').scrollIntoView({offset: -50})
cy.get('.wp-block-example-image-example img').should('be.visible');

cy.get('.wp-block-example-image-example img')
.should('have.attr', 'alt');
Expand All @@ -34,7 +35,8 @@ context('Image', () => {

cy.wait(500);

cy.get('.wp-block-example-image-example img').scrollIntoView().should('be.visible');
cy.get('.wp-block-example-image-example img').scrollIntoView({offset: -50})
cy.get('.wp-block-example-image-example img').should('be.visible');

})

Expand Down
10 changes: 4 additions & 6 deletions cypress/e2e/Link.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ context('Link', () => {

// create the first link
cy.get('.tenup-block-components-link__label').first().click();
cy.wait(1500);
cy.wait(50);
cy.get('.tenup-block-components-link__label').first().scrollIntoView({offset: {top: 100}}).type('First Link Label', { delay: 50, waitForAnimations: true });
cy.get('.block-editor-url-input__input').first().type('https://10up.com/', { delay: 50, waitForAnimations: true });
cy.get('button.block-editor-link-control__search-submit').first().click();
cy.get('.block-editor-url-input__input').first().type('https://10up.com/{enter}', { delay: 50, waitForAnimations: true });

// create the second link
cy.get('.tenup-block-components-link__label').eq(1).click();
cy.wait(1500);
cy.wait(50);
cy.get('.tenup-block-components-link__label').eq(1).type('Second Link Label', { delay: 50, waitForAnimations: true });
cy.get('.block-editor-url-input__input').first().type('https://10up.com/our-work/', { delay: 50, waitForAnimations: true });
cy.get('button.block-editor-link-control__search-submit').first().click();
cy.get('.block-editor-url-input__input').first().type('https://10up.com/our-work/{enter}', { delay: 50, waitForAnimations: true });

cy.savePost();

Expand Down
2 changes: 2 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Cypress.Commands.add('createPost', (options = {}) => {
.contains(postType, { matchCase: false })
.click({ force: true });

cy.wait(100);

// close the Yoast SEO metabox
cy.get('.wpseo-metabox .handlediv').then(button => {
const isExpanded = button[0].getAttribute('aria-expanded') === 'true';
Expand Down
2 changes: 1 addition & 1 deletion example/.wp-env.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": [ ".", "https://downloads.wordpress.org/plugin/wordpress-seo.20.9.zip" ],
"plugins": [ ".", "https://downloads.wordpress.org/plugin/wordpress-seo.21.0.zip" ],
"mappings": {
"/var/www/html/images": "./images"
}
Expand Down
8 changes: 8 additions & 0 deletions example/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ function register_book_custom_post_type() {
}

add_action( 'init', __NAMESPACE__ . '\register_book_custom_post_type' );


add_action(
'after_setup_theme',
function() {
remove_theme_support( 'core-block-patterns' );
}
);

0 comments on commit c38732c

Please sign in to comment.