Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue migrating E2E tests to Cypress. #1070

Merged
merged 34 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab9dae1
Remove internal pull tests (migrated to Cypress).
peterwilsoncc Jun 6, 2023
9f6e8eb
Remove oembed tests (migrated to Cypress).
peterwilsoncc Jun 6, 2023
ddf1c4c
Delete Settings Tests (migrated to Cypress).
peterwilsoncc Jun 6, 2023
36d1c76
Test limited connection warning displays.
peterwilsoncc Jun 6, 2023
cc2964f
Move test image from WPA directory to Cypress directory.
peterwilsoncc Jun 7, 2023
e682df3
Specify config file in workflow file.
peterwilsoncc Jun 7, 2023
8ca7479
Add explanation why featured image test is disabled.
peterwilsoncc Jun 7, 2023
6da6ddc
Delete Internal Push Tests (migrated to Cypress).
peterwilsoncc Jun 7, 2023
ff4f5d5
Update 10up Cypress test utilities.
peterwilsoncc Jun 7, 2023
fc08bb5
Add test to ensure distributed to count increments.
peterwilsoncc Jun 7, 2023
c227b5c
Allow welcome box to be closed via mouse click.
peterwilsoncc Jun 7, 2023
cf33631
Test distributed posts show links to source.
peterwilsoncc Jun 7, 2023
9e18863
Test canonical URL is filtered as expected.
peterwilsoncc Jun 7, 2023
919a05c
Rename post variables for clarity.
peterwilsoncc Jun 7, 2023
f49db81
Remove Distributed Posts tests (migrated to Cypress).
peterwilsoncc Jun 7, 2023
0070301
Test linked posts display correct notice & lack interactivity.
peterwilsoncc Jun 8, 2023
5102ac9
Ensure unlinked posts show expected notice and are interactive.
peterwilsoncc Jun 8, 2023
9a9d54d
Delete link/unlinking tests (migrated to Cypress).
peterwilsoncc Jun 8, 2023
3156948
Modify selectors to account for HTML markup changes between versions.
peterwilsoncc Jun 8, 2023
b0c83a2
Merge branch 'develop' into do/1038-cypress-migration
peterwilsoncc Jun 8, 2023
e5dfb73
Test distribution menu hidden on new post page.
peterwilsoncc Jun 8, 2023
e80b43b
Test Distribution menu is visible on published post.
peterwilsoncc Jun 8, 2023
f04b81a
Test the push menu disables items already distributed to.
peterwilsoncc Jun 8, 2023
3747002
Test adding and removing push connections works.
peterwilsoncc Jun 8, 2023
fb6ce52
Remove unused variable.
peterwilsoncc Jun 8, 2023
70707ee
Delete extenan connection create tests (migrated to Cypress).
peterwilsoncc Jun 8, 2023
5ab2732
Delete Push Menu Tests (migrated to Cypress).
peterwilsoncc Jun 8, 2023
ab21a4d
Test network pushed posts contain block markup.
peterwilsoncc Jun 8, 2023
ee34a80
Ensure network pulled posts contain block markup.
peterwilsoncc Jun 8, 2023
786315d
Test pulling from an external connection.
peterwilsoncc Jun 9, 2023
98aad74
Test pushing to an external connection.
peterwilsoncc Jun 9, 2023
85ab03f
Delete editor blocks tests (migrated to Cypress).
peterwilsoncc Jun 9, 2023
d5b31c1
Remove last traces of wpacceptance test suite.
peterwilsoncc Jun 9, 2023
a87fa68
Merge branch 'develop' into do/1038-cypress-migration
iamdharmesh Jun 14, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
run: npm run copy-htaccess

- name: Test
run: npm run cypress:run
run: npm run cypress:run --config-file tests/cypress/config.js

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions assets/css/gutenberg-syndicated-post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ body.dt-linked-post {
cursor: default;
}

.edit-post-welcome-guide,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is to allow cy.closeWelcomeGuide(); to run by re-enabling pointer events on the modal. Without them, Cypress declines to click on the element because it's unclickable.

.edit-post-header__settings,
.components-time-picker,
.react-datepicker,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions run-wpacceptance.sh

