61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
describe('The admin text detail page horizontal layout', () => {
|
|
beforeEach(() => {
|
|
cy.exec('npm run db:seed')
|
|
cy.loginAsAdmin()
|
|
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('renders child list to the right of the parent title', () => {
|
|
cy.get('#text-detail > ul > li').first().as('rootLi')
|
|
cy.get('@rootLi').children('span').first().as('rootTitle')
|
|
cy.get('@rootLi').children('ul').first().as('childList')
|
|
|
|
cy.get('@childList').should('be.visible')
|
|
|
|
cy.get('@rootTitle').then(($title) => {
|
|
const titleRect = $title[0].getBoundingClientRect()
|
|
cy.get('@childList').then(($list) => {
|
|
const listRect = $list[0].getBoundingClientRect()
|
|
expect(listRect.left).to.be.greaterThan(titleRect.right)
|
|
})
|
|
})
|
|
})
|
|
|
|
it('stacks sibling child nodes vertically within the right column', () => {
|
|
cy.intercept('POST', '/api/nodes').as('createNode')
|
|
cy.intercept('GET', '/api/nodes/0').as('getNodesRefresh')
|
|
|
|
cy.get('#text-detail > ul > li')
|
|
.first()
|
|
.activateNode()
|
|
.children('button.add-child')
|
|
.click()
|
|
cy.get('#text-detail > ul > li')
|
|
.first()
|
|
.children('input.child-title')
|
|
.type('Sibling One{enter}')
|
|
cy.wait('@createNode')
|
|
cy.wait('@getNodesRefresh')
|
|
|
|
cy.get('#text-detail > ul > li > ul > li').should(
|
|
'have.length.greaterThan',
|
|
1
|
|
)
|
|
|
|
cy.get('#text-detail > ul > li > ul > li').then(($siblings) => {
|
|
const firstRect = $siblings[0].getBoundingClientRect()
|
|
const lastRect = $siblings[$siblings.length - 1]
|
|
.getBoundingClientRect()
|
|
expect(lastRect.top).to.be.greaterThan(firstRect.top)
|
|
expect(Math.abs(lastRect.left - firstRect.left)).to.be.lessThan(2)
|
|
})
|
|
})
|
|
})
|