Skip to content

Commit

Permalink
test(e2e): fix and restructure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Feb 7, 2024
1 parent 23636ad commit 1b4ed86
Showing 1 changed file with 44 additions and 32 deletions.
76 changes: 44 additions & 32 deletions apps/datahub-e2e/src/e2e/dataset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,81 @@ describe('datasets', () => {
describe('when not logged in', () => {
beforeEach(() => cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4'))

it('should display the favorite button disabled', () => {
cy.get('mel-datahub-button-primary')
.eq(0)
.find('button')
.as('favoriteButton')
cy.get('@favoriteButton').should('be.disabled')
cy.get('@favoriteButton').should('have.class', 'bg-primary-light')
})

it('should scroll to download section (all the way down)', () => {
cy.get('mel-datahub-button-primary').eq(1).as('downloadButton')
cy.get('@downloadButton').click()
cy.get('@downloadButton').should(() => {
const scrollPosition = Cypress.dom.getWindowByElement(
cy.state('window')
).scrollY
expect(scrollPosition).to.be.greaterThan(900)
})
})

it('should scroll to api section (all the way down)', () => {
cy.get('mel-datahub-button-primary').eq(2).as('apiButton')
cy.get('@apiButton').click()
cy.get('@apiButton').should(() => {
const scrollPosition = Cypress.dom.getWindowByElement(
cy.state('window')
).scrollY
expect(scrollPosition).to.be.greaterThan(900)
})
})

it('should display the title', () => {
cy.get('.mel-page-title').should('be.visible')
cy.get('.mel-page-title').should('have.text', ' Alpenkonvention ')
})

it('should display the abstract in collapsed mode applying gradient', () => {
cy.get('mel-datahub-max-lines').should('be.visible')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand').should('be.visible')
cy.get('mel-datahub-text-expand')
.find('mel-datahub-button-primary')
.should('have.text', ' En savoir plus ')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand')
.find('mel-datahub-button-primary')
.find('img')
.should('have.attr', 'src', '/assets/icons/arrow.svg')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand')
.find('.bg-gradient-to-b')
.should('have.css', 'max-height', '72px')
})

it('should display the abstract in expanded mode without gradient', () => {
cy.get('mel-datahub-max-lines').should('be.visible')
cy.get('mel-datahub-max-lines').find('mel-datahub-button-primary').click()
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand').should('be.visible')
cy.get('mel-datahub-text-expand')
.find('mel-datahub-button-primary')
.click()
cy.get('mel-datahub-text-expand')
.find('mel-datahub-button-primary')
.should('have.text', ' Reduire ')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand')
.find('mel-datahub-button-primary')
.find('img')
.should('have.attr', 'src', '/assets/icons/arrow-up.svg')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand')
.find('.bg-gradient-to-b')
.should('not.exist')
cy.get('mel-datahub-max-lines')
cy.get('mel-datahub-text-expand')
.find('.ease-in')
.should('have.css', 'max-height')
.and('satisfy', (maxHeight) => parseInt(maxHeight, 10) > 110)
})

it('should scroll to download section (all the way down)', () => {
cy.get('mel-datahub-button-primary').eq(1).as('downloadButton')
cy.get('@downloadButton').click()
cy.get('@downloadButton').should(() => {
const scrollPosition = Cypress.dom.getWindowByElement(
cy.state('window')
).scrollY
expect(scrollPosition).to.be.greaterThan(900)
})
})

it('should scroll to api section (all the way down)', () => {
cy.get('mel-datahub-button-primary').eq(2).as('apiButton')
cy.get('@apiButton').click()
cy.get('@apiButton').should(() => {
const scrollPosition = Cypress.dom.getWindowByElement(
cy.state('window')
).scrollY
expect(scrollPosition).to.be.greaterThan(900)
})
})
})
describe('when logged in', () => {
beforeEach(() => {
cy.login()
cy.clearFavorites()
cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4')
})
it('should toggle the favorite button', () => {
Expand Down

0 comments on commit 1b4ed86

Please sign in to comment.