-
Notifications
You must be signed in to change notification settings - Fork 156
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
Changes from all commits
ab9dae1
9f6e8eb
ddf1c4c
36d1c76
cc2964f
e682df3
8ca7479
6da6ddc
ff4f5d5
fc08bb5
c227b5c
cf33631
9e18863
919a05c
f49db81
0070301
5102ac9
9a9d54d
3156948
b0c83a2
e5dfb73
e80b43b
f04b81a
3747002
fb6ce52
70707ee
5ab2732
ab21a4d
ee34a80
786315d
98aad74
85ab03f
d5b31c1
a87fa68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
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' | ||
); | ||
} | ||
); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
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/' | ||
); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we open an issue for this to tackle in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ) { | ||
|
There was a problem hiding this comment.
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.