forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Protrator e2e tests with Cypress. Move all existing tests to …
…Cypress & add basic Deque Axe integration.
- Loading branch information
Showing
30 changed files
with
925 additions
and
506 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,9 @@ | ||
{ | ||
"integrationFolder": "cypress/integration", | ||
"supportFile": "cypress/support/index.ts", | ||
"videosFolder": "cypress/videos", | ||
"screenshotsFolder": "cypress/screenshots", | ||
"pluginsFile": "cypress/plugins/index.ts", | ||
"fixturesFolder": "cypress/fixtures", | ||
"baseUrl": "http://localhost:4000" | ||
} |
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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
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,37 @@ | ||
describe('Homepage', () => { | ||
beforeEach(() => { | ||
// All tests start with visiting homepage | ||
cy.visit('/'); | ||
}); | ||
|
||
it('should display translated title "DSpace Angular :: Home"', () => { | ||
cy.title().should('eq', 'DSpace Angular :: Home'); | ||
}); | ||
|
||
it('should contain a news section', () => { | ||
cy.get('ds-home-news').should('be.visible'); | ||
}); | ||
|
||
it('should have a working search box', () => { | ||
const queryString = 'test'; | ||
cy.get('ds-search-form input[name="query"]').type(queryString); | ||
cy.get('ds-search-form button.search-button').click(); | ||
cy.url().should('include', '/search'); | ||
cy.url().should('include', 'query=' + encodeURI(queryString)); | ||
}); | ||
|
||
it('should pass accessibility tests', () => { | ||
// first must inject Axe into current page | ||
cy.injectAxe(); | ||
|
||
// Analyze entire page for accessibility issues | ||
// NOTE: this test checks accessibility of header/footer as well | ||
cy.checkA11y({ | ||
exclude: [ | ||
['#klaro'], // Klaro plugin (privacy policy popup) has color contrast issues | ||
['#search-navbar-container'], // search in navbar has duplicative ID. Will be fixed in #1174 | ||
['.dropdownLogin'] // "Log in" link in header has color contrast issues | ||
], | ||
}); | ||
}); | ||
}); |
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,15 @@ | ||
describe('Item Page', () => { | ||
const ITEMPAGE = '/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; | ||
const ENTITYPAGE = '/entities/publication/e98b0f27-5c19-49a0-960d-eb6ad5287067'; | ||
|
||
it('should contain element ds-item-page when navigating to an item page', () => { | ||
cy.visit(ENTITYPAGE); | ||
cy.get('ds-item-page').should('exist'); | ||
}); | ||
|
||
// Test that entities will redirect to /entities/[type]/[uuid] when accessed via /items/[uuid] | ||
it('should redirect to the entity page when navigating to an item page', () => { | ||
cy.visit(ITEMPAGE); | ||
cy.location('pathname').should('eq', ENTITYPAGE); | ||
}); | ||
}); |
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,24 @@ | ||
describe('Item Statistics Page', () => { | ||
const ITEMSTATISTICSPAGE = '/statistics/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; | ||
|
||
it('should contain element ds-item-statistics-page when navigating to an item statistics page', () => { | ||
cy.visit(ITEMSTATISTICSPAGE); | ||
cy.get('ds-item-statistics-page').should('exist'); | ||
cy.get('ds-item-page').should('not.exist'); | ||
}); | ||
|
||
it('should contain the item statistics page url when navigating to an item statistics page', () => { | ||
cy.visit(ITEMSTATISTICSPAGE); | ||
cy.location('pathname').should('eq', ITEMSTATISTICSPAGE); | ||
}); | ||
|
||
it('should contain a "Total visits" section', () => { | ||
cy.visit(ITEMSTATISTICSPAGE); | ||
cy.get('ds-statistics-table h3').contains('Total visits'); | ||
}); | ||
|
||
it('should contain a "Total visits per month" section', () => { | ||
cy.visit(ITEMSTATISTICSPAGE); | ||
cy.get('ds-statistics-table h3').contains('Total visits per month'); | ||
}); | ||
}); |
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,12 @@ | ||
describe('PageNotFound', () => { | ||
it('should contain element ds-pagenotfound when navigating to page that doesnt exist', () => { | ||
cy.visit('/e9019a69-d4f1-4773-b6a3-bd362caa46f2'); | ||
cy.get('ds-pagenotfound').should('exist'); | ||
}); | ||
|
||
it('should not contain element ds-pagenotfound when navigating to existing page', () => { | ||
cy.visit('/home'); | ||
cy.get('ds-pagenotfound').should('not.exist'); | ||
}); | ||
|
||
}); |
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,49 @@ | ||
const page = { | ||
fillOutQueryInNavBar(query) { | ||
// Click the magnifying glass | ||
cy.get('.navbar-container #search-navbar-container form a').click(); | ||
// Fill out a query and click Enter | ||
cy.get('.navbar-container #search-navbar-container form input[name = "query"]').type(query); | ||
}, | ||
submitQueryByPressingEnter() { | ||
cy.get('.navbar-container #search-navbar-container form input[name = "query"]').type('{enter}'); | ||
}, | ||
submitQueryByPressingIcon() { | ||
cy.get('.navbar-container #search-navbar-container form .submit-icon').click(); | ||
} | ||
}; | ||
|
||
describe('Search from Navigation Bar', () => { | ||
// NOTE: these tests currently assume this query will return results! | ||
const query = 'test'; | ||
|
||
it('should go to search page with correct query if submitted (from home)', () => { | ||
cy.visit('/'); | ||
page.fillOutQueryInNavBar(query); | ||
page.submitQueryByPressingEnter(); | ||
// New URL should include query param | ||
cy.url().should('include', 'query=' + query); | ||
// At least one search result should be displayed | ||
cy.get('ds-item-search-result-list-element').should('be.visible'); | ||
}); | ||
|
||
it('should go to search page with correct query if submitted (from search)', () => { | ||
cy.visit('/search'); | ||
page.fillOutQueryInNavBar(query); | ||
page.submitQueryByPressingEnter(); | ||
// New URL should include query param | ||
cy.url().should('include', 'query=' + query); | ||
// At least one search result should be displayed | ||
cy.get('ds-item-search-result-list-element').should('be.visible'); | ||
}); | ||
|
||
it('should allow user to also submit query by clicking icon', () => { | ||
cy.visit('/'); | ||
page.fillOutQueryInNavBar(query); | ||
page.submitQueryByPressingIcon(); | ||
// New URL should include query param | ||
cy.url().should('include', 'query=' + query); | ||
// At least one search result should be displayed | ||
cy.get('ds-item-search-result-list-element').should('be.visible'); | ||
}); | ||
}); |
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,63 @@ | ||
describe('Search Page', () => { | ||
|
||
it('should contain query value when navigating to page with query parameter', () => { | ||
const queryString = 'test query'; | ||
cy.visit('/search?query=' + queryString); | ||
cy.get('#search-form input').should('have.value', queryString); | ||
}); | ||
|
||
|
||
it('should have right scope selected when navigating to page with scope parameter', () => { | ||
// First, visit search with no params just to get the set of the scope options | ||
cy.visit('/search'); | ||
cy.get('#search-form select[name="scope"] > option').as('options'); | ||
|
||
// Find length of scope options, select a random index | ||
cy.get('@options').its('length') | ||
.then(len => Math.floor(Math.random() * Math.floor(len))) | ||
.then((index) => { | ||
// return the option at that (randomly selected) index | ||
return cy.get('@options').eq(index); | ||
}) | ||
.then((option) => { | ||
const randomScope: any = option.val(); | ||
// Visit the search page with the randomly selected option as a pararmeter | ||
cy.visit('/search?scope=' + randomScope); | ||
// Verify that scope is selected when the page reloads | ||
cy.get('#search-form select[name="scope"]').find('option:selected').should('have.value', randomScope); | ||
}); | ||
}); | ||
|
||
|
||
it('should redirect to the correct url when scope was set and submit button was triggered', () => { | ||
// First, visit search with no params just to get the set of scope options | ||
cy.visit('/search'); | ||
cy.get('#search-form select[name="scope"] > option').as('options'); | ||
|
||
// Find length of scope options, select a random index (i.e. a random option in selectbox) | ||
cy.get('@options').its('length') | ||
.then(len => Math.floor(Math.random() * Math.floor(len))) | ||
.then((index) => { | ||
// return the option at that (randomly selected) index | ||
return cy.get('@options').eq(index); | ||
}) | ||
.then((option) => { | ||
const randomScope: any = option.val(); | ||
// Select the option at our random index & click the search button | ||
cy.get('#search-form select[name="scope"]').select(randomScope); | ||
cy.get('#search-form button.search-button').click(); | ||
// Result should be the page URL should include that scope & page will reload with scope selected | ||
cy.url().should('include', 'scope=' + randomScope); | ||
cy.get('#search-form select[name="scope"]').find('option:selected').should('have.value', randomScope); | ||
}); | ||
}); | ||
|
||
it('should redirect to the correct url when query was set and submit button was triggered', () => { | ||
const queryString = 'Another interesting query string'; | ||
cy.visit('/search'); | ||
cy.get('#search-form input[name="query"]').type(queryString); | ||
cy.get('#search-form button.search-button').click(); | ||
cy.url().should('include', 'query=' + encodeURI(queryString)); | ||
}); | ||
|
||
}); |
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,5 @@ | ||
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress | ||
// For more info, visit https://on.cypress.io/plugins-api | ||
/* tslint:disable:no-empty */ | ||
module.exports = (on, config) => { }; | ||
/* tslint:enable:no-empty */ |
Oops, something went wrong.