This file was deleted.

107 changes: 107 additions & 0 deletions tests/cypress/e2e/distributed-post.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
const { randomName } = require( '../support/functions' );

describe( 'Distributed Post Tests', () => {
let externalConnectionName = '';

before( () => {
cy.login();
cy.networkActivatePlugin( 'distributor' );
cy.networkActivatePlugin( 'json-basic-authentication' );

externalConnectionName = 'Connection ' + randomName();
cy.createExternalConnection(
externalConnectionName,
'http://localhost/second/wp-json'
);
} );

it( 'Counter should increase after distributing a post', () => {
const postTitle = 'Post to push ' + randomName();

cy.createPost( { title: postTitle } ).then( ( post ) => {
cy.distributorPushPost( post.id, 'second', '', 'publish' );
// Return the the post edit screen.
cy.visit( '/wp-admin/post.php?post=' + post.id + '&action=edit' );
// Ensure the settings panel is open.
cy.get( 'button[aria-label="Settings"]' ).then( ( $settings ) => {
if ( $settings.attr( 'aria-expanded' ) === 'false' ) {
$settings.trigger( 'click' );
}
cy.openDocumentSettingsSidebar( 'Post' );
cy.openDocumentSettingsPanel( 'Distributor' );
cy.get( '#distributed-to' ).should(
'contain.text',
'Distributed to 1 connection'
);
} );

cy.distributorPushPost(
post.id,
externalConnectionName,
'',
'publish'
);
// Return the the post edit screen.
cy.visit( '/wp-admin/post.php?post=' + post.id + '&action=edit' );
// Ensure the settings panel is open.
cy.get( 'button[aria-label="Settings"]' ).then( ( $settings ) => {
if ( $settings.attr( 'aria-expanded' ) === 'false' ) {
$settings.trigger( 'click' );
}
cy.openDocumentSettingsSidebar( 'Post' );
cy.openDocumentSettingsPanel( 'Distributor' );
cy.get( '#distributed-to' ).should(
'contain.text',
'Distributed to 2 connections'
);
} );
} );
} );

it( 'Should display source information in distributed copies of content', () => {
const postTitle = 'Post to push ' + randomName();

cy.createPost( { title: postTitle } ).then( ( sourcePost ) => {
cy.distributorPushPost(
sourcePost.id,
'second',
'',
'publish'
).then( ( distributedPost ) => {
cy.visit( distributedPost.distributedFrontUrl );
cy.get( '#wp-admin-bar-distributor .syndicated-notice' )
.should( 'contain.text', 'This post was distributed from' )
.should( 'contain.text', 'View the origin post.' );
cy.get( 'link[rel=canonical]' ).should(
'have.attr',
'href',
sourcePost.link
);

cy.visit( distributedPost.distributedEditUrl );
cy.closeWelcomeGuide();
cy.get( '.components-notice__content' )
.should( 'contain.text', 'Distributed from' )
.should(
'contain.text',
'This post is linked to the origin post. Edits to the origin post will update this remote version.'
);

// Ensure the settings panel is open.
cy.get( 'button[aria-label="Settings"]' ).then(
( $settings ) => {
if ( $settings.attr( 'aria-expanded' ) === 'false' ) {
$settings.trigger( 'click' );
}
cy.openDocumentSettingsSidebar( 'Post' );
cy.openDocumentSettingsPanel( 'Distributor' );
cy.get( '#distributed-from' ).should(
'contain.text',
'Distributed on'
);
}
);
} );
} );
} );
} );
116 changes: 116 additions & 0 deletions tests/cypress/e2e/editor-blocks.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const { randomName } = require( '../support/functions' );

