-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
2,537 additions
and
1,141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
|
||
|
@@ -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'); | ||
|
||
|
@@ -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'); | ||
|
@@ -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); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.