test toggle children button visibility
This commit is contained in:
parent
f79757ce7e
commit
d26734facf
1 changed files with 67 additions and 0 deletions
67
cypress/e2e/adminTextToggle.cy.js
Normal file
67
cypress/e2e/adminTextToggle.cy.js
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
describe('Toggle display of child nodes', () => {
|
||||
beforeEach(() => {
|
||||
cy.exec('npm run db:seed')
|
||||
cy.intercept('GET', '/api/texts/0').as('getText')
|
||||
cy.intercept('GET', '/api/nodes/0').as('getNodes')
|
||||
cy.visit('/admin/texts/0')
|
||||
cy.wait('@getText')
|
||||
cy.wait('@getNodes')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
cy.exec('npm run db:wipe')
|
||||
})
|
||||
|
||||
it('shows a toggle button on nodes that have children', () => {
|
||||
cy.get('#text-detail > ul > li')
|
||||
.first()
|
||||
.find('button.toggle-children')
|
||||
.should('exist')
|
||||
})
|
||||
|
||||
it('does not show a toggle button on leaf nodes', () => {
|
||||
cy.get('#text-detail > ul > li > ul > li > ul > li')
|
||||
.first()
|
||||
.find('button.toggle-children')
|
||||
.should('not.exist')
|
||||
})
|
||||
|
||||
it('root node children are visible on initial load', () => {
|
||||
cy.get('#text-detail > ul > li > ul > li')
|
||||
.first()
|
||||
.should('be.visible')
|
||||
})
|
||||
|
||||
it('grandchildren are hidden on initial load', () => {
|
||||
cy.get('#text-detail > ul > li > ul > li > ul')
|
||||
.first()
|
||||
.should('not.be.visible')
|
||||
})
|
||||
|
||||
it('clicking toggle button on a node shows its children', () => {
|
||||
cy.get('#text-detail > ul > li > ul > li')
|
||||
.first()
|
||||
.find('button.toggle-children')
|
||||
.click()
|
||||
cy.get('#text-detail > ul > li > ul > li > ul')
|
||||
.first()
|
||||
.should('be.visible')
|
||||
})
|
||||
|
||||
it('clicking toggle button again hides children', () => {
|
||||
cy.get('#text-detail > ul > li > ul > li')
|
||||
.first()
|
||||
.find('button.toggle-children')
|
||||
.click()
|
||||
cy.get('#text-detail > ul > li > ul > li > ul')
|
||||
.first()
|
||||
.should('be.visible')
|
||||
cy.get('#text-detail > ul > li > ul > li')
|
||||
.first()
|
||||
.find('button.toggle-children')
|
||||
.click()
|
||||
cy.get('#text-detail > ul > li > ul > li > ul')
|
||||
.first()
|
||||
.should('not.be.visible')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue