Skip to content

Commit

Permalink
Merge pull request #2968 from bolt/tests/make-cypress-cleaner
Browse files Browse the repository at this point in the history
Remove some of the describe from Cypress / Fix some common Cypress errors
  • Loading branch information
bobdenotter authored Nov 29, 2021
2 parents fbd72ad + 6620771 commit dcfd7db
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 154 deletions.
6 changes: 2 additions & 4 deletions tests/cypress/integration/bulk_actions.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an admin I want to select all items on a contentlisting page', () => {
describe('As an admin I should be able to run bulk actions', () => {
it('checks if an admin can see all items', () => {
cy.login();
cy.visit('/bolt/content/pages');
Expand All @@ -12,10 +12,8 @@ describe('As an admin I want to select all items on a contentlisting page', () =
cy.get('.admin__body--aside .card-body .multiselect').should('contain', 'Select option');
cy.get('button[name="bulk-action"]').should('be.disabled');
})
});

describe('As an Admin I want to change the status of several tests at once', () => {
it('checks if an admin can make multiple changes', () => {
it('checks if an admin can make multiple changes at once', () => {
cy.login();
cy.visit('/bolt/content/tests');
cy.get(".listing__filter .custom-checkbox").click();
Expand Down
10 changes: 2 additions & 8 deletions tests/cypress/integration/display_record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,21 @@ describe('As a user I want to display a single record', () => {
cy.get('.title').should('have.length', 1);
cy.get('.edit-link').should('not.exist');
})
});

describe('As an admin I want to see edit link on single record page', () => {
it('checks if an admin can edit a record', () => {
cy.login();
cy.visit('/entry/this-is-a-record-in-the-entries-contenttype');
cy.get('.title').should('have.length', 1);
cy.get('.edit-link').should('contain', 'Edit');
})
});

describe('As a user I want to see the difference between records with a "Title" and a "Heading"', () => {
it('checks if heading replaces title', () => {
it('checks if you can see the difference between records with a Title and a Heading', () => {
cy.visit('/page/2');
cy.get('.heading').should('have.length', 1);
cy.get('.title').should('not.exist');
})
});

describe('As a user I want to see the correct canonical URL for a page', () => {
it('checks for correct URL', () => {
it('checks for correct canonical URL', () => {
cy.visit('/page/this-is-a-page');
cy.get("link[rel='canonical']").should('have.attr', 'href', Cypress.config().baseUrl + '/page/this-is-a-page');

Expand Down
7 changes: 1 addition & 6 deletions tests/cypress/integration/display_record_test.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/// <reference types="cypress" />


describe('As a user I want to see how the record title is displayed', () => {
describe('As a user I want to see how the record is displayed', () => {
it('checks that the record title is displayed as a user', () => {
cy.visit('/test/title-of-the-test');
cy.get('.title').should('have.length', 1);
cy.get('.title').should('contain', '74: Title of the test');
})
});

describe('As a user I want to see how fields are escaped', () => {
it('checks that fields are escaped as a user', () => {
cy.visit('/test/title-of-the-test');
cy.get('.title').should('have.length', 1);
Expand All @@ -29,9 +26,7 @@ describe('As a user I want to see how fields are escaped', () => {
cy.get('div.box.text_sanitise_a').should('not.contain', 'Text field with <strong>markup</strong>, including . The end.');
cy.get('div.box.text_sanitise_b').should('not.contain', 'Text field with <strong>markup</strong>, including <script>console.log(\'hoi\')</script>. The end.');
})
});

describe('As a user I want to see how file fields are displayed', () => {
it('checks that file fields are displayed as a user', () => {
cy.visit('/test/title-of-the-test');
cy.get('.title').should('have.length', 1);
Expand Down
4 changes: 1 addition & 3 deletions tests/cypress/integration/display_taxonomies.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/// <reference types="cypress" />

describe('As a user I want to see taxonomies on a single record', () => {
describe('As a user I want to see taxonomies in records and listings', () => {
it('checks if there are taxonomies on a record', () => {
cy.visit('/entry/this-is-a-record-in-the-entries-contenttype');
cy.get('.title').should('have.length', 1);
cy.get('.taxonomy-categories').its('length').should('eq', 2);
cy.get('.taxonomy-tags').its('length').should('eq', 4);
})
});

describe('As an admin I want to see a listing of a taxonomy', () => {
it('checks if there is a listing of a taxonomy', () => {
cy.login();
cy.visit('/entry/this-is-a-record-in-the-entries-contenttype');
Expand Down
4 changes: 1 addition & 3 deletions tests/cypress/integration/edit_record_1_change_title.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to change title of a record', () => {
describe('As an Admin I want to change the title and the locale of a record', () => {
it("checks if an admin can change a record's title", () => {
cy.login();
cy.visit('/bolt/edit/30');
Expand All @@ -15,9 +15,7 @@ describe('As an Admin I want to change title of a record', () => {
cy.wait(1000);
cy.get('input[id="field-title"]').should('have.value', 'Changed title');
})
});

describe('As an Admin I want to change title of a record in another language', () => {
it("checks if an admin can change a record's title in another language", () => {
cy.login();
cy.visit('/bolt/edit/1');
Expand Down
6 changes: 1 addition & 5 deletions tests/cypress/integration/edit_record_1_content.spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
/// <reference types="cypress" />

describe('As an Admin I want to see separated content (separator)', () => {
describe('As an Admin I want to see separators, placeholders and default values', () => {
it('checks if an admin can see separated content (separator)', () => {
cy.login();
cy.visit('/bolt/edit/43');
cy.get('#field--field-html').find('hr').its('length').should('eq', 1);
})
});

describe('As an Admin I want to see placeholder on new content', () => {
it('checks if an admin can see placeholder on new content', () => {
cy.login();
cy.visit('/bolt/new/showcases');
cy.get('input[name="fields[title]"]').should('have.attr', 'placeholder').and('match', /Placeholder for the title/);
})
});

describe('As an Admin, I want to see default values on new content', () => {
it('checks if an admin can see default values', () => {
cy.login();
cy.visit('/bolt');
Expand Down
14 changes: 5 additions & 9 deletions tests/cypress/integration/edit_record_1_field.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to be able to make use of the embed field', () => {
describe('As an Admin I want to be able to make use of the embed, infobox and image fields', () => {
it('checks if an admin can use the embed field', () => {
cy.login();
cy.visit('/bolt/edit/44');
Expand All @@ -22,9 +22,7 @@ describe('As an Admin I want to be able to make use of the embed field', () => {
cy.get('input[name="fields[embed][width]"]').should('have.value', '');
cy.get('input[name="fields[embed][height]"]').should('have.value', '');
})
});

describe('As an Admin I want to see the field infobox', () => {
it('checks if an admin can see the infobox field', () => {
cy.login();
cy.visit('/bolt/edit/38');
Expand All @@ -37,20 +35,18 @@ describe('As an Admin I want to see the field infobox', () => {
cy.get('.popover-header').should('contain', 'Email').should('be.visible');
cy.get('.popover-body').should('contain', 'This is an info box shown as a popover next to the field label.').should('be.visible');
})
});

describe('As an Admin, I want to reset an image field', () => {
it('checks if an admin can reset an image field', () => {
cy.login();
cy.visit('/bolt/edit/40');
cy.get('a[id="media-tab"]').click();

cy.get("label[for=field-image]").should('contain', 'Image');
cy.get('input[name="fields[image][filename]"]').should('have.value', 'foal.jpg');
cy.get('input[name="fields[image][alt]"]').should('have.value', 'Ex veniam repellat ipsam autem delectus.');
cy.get('input[name="fields[image][filename]"]').should('not.be.empty');
cy.get('input[name="fields[image][alt]"]').should('not.be.empty');

cy.get('button[class="btn btn-sm btn-hidden-danger"]').should('contain', 'Remove').eq(0).click();
cy.get('input[name="fields[image][filename]"]').should('have.value', '');
cy.get('input[name="fields[image][alt]"]').should('have.value', '');
cy.get('input[name="fields[image][filename]"]').should('be.empty');
cy.get('input[name="fields[image][alt]"]').should('be.empty');
})
});
4 changes: 1 addition & 3 deletions tests/cypress/integration/edit_record_1_fill_list.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to fill in an imagelist', () => {
describe('As an Admin I want to fill in an imagelist and filelist', () => {
it('checks if an admin can fill in an imagelist', () => {
cy.login();
cy.visit('/bolt/edit/42');
Expand Down Expand Up @@ -55,9 +55,7 @@ describe('As an Admin I want to fill in an imagelist', () => {
cy.get('.editor__imagelist').find('div[class="form-fieldsgroup"]').its('length').should('eq', 4);
cy.url().should('contain', '/bolt/edit/42?edit_locale=en#media');
})
});

describe('As an Admin I want to fill in a filelist', () => {
it('checks if an admin can fill in an filelist', () => {
cy.login();
cy.visit('/bolt/edit/42');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to fill in a Set', () => {
describe('As an Admin I want to fill in a Set and an Collection', () => {
it('checks if an admin can fill in a set', () => {
cy.login();
cy.visit('/bolt/edit/43');
Expand All @@ -27,9 +27,7 @@ describe('As an Admin I want to fill in a Set', () => {
cy.get('textarea[name="sets[set][textarea]"]').should('have.value', 'Bar');

})
});

describe('As an Admin I want to fill in a Collection', () => {
it('checks if an admin can fill in a collection', () => {
cy.login();
cy.visit('/bolt/edit/43');
Expand Down
4 changes: 1 addition & 3 deletions tests/cypress/integration/edit_record_2.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to view saved changes of a record', () => {
describe('As an Admin I want to view saved changes of a record or preview these', () => {
it('checks if an admin can view saved changes on a record', () => {
cy.login();
cy.visit('/bolt/edit/2');
Expand All @@ -23,9 +23,7 @@ describe('As an Admin I want to view saved changes of a record', () => {
cy.get('h1').should('not.contain', 'This is the title in the wrong locale');
cy.get('h1').should('contain', 'This is the title in the right locale');
})
});

describe('As an Admin I want to preview an edited record', () => {
it('checks if an admin can preview an edited record', () => {
cy.login();
cy.visit('/bolt/edit/30');
Expand Down
43 changes: 19 additions & 24 deletions tests/cypress/integration/edit_users.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('Edit user successfully', () => {
describe('Edit user successfully, Edit users incorrectly', () => {
it('checks that an admin can edit users', () => {
cy.login();
cy.visit('/bolt/users');
Expand All @@ -23,9 +23,25 @@ describe('Edit user successfully', () => {
cy.url().should('contain', 'bolt/users');
cy.get('table:nth-child(1) > tbody > tr:nth-child(6)').children('td').eq(1).should('contain', 'Tom Doe CHANGED');
})
});

describe('Edit user with incorrect display name, password and email', () => {
it('checks that a user can change their display name', () => {
cy.visit('/bolt/login');
cy.get('input[name="login[username]"]').type('jane_chief');
cy.get('input[name="login[password]"]').type('jane%1' + '{enter}');
cy.visit('/bolt/profile-edit')

cy.get('#user_displayName').clear();
cy.get('#user_displayName').type('Administrator');
cy.get('#editcontent > button').scrollIntoView();
cy.get('#editcontent > button').click();

cy.wait(500);

cy.get('div[class="toast fade show"]').children('.toast-body').should('contain', 'User Profile has been updated!')
cy.get('#user_displayName').invoke('val').should('contain', 'Administrator');
cy.visit('/bolt/logout');
})

it('checks that an admin can\'t edit a user with incorrect details', () => {
cy.login();
cy.visit('/bolt/user-edit/2');
Expand All @@ -45,9 +61,7 @@ describe('Edit user with incorrect display name, password and email', () => {
cy.get('.field-error').eq(2).children('.help-block').children('.list-unstyled').children('li').should('contain', 'Invalid email');
cy.get('.form-group').eq(2).children('div').eq(1).should('contain', 'Suggested secure password');
})
});

describe('Edit my user with incorrect display name', () => {
it('checks that a user can\'t edit their profile with an incorrect display name', () => {
cy.visit('/bolt/login');
cy.get('input[name="login[username]"]').type('jane_chief');
Expand All @@ -72,24 +86,5 @@ describe('Edit my user with incorrect display name', () => {
cy.get('.field-error').eq(0).children('.help-block').children('.list-unstyled').children('li').should('contain', 'Invalid display name');
cy.visit('/bolt/logout')
})
});

describe('Edit my user to change display name', () => {
it('checks that a user can change their display name', () => {
cy.visit('/bolt/login');
cy.get('input[name="login[username]"]').type('jane_chief');
cy.get('input[name="login[password]"]').type('jane%1' + '{enter}');
cy.visit('/bolt/profile-edit')

cy.get('#user_displayName').clear();
cy.get('#user_displayName').type('Administrator');
cy.get('#editcontent > button').scrollIntoView();
cy.get('#editcontent > button').click();

cy.wait(500);

cy.get('div[class="toast fade show"]').children('.toast-body').should('contain', 'User Profile has been updated!')
cy.get('#user_displayName').invoke('val').should('contain', 'Administrator');
cy.visit('/bolt/logout');
})
});
6 changes: 1 addition & 5 deletions tests/cypress/integration/editor_permissions.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/// <reference types="cypress" />

describe('As an editor I should not be able to access Configuration', () => {
describe('Check all editors privileges', () => {
it('checks if an editor can access Configuration', () => {
cy.login('john_editor', 'john%1');
cy.url().should('contain', '/bolt/');
cy.get('ul[class="admin__sidebar--menu"]').find('li').find('a[href="/bolt/menu/configuration"]').should('not.exist');
})
});

describe('As an editor I should only be able to view the About Bolt maintenance page', () => {
it('checks if an editor can access maintenance pages besides About Bolt', () => {
cy.login('john_editor', 'john%1');
cy.url().should('contain', '/bolt/');
Expand Down Expand Up @@ -42,9 +40,7 @@ describe('As an editor I should only be able to view the About Bolt maintenance
cy.url().should('contain', '/bolt/');
cy.url().should('not.contain', '/bolt/kitchensink');
})
});

describe('As an editor I should only be able to view uploaded files', () => {
it('checks if an editor can access files', () => {
cy.visit('/bolt/login');
cy.login('john_editor', 'john%1');
Expand Down
10 changes: 1 addition & 9 deletions tests/cypress/integration/filemanager.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

describe('As an Admin I want to see the files in the "Files" section', () => {
describe('As an Admin I am able to use the files section', () => {
it('checks if an admin can see the files in the Files section', () => {
cy.login();
cy.visit('/bolt/filemanager/themes');
Expand All @@ -10,9 +10,7 @@ describe('As an Admin I want to see the files in the "Files" section', () => {
cy.visit('/bolt/filemanager/files');
cy.get('.path').should('contain', 'Path: files/');
})
});

describe('As an Admin I want to delete a file from the "Files" section', () => {
it('checks if an admin can delete files in the Files section', () => {
cy.login();
cy.visit('/bolt/filemanager/files');
Expand All @@ -28,9 +26,7 @@ describe('As an Admin I want to delete a file from the "Files" section', () => {
cy.get('.toast-body').should('contain', 'File deleted successfully');
cy.get('#files-list tr').should('not.contain', '_b-penguin.jpeg');
})
});

describe('As an Admin I want accidentally click delete file and want to cancel', () => {
it('checks if an admin can cancel deleting files in the Files section', () => {
cy.login();
cy.visit('/bolt/filemanager/files');
Expand All @@ -46,9 +42,7 @@ describe('As an Admin I want accidentally click delete file and want to cancel',
cy.get('.toast-body').should('not.exist');
cy.get('#files-list tr').should('contain', '_a-sunrise.jpeg');
})
});

describe('As an Admin I want to duplicate a file', () => {
it('checks if an admin can duplicate files in the Files section', () => {
cy.login();
cy.visit('/bolt/filemanager/files');
Expand Down Expand Up @@ -81,9 +75,7 @@ describe('As an Admin I want to duplicate a file', () => {
cy.get('.modal-dialog').should('have.length', 1);
cy.get('button[class="btn btn-primary bootbox-accept"]').click();
})
});

describe('As an admin I want to create and delete a folder', () => {
it('checks if an admin can create and delete folders in the Files section', () => {
cy.login();
cy.visit('/bolt/filemanager/files');
Expand Down
4 changes: 1 addition & 3 deletions tests/cypress/integration/frontend_menu.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
/// <reference types="cypress" />

describe('As a user I want to see the menu in the frontend', () => {
describe('As a user I want to see the menu\'s in the frontend', () => {
it('checks if the frontend menu exists', () => {
cy.visit(Cypress.config().baseUrl);
cy.get('.menu .first').should('contain', 'Home');
cy.get('.menu .bolt-site').should('contain', 'The Bolt site');
cy.get('.has-submenu li').its('length').should('eq', 4);
})
});

describe('As a user I want to see the multi-level in the frontend', () => {
it('checks if the multi-level frontend menu exists', () => {
cy.visit('/test/title-of-the-test');
cy.get('.menu .item-1').should('contain', 'Item 1');
Expand Down
Loading

0 comments on commit dcfd7db

Please sign in to comment.