Skip to content

Commit

Permalink
reorder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Dec 22, 2020
1 parent 85551ed commit 83df043
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 118 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
GIT_NAME = "volto-accordion-block"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu"
DEPENDENCIES = "@eeacms/volto-blocks-form"
DEPENDENCIES = "@eeacms/volto-blocks-form volto-slate:asDefault"
}

stages {
Expand Down Expand Up @@ -80,7 +80,7 @@ pipeline {
script {
try {
sh '''docker pull plone; docker run -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
sh '''docker pull eeacms/volto-test; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e DEPENDENCIES="$DEPENDENCIES volto-slate:asDefault" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/volto-test cypress'''
sh '''docker pull eeacms/volto-test; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e DEPENDENCIES="$DEPENDENCIES" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/volto-test cypress'''
} finally {
sh '''mkdir -p cypress-reports'''
sh '''docker cp $BUILD_TAG-cypress:/opt/frontend/my-volto-project/src/addons/$GIT_NAME/cypress/videos cypress-reports/'''
Expand Down
232 changes: 116 additions & 116 deletions cypress/integration/blocks-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,121 +26,121 @@ describe('Block Tests', () => {
cy.autologin();
cy.removeContent('cypress');
});
it('Accordion Block: add accordion content', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

//
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 });

//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()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

// 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');
});
});
it('Accordion Block: Empty', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

// 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');
});

it('Accordion Block: Change Title', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

//
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: Change Title', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

//
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', () => {
// Change page title
cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
.clear()
.type('My Add-on Page')
.get('.documentFirstHeading span[data-text]')
.contains('My Add-on Page');

cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
'{enter}',
);

// 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();

//
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 });

//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]/);
});
});

0 comments on commit 83df043

Please sign in to comment.