From d26734facf09164b57e83f44ec52cc50ad25d031 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Mon, 20 Apr 2026 09:32:28 +0300 Subject: [PATCH] test toggle children button visibility --- cypress/e2e/adminTextToggle.cy.js | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 cypress/e2e/adminTextToggle.cy.js diff --git a/cypress/e2e/adminTextToggle.cy.js b/cypress/e2e/adminTextToggle.cy.js new file mode 100644 index 0000000..c75132b --- /dev/null +++ b/cypress/e2e/adminTextToggle.cy.js @@ -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') + }) +})