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 3d72f97 commit 67ebb67
Showing 1 changed file with 68 additions and 68 deletions.
136 changes: 68 additions & 68 deletions cypress/integration/blocks-accordion.js
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,63 @@ 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('.accordion:nth-child(1) > .content:nth-child(2)')
.first()
.within(() => {
cy.get('p[data-slate-node="element"]')
.should('have.value', '')
.invoke('attr', 'tabindex', 1)
.first()
.type('children', { delay: 50 });
});

// then the page view should contain our changes
cy.contains('My Add-on Page');
});
// cy.get('div.DraftEditor-editorContainer')
// .first()
// .within(() => {
// cy.get('span[data-text=true]')
// .should('have.value', '')
// .invoke('attr', 'tabindex', 1)
// .type('children', { delay: 50 });
// });

it('Accordion Block: Change Title', () => {
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 });

//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: Empty', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
Expand All @@ -63,30 +106,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,52 +139,19 @@ describe('Block Tests', () => {
//
cy.get('.accordion:nth-child(1) > .active input')
.click()
.type('panel 1')
.should('have.value', 'panel 1');
cy.wait(1000);
if (cy.find('div.slate-editor').length) {
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 });
});
} else {
cy.get('div.DraftEditor-editorContainer')
.first()
.within(() => {
cy.get('span[data-text=true]')
.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 });
.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(() => {
//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]/);
});
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 67ebb67

Please sign in to comment.