Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjmaclean committed Jan 22, 2020
2 parents 0e0fa88 + 28bbc8d commit faf6b6f
Show file tree
Hide file tree
Showing 80 changed files with 2,537 additions and 1,141 deletions.
6 changes: 5 additions & 1 deletion cypress/integration/dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ context('metis-ui', () => {
cy.visit('/dashboard');
});

const expectedRowCount = 5;
const expectedRowCount = 2;
const expectedHeaderCount = 5;

it('should show the search form', () => {
cy.get('.search-form').should('have.length', 1);
});

it('should show the welcome message', () => {
cy.get('.metis-welcome-message').contains('Welcome');
});
Expand Down
4 changes: 4 additions & 0 deletions cypress/integration/dataset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ context('metis-ui', () => {
const expectedId = '0';
const lastPublished = '19/02/2019 - 08:49';

it('should show the search form', () => {
cy.get('.search-form').should('have.length', 1);
});

it('should show the dataset, general info, status, history', () => {
cy.get('.dataset-name').contains('Dataset 1');

Expand Down
8 changes: 8 additions & 0 deletions cypress/integration/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ context('metis-ui', () => {
cy.visit('/home');
});

it('should not show the search form', () => {
cy.get('.search-form').should('have.length', 0);
});

it('should show the home screen and have a signin button', () => {
cy.get('h2').contains('What can you do with Metis?');

Expand All @@ -35,6 +39,10 @@ context('metis-ui', () => {
cy.visit('/home');
});

it('should show the search form', () => {
cy.get('.search-form').should('have.length', 1);
});

it('should show the dashboard screen and have a dashboard and signout button', () => {
cy.get('.metis-welcome-message').contains('Welcome Valentine');

Expand Down
44 changes: 44 additions & 0 deletions cypress/integration/search-results.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { checkAHref, setupUser } from '../support/helpers';

context('metis-ui', () => {
describe('search results', () => {
const expectedRowCount = 2;
const expectedRowCountMoreLoaded = 3;
const expectedHeaderCount = 5;

beforeEach(() => {
cy.server();
setupUser();
cy.visit('/search');
});

it('should show the search form', () => {
cy.get('.search-form').should('have.length', 1);
cy.get('.search-string').should('have.length', 1);
cy.get('.search').should('have.length', 1);
});

it('should show the reults', () => {
cy.get('.grid-cell').should('have.length', 0);
cy.get('.search-string').type('set');
cy.get('.search').click();
cy.get('.grid-cell').should('have.length', expectedHeaderCount * expectedRowCount);
});

it('should load more reults', () => {
cy.get('.grid-cell').should('have.length', 0);
cy.get('.search-string').type('set');
cy.get('.search').click();
cy.get('.grid-cell').should('have.length', expectedHeaderCount * expectedRowCount);
cy.get('.load-more-btn').click();
cy.get('.grid-cell').should('have.length', expectedHeaderCount * expectedRowCountMoreLoaded);
});

it('should link result items to dataset pages', () => {
cy.get('.search-string').type('set');
cy.get('.search').click();
cy.wait(10);
checkAHref(cy.get(`.grid-cell:nth-child(${expectedHeaderCount + 1}) a`), '/dataset/edit/0');
});
});
});
68 changes: 36 additions & 32 deletions cypress/integration/signin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { cleanupUser } from '../support/helpers';
import { user } from '../fixtures';

context('metis-ui', () => {
const fillLoginFieldsAndSubmit = (submit = true) => {
cy.get('#email')
.clear()
.type('[email protected]');
cy.get('#password')
.clear()
.type('x');
if (submit) {
cy.get('.login-btn').click();
}
};

describe('signin', () => {
beforeEach(() => {
cy.server();
afterEach(() => {
cleanupUser();
});

before(() => {
beforeEach(() => {
cy.server();
cy.visit('/signin');
});

Expand All @@ -17,8 +31,8 @@ context('metis-ui', () => {
.blur();
cy.get('#password')
.clear()
.type('x')
.blur();
.type('x');

cy.get('.error-message').contains('Please enter a valid email address');
cy.get('.login-btn').should('be.disabled');

Expand All @@ -37,18 +51,12 @@ context('metis-ui', () => {
});

it('should validate the password', () => {
cy.get('#email')
.clear()
.type('[email protected]')
.blur();
fillLoginFieldsAndSubmit(false);
cy.get('#password')
.clear()
.type('x')
.clear()
.blur();
cy.get('.error-message').contains('Please enter a valid password');
cy.get('.login-btn').should('be.disabled');

cy.get('#password')
.clear()
.type('x');
Expand All @@ -63,34 +71,30 @@ context('metis-ui', () => {
status: 401,
response: { errorMessage: 'Oops!' }
});

cy.get('#email')
.clear()
.type('[email protected]')
.blur();
cy.get('#password')
.clear()
.type('x')
.blur();
cy.get('.login-btn').click();

fillLoginFieldsAndSubmit();
cy.get('.error-notification').contains('401 Oops!');
});

it('should login', () => {
cy.route('POST', '/authentication/login', user);
fillLoginFieldsAndSubmit();
cy.url().should('contain', '/dashboard');
});

cy.get('#email')
.clear()
.type('[email protected]')
.blur();
cy.get('#password')
.clear()
.type('x')
.blur();
it('should show the search form when logged in', () => {
cy.route('POST', '/authentication/login', user);
fillLoginFieldsAndSubmit(false);
cy.get('.search-form').should('have.length', 0);
cy.get('.login-btn').click();
cy.get('.search-form').should('have.length', 1);
});

cy.url().should('contain', '/dashboard');
it('should redirect to the originally requested url after a successful login', () => {
const destinationUrl = '/dataset/edit/2';
cy.visit(destinationUrl);
cy.url().should('contain', '/signin');
fillLoginFieldsAndSubmit();
cy.url().should('contain', destinationUrl);
});
});
});
Loading

0 comments on commit faf6b6f

Please sign in to comment.