-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add cypress e2e tests instead of protractor e2e and e2e-…
…bdd tests (#3515) * feat(tests): add cypress e2e tests instead of protractor e2e and e2e-bdd tests * test(demo): add cypress e2e for accordion demo page * feat(tests): add cypress e2e for alerts demo page * feat(tests): add cypress e2e for buttons demo page
- Loading branch information
Showing
61 changed files
with
785 additions
and
1,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:4400/#" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import { AccordionPo } from '../support/accordion.po'; | ||
|
||
describe('Accordion page test suite', () => { | ||
const accordion = new AccordionPo(); | ||
const accordionExamples = accordion.accordionDemosArr; | ||
const accordionTitles = accordion.exampleTitlesArr; | ||
|
||
beforeEach(() => accordion.navigateTo()); | ||
|
||
it('accordion page loads and displays it\'s content', () => { | ||
cy.get('.content') | ||
.should('be.visible'); | ||
}); | ||
|
||
it('content header contains title and link to accordion component at github', () => { | ||
cy.get('.content-header').children('h1').as('title') | ||
.should('be.visible') | ||
.and('to.contain', accordion.pageTitle); | ||
|
||
cy.get('@title').children('a') | ||
.should('be.enabled') | ||
.and('have.attr', 'href', accordion.ghLinkToComponent); | ||
}); | ||
|
||
it('usage code example is displayed at demo top section', () => { | ||
cy.get('demo-top-section').as('demoTop').children('h2') | ||
.should('be.visible') | ||
.and('to.contain', accordion.titleDefaultExample); | ||
|
||
cy.get('@demoTop').children('.prettyprint') | ||
.should('be.visible') | ||
.and('not.to.be.empty'); | ||
}); | ||
|
||
it('each panel at simple accordion opens content at first click', () => { | ||
cy.get(accordionExamples[0]).children('.panel-group').children('.panel').each(($panel, i) => { | ||
accordion.getAccordionPanel(accordionExamples[0], i).as('currPanel').click(); | ||
|
||
cy.get('@currPanel') | ||
.should('have.class', 'panel-open'); | ||
}); | ||
}); | ||
|
||
it('double click leaves all panels closed at simple accordion', () => { | ||
cy.get(accordionExamples[0]).children('.panel-group').children('.panel').each(($panel, i) => { | ||
accordion.getAccordionPanel(accordionExamples[0], i).as('currPanel').dblclick(); | ||
|
||
cy.get('@currPanel') | ||
.should('not.have.class', 'panel-open'); | ||
}); | ||
}); | ||
|
||
it('first panel can be disabled or enabled at disabled example', () => { | ||
accordion.clickByText(accordionExamples[1], accordion.buttonEnableDisable); | ||
|
||
accordion.getAccordionPanel(accordionExamples[1], 0).as('firstPanel').find('.text-muted') | ||
.should('to.be.exist'); | ||
|
||
accordion.clickByText(accordionExamples[1], accordion.buttonEnableDisable); | ||
|
||
cy.get('@firstPanel').find('.text-muted') | ||
.should('not.to.be.exist'); | ||
}); | ||
|
||
it('last panel can be controlled by toggler button at dynamic example', () => { | ||
accordion.clickByText(accordionExamples[2], accordion.buttonPanelToggler); | ||
|
||
accordion.getAccordionPanel(accordionExamples[2], 4).as('dynamicPanel') | ||
.should('not.have.class', 'panel-open'); | ||
|
||
accordion.clickByText(accordionExamples[2], accordion.buttonPanelToggler); | ||
|
||
cy.get('@dynamicPanel') | ||
.should('have.class', 'panel-open'); | ||
}); | ||
|
||
it('items in collapse-panel can be added dynamic at dynamic example', () => { | ||
accordion.getAccordionPanel(accordionExamples[2], 3).as('dynamicItemsPanel').click(); | ||
|
||
cy.get('@dynamicItemsPanel').find('.panel-body').children('div') | ||
.should('have.length', 3); | ||
|
||
accordion.clickByText('@dynamicItemsPanel', accordion.buttonAddItem); | ||
|
||
cy.get('@dynamicItemsPanel').find('.panel-body').children('div') | ||
.should('have.length', 4); | ||
}); | ||
|
||
it('open only one panel at a time if closeOthers property sets as true', () => { | ||
cy.get(accordionExamples[3]).find('input').check(); | ||
|
||
accordion.getAccordionPanel(accordionExamples[3], 0).as('firstPanel').click() | ||
.should('have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[3], 1).as('secondPanel') | ||
.should('not.have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[3], 2).as('thirdPanel') | ||
.should('not.have.class', 'panel-open'); | ||
|
||
cy.get('@thirdPanel').click() | ||
.should('have.class', 'panel-open'); | ||
cy.get('@firstPanel') | ||
.should('not.have.class', 'panel-open'); | ||
cy.get('@secondPanel') | ||
.should('not.have.class', 'panel-open'); | ||
}); | ||
|
||
it('other panels are not closed if closeOthers property sets as false', () => { | ||
cy.get(accordionExamples[3]).find('input').uncheck(); | ||
|
||
accordion.getAccordionPanel(accordionExamples[3], 0).as('firstPanel').click() | ||
.should('have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[3], 1).as('secondPanel') | ||
.should('not.have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[3], 2).as('thirdPanel') | ||
.should('not.have.class', 'panel-open'); | ||
|
||
cy.get('@thirdPanel').click() | ||
.should('have.class', 'panel-open'); | ||
cy.get('@firstPanel') | ||
.should('have.class', 'panel-open'); | ||
cy.get('@secondPanel') | ||
.should('not.have.class', 'panel-open'); | ||
}); | ||
|
||
it('first and third panel at styling accordion contains customClass style', () => { | ||
const stylesPanel = ['rgb(91, 192, 222)', 'rgb(255, 255, 255)']; | ||
const stylePanelBody = 'rgb(51, 122, 167)'; | ||
|
||
accordion.getAccordionPanel(accordionExamples[4], 0).children('.card').as('firstPanel') | ||
.should('to.have.css', 'background-color', stylesPanel[0]) | ||
.and('to.have.css', 'color', stylesPanel[1]); | ||
cy.get('@firstPanel').find('.panel-body') | ||
.should('to.have.css', 'background-color', stylePanelBody); | ||
|
||
accordion.getAccordionPanel(accordionExamples[4], 2).children('.card').as('thirdPanel') | ||
.should('to.have.css', 'background-color', stylesPanel[0]) | ||
.and('to.have.css', 'color', stylesPanel[1]); | ||
cy.get('@thirdPanel').find('.panel-body') | ||
.should('to.have.css', 'background-color', stylePanelBody); | ||
}); | ||
|
||
it('configuring defaults example opens only one panel at a time', () => { | ||
accordion.getAccordionPanel(accordionExamples[5], 0).as('firstPanel').click() | ||
.should('have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[5], 1).as('secondPanel') | ||
.should('not.have.class', 'panel-open'); | ||
accordion.getAccordionPanel(accordionExamples[5], 2).as('thirdPanel') | ||
.should('not.have.class', 'panel-open'); | ||
|
||
cy.get('@secondPanel').click() | ||
.should('have.class', 'panel-open'); | ||
cy.get('@firstPanel') | ||
.should('not.have.class', 'panel-open'); | ||
cy.get('@thirdPanel') | ||
.should('not.have.class', 'panel-open'); | ||
}); | ||
|
||
it('each demo examples are not mixed up with each other and contains code examples', () => { | ||
cy.get('examples').find('h3').as('exampleTitles').each(($title, i) => { | ||
expect($title).to.contain(accordionTitles[i]); | ||
|
||
cy.get('@exampleTitles').contains(accordionTitles[i]).parent().as('currentBlock'); | ||
|
||
cy.get('@currentBlock').find(accordionExamples[i]) | ||
.should('to.exist'); | ||
cy.get('@currentBlock').find('.section').eq(1) | ||
.should('be.visible') | ||
.and('not.to.be.empty'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.