Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Dec 22, 2020
1 parent 7f6788a commit 64868c9
Showing 1 changed file with 57 additions and 56 deletions.
113 changes: 57 additions & 56 deletions cypress/integration/blocks-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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');
});
});

0 comments on commit 64868c9

Please sign in to comment.