Skip to content

Commit

Permalink
Merge branch 'e2e/55-default-admin-settings' of github.com:10up/restr…
Browse files Browse the repository at this point in the history
…icted-site-access into e2e/55-default-admin-settings
  • Loading branch information
Sidsector9 committed Oct 18, 2021
2 parents 3e874b7 + 3caa574 commit 53f37a1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: E2E Tests

on:
push:
branches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe( 'Plugin admin settings are properly interactive.', () => {
.should( 'not.be.visible' );
} );

it ( 'Select "Site visibility: no robots" radio button', function() {
it ( 'Select "Site visibility: blog restrcited" radio button', function() {
cy
.get( '#blog-restricted' )
.check();
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/integration/rsa-redirect-to-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe( 'Send restricted visitors to login page', () => {
cy.visitAdminPage( 'options-reading.php' );
cy.get( '#blog-restricted' ).check();
cy.get( '#rsa-send-to-login' ).check();
cy.saveRsaSettings();
cy.saveSettings();
cy.logout();
} );

Expand Down
9 changes: 6 additions & 3 deletions tests/cypress/integration/rsa-redirect-to-web-address.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
describe( 'Send restricted visitors to a web address', () => {
before( () => {
cy.setPermalink();
cy.saveSettings();
cy.visitAdminPage( 'options-reading.php' );
cy.get( '#blog-restricted' ).check();
cy.get( '#rsa-redirect-visitor' ).check();
Expand All @@ -8,7 +10,8 @@ describe( 'Send restricted visitors to a web address', () => {
.get( 'input[name="rsa_options[redirect_url]"]' )
.clear()
.type( `${ Cypress.config().baseUrl }non-existent-page` )
cy.saveRsaSettings();
cy.saveSettings();

cy.logout();
} );

Expand Down Expand Up @@ -43,12 +46,12 @@ function testRedirectStatusCode( $status_code = 301 ) {
cy
.get( '.rsa-setting_settings_field_redirect_code #redirect_code' )
.select( `${ $status_code }` );
cy.saveRsaSettings();
cy.saveSettings();
cy.logout();

cy.request({
method: 'GET',
url: 'http://osp.local/',
url: Cypress.config().baseUrl,
failOnStatusCode: false,
followRedirect: false
} ).then( ( response ) => {
Expand Down
6 changes: 3 additions & 3 deletions tests/cypress/integration/rsa-redirection-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe( 'Admin can correctly save redirection settings', () => {
.type( `${ Cypress.config().baseUrl }non-existent-page` )
.should( 'have.value', `${ Cypress.config().baseUrl }non-existent-page` );

cy.saveRsaSettings();
cy.saveSettings();
} );

it( 'Can check "Redirect to same path" checkbox', () => {
Expand All @@ -21,7 +21,7 @@ describe( 'Admin can correctly save redirection settings', () => {
.check()
.should( 'be.checked' );

cy.saveRsaSettings();
cy.saveSettings();
} );

it( 'Can select any of the "Redirection status code" options', () => {
Expand All @@ -34,7 +34,7 @@ describe( 'Admin can correctly save redirection settings', () => {
.select( '307' )
.should( 'have.value', '307' );

cy.saveRsaSettings();
cy.saveSettings();
} );

it( 'Verify all settings are correctly saved', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/integration/rsa-simple-message-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe( 'Admin can correctly save redirection settings', () => {
.get( '#rsa_message' )
.should( 'have.value', '<strong>This is a restricted site. Please contact the admin.</strong>' );

cy.saveRsaSettings();
cy.saveSettings();
} );

it( 'Verify all settings are correctly saved', () => {
Expand Down
10 changes: 9 additions & 1 deletion tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Cypress.Commands.add( 'openDocumentSettingsPanel', ( name ) => {
} );
} );

Cypress.Commands.add( 'saveRsaSettings', () => {
Cypress.Commands.add( 'saveSettings', () => {
cy
.get( '#submit' )
.click();
Expand All @@ -96,3 +96,11 @@ Cypress.Commands.add( 'logout', () => {
cy.visit( href );
} );
} );

Cypress.Commands.add( 'setPermalink', () => {
cy.visitAdminPage( 'options-permalink.php' );
cy
.get( 'form[action="options-permalink.php"] input[type="radio"]' )
.eq(4)
.check();
} );

0 comments on commit 53f37a1

Please sign in to comment.