Skip to content

Commit

Permalink
Merge pull request #3355 from bolt/working-on-cypress-tests
Browse files Browse the repository at this point in the history
Working on cypress tests
  • Loading branch information
bobdenotter authored Nov 18, 2022
2 parents 22d37af + ab49b25 commit c35cb54
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 243 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference types="cypress" />

describe('Edit content as chief editor and editor without being the owner', () => {
it('checks that the chief editor and editor can edit someone else\'s content', () => {
cy.login('jane_chief', 'jane%1');

cy.visit('/bolt/content/pages');

cy.get('.listing__row.is-normal').eq(0).children('.listing__row--item.is-actions.edit-actions').children('div').children('a[href="/bolt/edit/2"]').click();
cy.url().should('contain', '/bolt/edit/2');

cy.get('#field-heading').invoke('val').should('contain', 'This is a page');
cy.get('#field-heading').clear();
cy.get('#field-heading').type('This is an edited page');

cy.get('button[name="save"]').eq(1).scrollIntoView();
cy.get('button[name="save"]').eq(1).click();

cy.get('#field-heading').invoke('val').should('contain', 'This is an edited page');
cy.visit('bolt/logout');

cy.login('john_editor', 'john%1');

cy.visit('/bolt/content/pages');

cy.get('.listing__row.is-normal').eq(0).children('.listing__row--item.is-actions.edit-actions').children('div').children('a[href="/bolt/edit/2"]').click();
cy.url().should('contain', '/bolt/edit/2');

cy.get('#field-heading').invoke('val').should('contain', 'This is an edited page');
cy.get('#field-heading').clear();
cy.get('#field-heading').type('This is a page');

cy.get('button[name="save"]').eq(1).scrollIntoView();
cy.get('button[name="save"]').eq(1).click();

cy.get('#field-heading').invoke('val').should('contain', 'This is a page');
cy.visit('bolt/logout');
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference types="cypress" />

describe('Create content as editor and delete it as chief editor', () => {
it('checks that editors can create content and chief editors can delete it', () => {
cy.login('john_editor', 'john%1');

cy.visit('/bolt/content/pages');

cy.get('.card.mb-3').children('.card-body').children('p').children('a').click();
cy.url().should('contain', '/bolt/new/pages');

cy.get('#field-heading').type('Test heading');

cy.get('button[name="save"]').eq(1).scrollIntoView();
cy.get('button[name="save"]').eq(1).should('be.visible').click({force:true});

cy.visit('/bolt/logout');

cy.login('jane_chief', 'jane%1');

cy.visit('/bolt/content/pages?page=3');

cy.get('.listing__row.is-normal').eq(2).children('.listing__row--item.is-details').children('a').should('contain', 'Test heading -');
cy.get('button[data-bs-toggle="dropdown"]').eq(3).click();
cy.get('.edit-actions__dropdown.dropdown-menu.dropdown-menu-right').eq(2).children('a').eq(4).click();
cy.get('button[data-bs-dismiss="modal"]').click({ multiple: true });

cy.visit('/bolt/content/pages?page=3');
cy.get('.listing--container').its('length').should('eq', 3);
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/// <reference types="cypress" />

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');
cy.get('a[id="media-tab"]').click();

cy.get('input[name="fields[embed][url]"]').clear();
cy.get('input[name="fields[embed][url]"').type('https://www.youtube.com/watch?v=x4IDM3ltTYo');
cy.wait(2000);
cy.get('button[class="btn btn-tertiary refresh"]').should('be.enabled');

cy.get('input[name="fields[embed][title]"]').should('have.value', 'Silversun Pickups - Nightlight (Official Video)');
cy.get('input[name="fields[embed][authorname]"]').should('have.value', 'Silversun Pickups');
cy.get('input[name="fields[embed][width]"]').should('have.value', '200');
cy.get('input[name="fields[embed][height]"]').should('have.value', '113');

cy.get('.editor__embed .remove').click();
cy.get('input[name="fields[embed][title]"]').should('have.value', '');
cy.get('input[name="fields[embed][authorname]"]').should('have.value', '');
cy.get('input[name="fields[embed][width]"]').should('have.value', '');
cy.get('input[name="fields[embed][height]"]').should('have.value', '');
})

it('checks if an admin can see the infobox field', () => {
cy.login();
cy.visit('/bolt/edit/38');

cy.get("label[for='field-email']").should('exist');
cy.get("label[for='field-email']").find('i').its('length').should('eq', 1);

cy.get('label[for="field-email"]').scrollIntoView();
cy.get("label[for='field-email'] > i").trigger('mouseover');
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');
})

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('.form-control').eq(10).should('not.equal', '');
cy.get('.form-control').eq(11).should('not.equal', '');

cy.get('button[class="btn btn-sm btn-hidden-danger"]').should('contain', 'Remove').eq(0).click();
cy.get('input[name="fields[image][filename]"]').should('be.empty');
cy.get('input[name="fields[image][alt]"]').should('be.empty');
})
});
Original file line number Diff line number Diff line change
@@ -1,56 +1,5 @@
/// <reference types="cypress" />

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');
cy.get('a[id="media-tab"]').click();

cy.get('input[name="fields[embed][url]"]').clear();
cy.get('input[name="fields[embed][url]"').type('https://www.youtube.com/watch?v=x4IDM3ltTYo');
cy.wait(2000);
cy.get('button[class="btn btn-tertiary refresh"]').should('be.enabled');

cy.get('input[name="fields[embed][title]"]').should('have.value', 'Silversun Pickups - Nightlight (Official Video)');
cy.get('input[name="fields[embed][authorname]"]').should('have.value', 'Silversun Pickups');
cy.get('input[name="fields[embed][width]"]').should('have.value', '200');
cy.get('input[name="fields[embed][height]"]').should('have.value', '113');

cy.get('.editor__embed .remove').click();
cy.get('input[name="fields[embed][title]"]').should('have.value', '');
cy.get('input[name="fields[embed][authorname]"]').should('have.value', '');
cy.get('input[name="fields[embed][width]"]').should('have.value', '');
cy.get('input[name="fields[embed][height]"]').should('have.value', '');
})

it('checks if an admin can see the infobox field', () => {
cy.login();
cy.visit('/bolt/edit/38');

cy.get("label[for='field-email']").should('exist');
cy.get("label[for='field-email']").find('i').its('length').should('eq', 1);

cy.get('label[for="field-email"]').scrollIntoView();
cy.get("label[for='field-email'] > i").trigger('mouseover');
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');
})

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('.form-control').eq(10).should('not.equal', '');
cy.get('.form-control').eq(11).should('not.equal', '');

cy.get('button[class="btn btn-sm btn-hidden-danger"]').should('contain', 'Remove').eq(0).click();
cy.get('input[name="fields[image][filename]"]').should('be.empty');
cy.get('input[name="fields[image][alt]"]').should('be.empty');
})
});

describe('As an Admin I want to be able to make use of the date & datetime fields', () => {
before(() => {
// First, switch an account to a locale which isn't using an AM/PM system (french for example)
Expand Down
105 changes: 0 additions & 105 deletions tests/cypress/integration-temporary-disabled/record_listing.spec.bak

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="cypress" />

describe('As an Admin I want to use record listing', () => {
it('checks that an admin can navigate over the record listing', () => {
cy.login();
cy.get('a[rel=next]').scrollIntoView();
cy.get('a[rel=next]').click();
cy.get('#listing .listing__row .is-details a').should('exist');
})
});
Loading

0 comments on commit c35cb54

Please sign in to comment.