Skip to content

Commit

Permalink
tests(e2e): organisations page (all but pagination done)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jun 23, 2023
1 parent 3b6d345 commit 16bc7ec
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 24 deletions.
5 changes: 2 additions & 3 deletions apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('datasets', () => {
})
})

describe('filter the list on click on options', () => {
describe.only('filter the list on click on options', () => {
let filterLength
beforeEach(() => {
cy.visit('/home/search')
Expand Down Expand Up @@ -241,7 +241,6 @@ describe('datasets', () => {
const label = $dropdown.prev('label')

if (label.text() !== '') {
cy.wrap($dropdown).select('OptionValue')
cy.get('[id^=dropdown-multiselect-]')
.find('label')
.eq(0)
Expand Down Expand Up @@ -443,7 +442,7 @@ describe('datasets', () => {
}
})

it.only('from cross button', () => {
it('from cross button', () => {
cy.visit('/home/search')
cy.get('[data-cy="addMoreBtn"]').realClick()
cy.get('datahub-search-filters')
Expand Down
216 changes: 216 additions & 0 deletions apps/datahub-e2e/src/e2e/organisations.cy.ts
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')
})
})
})
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
<a href (click)="clickOrganisation($event)">
<div
class="group cursor-pointer rounded-lg h-full flex flex-col"
[title]="organisation.name"
>
<div class="group cursor-pointer rounded-lg h-full flex flex-col" [title]="organisation.name">
<div
class="flex-shrink-0 bg-gray-100 rounded-lg w-full border border-gray-300 h-36 group-hover:shadow-xl group-hover:border-0"
>
<gn-ui-thumbnail
class="relative h-full w-full"
[thumbnailUrl]="organisation.logoUrl"
fit="contain"
>
class="flex-shrink-0 bg-gray-100 rounded-lg w-full border border-gray-300 h-36 group-hover:shadow-xl group-hover:border-0">
<gn-ui-thumbnail class="relative h-full w-full" [thumbnailUrl]="organisation.logoUrl" fit="contain">
</gn-ui-thumbnail>
</div>
<div class="px-3 pb-2 capitalize flex flex-col flex-grow overflow-hidden">
<span
class="flex-shrink-0 mb-3 mt-5 font-title text-21 text-title group-hover:text-primary line-clamp-2 sm:mt-2"
>
{{ organisation.name }}</span
>
<p
class="abstract mt-4 mb-5 sm:mb-2 sm:mt-0 flex-grow flex-shrink-1 overflow-hidden"
>
<div class="px-3 pb-2 capitalize flex flex-col flex-grow overflow-hidden" data-cy="providerDesc">
<span class="flex-shrink-0 mb-3 mt-5 font-title text-21 text-title group-hover:text-primary line-clamp-2 sm:mt-2"
data-cy="orgaName">
{{ organisation.name }}</span>
<p class="abstract mt-4 mb-5 sm:mb-2 sm:mt-0 flex-grow flex-shrink-1 overflow-hidden">
{{ organisation.description }}
</p>
<!--
Expand All @@ -40,4 +28,4 @@
</div>
</div>
</div>
</a>
</a>

0 comments on commit 16bc7ec

Please sign in to comment.