Skip to content

Commit

Permalink
feat(dh): e2e tests (not finished)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Dec 5, 2023
1 parent eec9f80 commit 00aa81f
Showing 1 changed file with 110 additions and 10 deletions.
120 changes: 110 additions & 10 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,114 @@ describe('record with file distributions', () => {
})
})

describe.only('api custom panel', () => {
// should display dots button
// should open the panel on click
// should have request elements : 2 text inputs, 1 dpdn input, reset button
// should change url on input change
// should set limit to zero on click on "Tous" checkbox
// should reset all 3 inputs and link on click
// should access the swagger on click
// should have close button
// should close the panel on click
describe('api cards', () => {
beforeEach(() => {
cy.visit('/dataset/accroche_velos')
cy.get('gn-ui-api-card').first().as('firstCard')
})

it('should display the open panel button', () => {
cy.get('@firstCard')
.find('button')
.children('mat-icon')
.should('have.text', 'more_horiz')
})
it('should open and close the panel on click on open panel button', () => {
cy.get('@firstCard').find('button').click()
cy.get('gn-ui-record-api-form').should('be.visible')
cy.get('@firstCard').find('button').click()
cy.get('gn-ui-record-api-form').should('not.exist')
})
})

describe.only('api form', () => {
beforeEach(() => {
cy.visit('/dataset/accroche_velos')
cy.get('gn-ui-api-card').first().find('button').click()
cy.get('gn-ui-record-api-form').children('div').as('apiForm')
})
it('should have request inputs', () => {
cy.get('@apiForm').find('gn-ui-text-input').should('have.length', 2)
cy.get('@apiForm').find('gn-ui-dropdown-selector').should('have.length', 1)
cy.get('@apiForm')
.children('div')
.first()
.find('button')
.should('have.length', 1)
cy.get('@apiForm').find('gn-ui-copy-text-button').should('have.length', 1)
})
it('should change url on input change', () => {
cy.get('@apiForm')
.find('gn-ui-copy-text-button')
.find('input')
.invoke('val')
.then((url) => {
cy.get('@apiForm').find('gn-ui-text-input').first().clear()
cy.get('@apiForm').find('gn-ui-text-input').first().type('54')
cy.get('@apiForm')
.find('gn-ui-copy-text-button')
.find('input')
.invoke('val')
.then((newUrl) => {
expect(newUrl).to.not.eq(url)
expect(newUrl).to.include('54')
})
})
})
it('should set limit to zero on click on "All" button', () => {
cy.get('@apiForm').find('gn-ui-text-input').first().clear()
cy.get('@apiForm').find('gn-ui-text-input').first().type('54')
cy.get('@apiForm').find('input[type="checkbox"]').check()
cy.get('@apiForm').find('gn-ui-text-input').first().should('have.value', '')
})
it.only('should reset all 3 inputs and link on click', () => {
cy.get('@apiForm').find('gn-ui-text-input').first().as('firstInput')
cy.get('@firstInput').clear()
cy.get('@firstInput').type('54')

cy.get('@apiForm').find('gn-ui-text-input').eq(1).as('secondInput')
cy.get('@secondInput').clear()
cy.get('@secondInput').type('87')

cy.get('@apiForm').find('gn-ui-dropdown-selector').click()
cy.get('button[data-cy-value="csv"]').click()

cy.get('@apiForm')
.find('gn-ui-copy-text-button')
.find('input')
.invoke('val')
.should('include', 'offset=87&limit=54&f=csv')

cy.get('@apiForm').children('div').first().find('button').first().click()

cy.get('@firstInput').find('input').should('have.value', 0)
cy.get('@secondInput').find('input').should('have.value', 0)
cy.get('@apiForm')
.find('gn-ui-dropdown-selector')
.find('button')
.children('div')
.should('have.text', ' JSON ')
cy.get('@apiForm')
.find('gn-ui-copy-text-button')
.find('input')
.invoke('val')
.should('include', 'f=json')
})
it('should have close button', () => {
cy.get('@apiForm').siblings().find('button')
// sibling of apiForm
})
it('should close the panel on click', () => {
// get the close button
// click on it
// check that the panel does not exist
cy.get('@apiForm')
})
it('should switch to other card url if card already open', () => {
// get the current url
// do then
// click on other card button
// check that the url is now different
cy.get('@apiForm')
})
})

0 comments on commit 00aa81f

Please sign in to comment.