Skip to content

Commit

Permalink
tests(e2e): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jul 5, 2023
1 parent 156085d commit 9da6019
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 49 deletions.
13 changes: 0 additions & 13 deletions apps/datahub-e2e/src/e2e/app.cy.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ describe('organisations', () => {
.children('div')
.eq(1)
.click()
cy.wait(2000)
cy.wait(5000)
cy.get('@prevSection').find('gn-ui-table').should('be.visible')
cy.get('@prevSection')
.find('tbody')
Expand Down
5 changes: 0 additions & 5 deletions apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ describe('datasets', () => {
.should('not.eq', '@initialLength')
})
})
it('should add more datasets to the list on click on "add more"', () => {
cy.get('gn-ui-results-list-item').as('initialList')
cy.get('[data-cy="addMoreBtn"]').trigger('click')
cy.get('gn-ui-results-list-item').should('not.eq', '@initialList')
})
})

describe('list actions', () => {
Expand Down
6 changes: 3 additions & 3 deletions apps/datahub-e2e/src/e2e/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ describe('header', () => {

describe('general display', () => {
it('should display the title', () => {
cy.get('[data-cy="dh-title"]')
cy.get('[data-cy="dh-title"]').should('be.visible')
})
it('should display the header image', () => {
cy.get('header')
.should('have.css', 'background')
.and('include', 'header_bg.webp')
})
it('should display the search bar, button and placeholder', () => {
cy.get('gn-ui-fuzzy-search')
cy.get('gn-ui-fuzzy-search').should('be.visible')
cy.get('gn-ui-autocomplete').should('have.length.gt', 0)
cy.get('mat-icon').contains('search')
cy.get('mat-icon').contains('search').should('be.visible')
})
it('display three buttons that go to other pages on click', () => {
cy.get('datahub-navigation-menu')
Expand Down
21 changes: 14 additions & 7 deletions apps/datahub-e2e/src/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ describe('header', () => {
.should('eq', 'decoration-primary')
})
it('should display the news feed', () => {
cy.get('gn-ui-results-list')
cy.get('gn-ui-results-list').should('be.visible')
})
it('should display the "show more" button', () => {
cy.get('[data-cy="addMoreBtn"]')
cy.get('[data-cy="addMoreBtn"]').should('be.visible')
})
it('should display the orga and dataset link buttons', () => {
cy.get('[ng-reflect-title="datasets"]')
cy.get('[ng-reflect-title="organisations"]')
cy.get('[ng-reflect-title="datasets"]').should('be.visible')
cy.get('[ng-reflect-title="organisations"]').should('be.visible')
})

describe('news feed display', () => {
Expand Down Expand Up @@ -47,9 +47,16 @@ describe('header', () => {
cy.url().should('include', '/dataset/')
})
it('adds more datasets to the news feed upon clicking on "show more"', () => {
cy.get('gn-ui-results-list-item').as('initialList')
cy.get('[data-cy="addMoreBtn"]').trigger('click')
cy.get('gn-ui-results-list-item').should('not.eq', '@initialList')
let initialList
let newList
cy.get('gn-ui-results-list-item').then((firstlist) => {
initialList = firstlist
cy.get('[data-cy="addMoreBtn"]').trigger('click')
cy.get('gn-ui-results-list-item').then((secondlist) => {
newList = secondlist
expect(newList).to.not.equal(initialList)
})
})
})
})

Expand Down
27 changes: 7 additions & 20 deletions apps/datahub-e2e/src/e2e/organisations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('organisations', () => {
.should('eq', 'decoration-primary')
})
it('should display the welcome panel', () => {
cy.get('gn-ui-organisations-sort')
cy.get('gn-ui-organisations-sort').should('be.visible')
cy.get('gn-ui-organisations-sort')
.find('p')
.its('text')
Expand Down Expand Up @@ -75,12 +75,6 @@ describe('organisations', () => {
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')
Expand All @@ -95,7 +89,7 @@ describe('organisations', () => {
.first()
.children('gn-ui-content-ghost')
.eq(11)
.realClick()
.click()
cy.url().should('include', 'publisher=').and('include', providerOrg)
})
})
Expand All @@ -118,18 +112,11 @@ describe('organisations', () => {

it('should filter the list A to Z / Z to A', () => {
cy.get('@filter').select(1)
function isOrderedZtoA(arr) {
function isOrdered(arr, type) {
for (let i = 0; i < arr.length - 1; i++) {
if (arr[i].localeCompare(arr[i + 1]) < 0) {
if (arr[i].localeCompare(arr[i + 1]) < 0 && type == 'ZA') {
return false
}
}
return true
}

function isOrderedAtoZ(arr) {
for (let i = 0; i < arr.length - 1; i++) {
if (arr[i].localeCompare(arr[i + 1]) > 0) {
} else if (arr[i].localeCompare(arr[i + 1]) > 0 && type == 'AZ') {
return false
}
}
Expand All @@ -143,7 +130,7 @@ describe('organisations', () => {
})
.then(() => {
proviList = proviList.map((elmt) => elmt.trim())
expect(isOrderedZtoA(proviList)).to.be.true
expect(isOrdered(proviList, 'ZA')).to.be.true
proviList = []
cy.get('@filter').select(0)
cy.get('@txtProvi')
Expand All @@ -153,7 +140,7 @@ describe('organisations', () => {
})
.then(() => {
proviList = proviList.map((elmt) => elmt.trim())
expect(isOrderedAtoZ(proviList)).to.be.true
expect(isOrdered(proviList, 'AZ')).to.be.true
})
})
})
Expand Down

0 comments on commit 9da6019

Please sign in to comment.