From 64868c9e88586d3877a6509d83801322d07c56ea Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Tue, 22 Dec 2020 15:23:18 +0530 Subject: [PATCH] WIP --- cypress/integration/blocks-accordion.js | 113 ++++++++++++------------ 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/cypress/integration/blocks-accordion.js b/cypress/integration/blocks-accordion.js index fafd0cf..c70131d 100644 --- a/cypress/integration/blocks-accordion.js +++ b/cypress/integration/blocks-accordion.js @@ -26,7 +26,7 @@ describe('Block Tests', () => { cy.autologin(); cy.removeContent('cypress'); }); - it('Accordion Block: Empty', () => { + it('Accordion Block: add accordion content', () => { // Change page title cy.get('.documentFirstHeading > .public-DraftStyleDefault-block') .clear() @@ -38,20 +38,52 @@ describe('Block Tests', () => { '{enter}', ); - // Add metadata block + // Add accordion block cy.get('.ui.basic.icon.button.block-add-button').first().click(); cy.get('.blocks-chooser .title').contains('Common').click(); cy.get('.ui.basic.icon.button.accordion').contains('Accordion').click(); - // Save - cy.get('#toolbar-save').click(); - cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); + // + cy.get('.accordion:nth-child(1) > .active input') + .click() + .type('panel 1') + .should('have.value', 'panel 1'); + cy.wait(1000); + cy.get('div.slate-editor') + .first() + .within(() => { + cy.get('p[data-slate-node="element"]') + .should('have.value', '') + .invoke('attr', 'tabindex', 1) + .type('children', { delay: 50 }); + }); + cy.get('.accordion:nth-child(2) > .title input').click(); + cy.get('.accordion:nth-child(2) > .title input').type('panel 2'); + cy.get('.accordion:nth-child(2) > .title > .icon').click(); + cy.get( + '.accordion:nth-child(2) > .content:nth-child(2) p[data-slate-node= "element"]', + ) + .should('have.value', '') + .invoke('attr', 'tabindex', 1) + .type('children', { delay: 100 }); + cy.get('#toolbar-save path').click({ force: true }); - // then the page view should contain our changes - cy.contains('My Add-on Page'); + //after saving + cy.get('div.accordion-title > span').contains('panel 1'); + cy.get('div.content') + .should('have.class', 'active') + .within(() => { + //using regex here,as there's a delay in typing letters in slate which do not uses input + cy.get('p').contains(/[a-z]/); + }); + cy.get('.accordion:nth-child(2) > .title > .icon').click(); + cy.get('div.content') + .should('have.class', 'active') + .within(() => { + cy.get('p').contains(/[a-z]/); + }); }); - - it('Accordion Block: Change Title', () => { + it('Accordion Block: Empty', () => { // Change page title cy.get('.documentFirstHeading > .public-DraftStyleDefault-block') .clear() @@ -63,30 +95,20 @@ describe('Block Tests', () => { '{enter}', ); - // Add accordion block + // Add metadata block cy.get('.ui.basic.icon.button.block-add-button').first().click(); cy.get('.blocks-chooser .title').contains('Common').click(); cy.get('.ui.basic.icon.button.accordion').contains('Accordion').click(); - // - cy.get('.accordion:nth-child(1) > .active input') - .click() - .type('Accordion panel 1') - .should('have.value', 'Accordion panel 1'); - - cy.get('[id="field-title_size"] .react-select-container') - .click() - .type('h2{enter}'); - // Save cy.get('#toolbar-save').click(); cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); // then the page view should contain our changes cy.contains('My Add-on Page'); - cy.get('h2.accordion-title').contains('Accordion panel 1'); }); - it('Accordion Block: add accordion content', () => { + + it('Accordion Block: Change Title', () => { // Change page title cy.get('.documentFirstHeading > .public-DraftStyleDefault-block') .clear() @@ -106,40 +128,19 @@ describe('Block Tests', () => { // cy.get('.accordion:nth-child(1) > .active input') .click() - .type('panel 1') - .should('have.value', 'panel 1'); - cy.get('div.slate-editor') - .first() - .within(() => { - cy.get('p[data-slate-node="element"]') - .should('have.value', '') - .invoke('attr', 'tabindex', 1) - .wait(1000) - .type('children', { delay: 50 }); - }); - cy.get('.accordion:nth-child(2) > .title input').click(); - cy.get('.accordion:nth-child(2) > .title input').type('panel 2'); - cy.get('.accordion:nth-child(2) > .title > .icon').click(); - cy.get( - '.accordion:nth-child(2) > .content:nth-child(2) p[data-slate-node= "element"]', - ) - .should('have.value', '') - .invoke('attr', 'tabindex', 1) - .type('children', { delay: 100 }); - cy.get('#toolbar-save path').click({ force: true }); + .type('Accordion panel 1') + .should('have.value', 'Accordion panel 1'); - //after saving - cy.get('div.accordion-title > span').contains('panel 1'); - cy.get('div.content') - .should('have.class', 'active') - .within(() => { - cy.get('p').contains('hildren'); - }); - cy.get('.accordion:nth-child(2) > .title > .icon').click(); - cy.get('div.content') - .should('have.class', 'active') - .within(() => { - cy.get('p').contains('hildren'); - }); + cy.get('[id="field-title_size"] .react-select-container') + .click() + .type('h2{enter}'); + + // Save + cy.get('#toolbar-save').click(); + cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page'); + + // then the page view should contain our changes + cy.contains('My Add-on Page'); + cy.get('h2.accordion-title').contains('Accordion panel 1'); }); });