describe( 'Distributed content block tests', () => {
let externalConnectionOneToTwo, externalConnectionTwoToOne;

before( () => {
cy.login();
cy.networkActivatePlugin( 'distributor' );
cy.networkActivatePlugin( 'json-basic-authentication' );

externalConnectionOneToTwo = 'Site Two ' + randomName();
cy.createExternalConnection(
externalConnectionOneToTwo,
'http://localhost/second/wp-json'
);

externalConnectionTwoToOne = 'Site One ' + randomName();
cy.createExternalConnection(
externalConnectionTwoToOne,
'http://localhost/wp-json',
'admin',
'password',
'second'
);
} );

it( 'Should distribute blocks when pushing to network connections.', () => {
const postTitle = 'Post to push ' + randomName();

cy.createPost( { title: postTitle } ).then( ( sourcePost ) => {
cy.distributorPushPost(
sourcePost.id,
'second',
'',
'publish'
).then( ( distributedPost ) => {
cy.postContains(
distributedPost.distributedPostId,
'<!-- wp:paragraph -->',
'http://localhost/second/'
);
} );
} );
} );

it( 'Should distribute blocks when pulling from network connections.', () => {
const postTitle = 'Post to pull ' + randomName();

cy.createPost( { title: postTitle } ).then( ( sourcePost ) => {
cy.distributorPullPost(
sourcePost.id,
'second',
'',
'localhost'
).then( ( distributedPost ) => {
cy.closeWelcomeGuide();
const matches =
distributedPost.distributedEditUrl.match( /post=(\d+)/ );
let distributedPostId;
if ( matches ) {
distributedPostId = matches[ 1 ];
}
cy.postContains(
distributedPostId,
'<!-- wp:paragraph -->',
'http://localhost/second/'
);
} );
} );
} );

it( 'Should distribute blocks when pushing to external connections.', () => {
const postTitle = 'Post to push ' + randomName();

cy.createPost( { title: postTitle } ).then( ( sourcePost ) => {
cy.distributorPushPost(
sourcePost.id,
externalConnectionOneToTwo,
'',
'publish'
).then( ( distributedPost ) => {
cy.postContains(
distributedPost.distributedPostId,
'<!-- wp:paragraph -->',
'http://localhost/second/'
);
} );
} );
} );

it( 'Should distribute blocks when pulling from external connections.', () => {
const postTitle = 'Post to pull ' + randomName();

cy.createPost( { title: postTitle } ).then( ( sourcePost ) => {
cy.distributorPullPost(
sourcePost.id,
'/second/', // Pull to second site.
'', // From primary site.
externalConnectionTwoToOne
).then( ( distributedPost ) => {
cy.closeWelcomeGuide();
const matches =
distributedPost.distributedEditUrl.match( /post=(\d+)/ );
let distributedPostId;
if ( matches ) {
distributedPostId = matches[ 1 ];
}
cy.postContains(
distributedPostId,
'<!-- wp:paragraph -->',
'http://localhost/second/'
);
} );
} );
} );
} );
19 changes: 19 additions & 0 deletions tests/cypress/e2e/external-connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,23 @@ describe( 'Admin can add a new external connection', () => {
.find( '.connection-status' )
.should( 'have.class', 'error' );
} );

it( 'Should display limited connection warning', () => {
cy.visit( '/wp-admin/admin.php?page=distributor' );
cy.get( '.page-title-action' ).contains( 'Add New' ).click();

const name = randomName();
cy.get( '#title' ).click().type( name );

cy.get( '.manual-setup-button' ).click();
cy.get( '#dt_username' ).type( 'invalid_username' );
cy.get( '#dt_password' ).type( 'invalid_password' );
cy.get( '#dt_external_connection_url' ).type(
'http://localhost/second/wp-json'
);
cy.get( '.description.endpoint-result' ).should(
'contain.text',
'Limited connection established.'
);
} );
} );
4 changes: 4 additions & 0 deletions tests/cypress/e2e/internal-push.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ describe( 'Internal Push', () => {
);

// Set Featured Image
// This test is temporarily disabled due to failures in GitHub actions that are not reproducible locally.
// On GitHub the success message expected within the cy.distributorPushPost command is not found as the
// distribution fails with an undefined error.
Comment on lines +60 to +62
Copy link
Member

Choose a reason for hiding this comment

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

Should we open an issue for this to tackle in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've logged #1076 for follow up.


// cy.uploadMedia( 'assets/img/banner-772x250.png' ).then(
// ( media ) => {
// if ( media && media.mediaId ) {
Expand Down
Loading