-
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.
tests(e2e): organisations page (all but pagination done)
- Loading branch information
Showing
3 changed files
with
227 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
import 'cypress-real-events' | ||
import { find } from 'cypress/types/lodash' | ||
import { transformExtent } from 'ol/proj' | ||
|
||
describe('organisations', () => { | ||
beforeEach(() => { | ||
cy.visit('/home/organisations') | ||
cy.viewport(1700, 1200) | ||
}) | ||
|
||
describe('general display', () => { | ||
it('should select the right tab', () => { | ||
cy.get('datahub-navigation-menu') | ||
.find('button') | ||
.eq(2) | ||
.invoke('attr', 'ng-reflect-ng-class') | ||
.should('eq', 'decoration-primary') | ||
}) | ||
it('should display the welcome panel', () => { | ||
cy.get('gn-ui-organisations-sort') | ||
cy.get('gn-ui-organisations-sort') | ||
.find('p') | ||
.its('text') | ||
.should('have.length.greaterThan', 0) | ||
cy.get('gn-ui-organisations-sort') | ||
.find('gn-ui-dropdown-selector') | ||
.find('select') | ||
.children('option') | ||
.should('have.length', 4) | ||
}) | ||
it('should display a list of organisations', () => { | ||
cy.get('gn-ui-organisations') | ||
.children('div') | ||
.first() | ||
.children('gn-ui-content-ghost') | ||
.eq(1) | ||
.as('provider') | ||
cy.get('@provider') | ||
.find('gn-ui-thumbnail') | ||
.find('img') | ||
.should('be.visible') | ||
cy.get('@provider').find('[data-cy="providerDesc"]').as('txtProvi') | ||
cy.get('@txtProvi') | ||
.children('span') | ||
.its('text') | ||
.should('have.length.above', 0) | ||
cy.get('@txtProvi').children('div').find('mat-icon').should('be.visible') | ||
cy.get('@txtProvi') | ||
.children('div') | ||
.children('span') | ||
.should(($element) => { | ||
const text = $element.text().trim() | ||
expect(parseInt(text)).to.not.be.NaN | ||
}) | ||
cy.get('@txtProvi') | ||
.children('div') | ||
.children('span') | ||
.eq(1) | ||
.its('text') | ||
.should('have.length.above', 0) | ||
}) | ||
it('should display navigation options', () => { | ||
cy.get('gn-ui-pagination') | ||
.children('div') | ||
.children('div') | ||
.first() | ||
.find('gn-ui-button') | ||
cy.get('gn-ui-pagination') | ||
.children('div') | ||
.children('div') | ||
.eq(1) | ||
.find('input') | ||
cy.get('gn-ui-pagination') | ||
.children('div') | ||
.children('div') | ||
.eq(1) | ||
.find('gn-ui-button') | ||
.should('have.length', 2) | ||
}) | ||
}) | ||
|
||
describe('list functionnalities', () => { | ||
let providerOrg | ||
beforeEach(() => { | ||
cy.get('gn-ui-organisations') | ||
.children('div') | ||
.first() | ||
.children('gn-ui-content-ghost') | ||
.eq(11) | ||
.realClick() | ||
cy.get('[data-cy="providerDesc"]') | ||
.eq(11) | ||
.children('span') | ||
.invoke('text') | ||
.then((txt) => { | ||
providerOrg = txt.toUpperCase().trim() | ||
}) | ||
}) | ||
it('should access the related datasets on click', () => { | ||
cy.get('gn-ui-organisations') | ||
.children('div') | ||
.first() | ||
.children('gn-ui-content-ghost') | ||
.eq(11) | ||
.realClick() | ||
cy.url().should('include', '/search?') | ||
cy.get('[data-cy="recordOrg"]').each(($record) => { | ||
const providerDataset = $record.text().toUpperCase().trim() | ||
expect(providerDataset).to.equal(providerOrg) | ||
}) | ||
}) | ||
}) | ||
|
||
describe.only('page toggle functionnalities', () => { | ||
let proviList = [] | ||
beforeEach(() => { | ||
cy.get('gn-ui-organisations-sort') | ||
.find('gn-ui-dropdown-selector') | ||
.find('select') | ||
.as('filter') | ||
cy.get('gn-ui-pagination') | ||
.children('div') | ||
.children('div') | ||
.as('pagination') | ||
cy.get('gn-ui-organisations') | ||
.children('div') | ||
.first() | ||
.children('gn-ui-content-ghost') | ||
.as('provider') | ||
cy.get('@provider').find('[data-cy="providerDesc"]').as('txtProvi') | ||
}) | ||
|
||
it('should filter the list A to Z / Z to A', () => { | ||
cy.get('@filter').select(1) | ||
function isOrderedZtoA(arr) { | ||
for (let i = 0; i < arr.length - 1; i++) { | ||
if (arr[i].localeCompare(arr[i + 1]) < 0) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
function isOrderedAtoZ(arr) { | ||
for (let i = 0; i < arr.length - 1; i++) { | ||
if (arr[i].localeCompare(arr[i + 1]) > 0) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
|
||
cy.get('@txtProvi') | ||
.children('span') | ||
.each(($span) => { | ||
proviList.push($span.text()) | ||
}) | ||
.then(() => { | ||
proviList = proviList.map((elmt) => elmt.trim()) | ||
expect(isOrderedZtoA(proviList)).to.be.true | ||
proviList = [] | ||
cy.get('@filter').select(0) | ||
cy.get('@txtProvi') | ||
.children('span') | ||
.each(($span) => { | ||
proviList.push($span.text()) | ||
}) | ||
.then(() => { | ||
proviList = proviList.map((elmt) => elmt.trim()) | ||
expect(isOrderedAtoZ(proviList)).to.be.true | ||
}) | ||
}) | ||
}) | ||
it.only('should filter the list by dataset count', () => { | ||
const thirdOrder = [] | ||
const updatedOrder = [] | ||
const initialOrder = [] | ||
cy.get('@filter').select(0) | ||
cy.get('[data-cy="orgaName"]') | ||
.each((item) => { | ||
const text = item.text().trim() | ||
initialOrder.push(text) | ||
}) | ||
.then(() => { | ||
cy.get('@filter').select(2) | ||
cy.get('[data-cy="orgaName"]') | ||
.each((item) => { | ||
const text = item.text().trim() | ||
updatedOrder.push(text) | ||
}) | ||
.then(() => { | ||
expect(initialOrder).to.not.equal(updatedOrder) | ||
cy.get('@filter').select(3) | ||
cy.get('[data-cy="orgaName"]') | ||
.each((item) => { | ||
const text = item.text().trim() | ||
thirdOrder.push(text) | ||
}) | ||
.then(() => { | ||
expect(initialOrder).to.not.equal(thirdOrder) | ||
expect(updatedOrder).to.not.equal(thirdOrder) | ||
}) | ||
}) | ||
}) | ||
}) | ||
it('should navigate to next page with button', () => { | ||
cy.get('@pagination') | ||
}) | ||
it('should navigate between pages with arrows', () => { | ||
cy.get('@pagination') | ||
}) | ||
it('should navigate between pages with number typed', () => { | ||
cy.get('@pagination') | ||
}) | ||
}) | ||
}) |
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