Skip to content

Commit

Permalink
fix(tests): modal e2e tests fix, cypress update (#5145)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludmilanesvitiy authored and Domainv committed Apr 3, 2019
1 parent 4d49218 commit b66b1bb
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,8 @@ describe('Modals demo page test suite: Directive examples', () => {
const btnX = '×';
const eventOnShowFired = 'event onShow is fired';
const eventOnShownFired = 'event onShown is fired';
const eventOnXHide = 'event onHide is fired';
const eventOnXHidden = 'event onHidden is fired';
const eventOnBackdropHide = 'event onHide is fired, dismissed by backdrop-click';
const eventOnBackdropHidden = 'event onHidden is fired, dismissed by backdrop-click';
const eventOnEscHide = 'event onHide is fired, dismissed by esc';
const eventOnEcsHidden = 'event onHidden is fired, dismissed by esc';
const eventOnHide = 'event onHide is fired';
const eventOnHidden = 'event onHidden is fired';

it('example contains the button "Open a modal"', () => {
modals.isButtonExist(eventsModalsDemo, btnText);
Expand All @@ -160,33 +156,30 @@ describe('Modals demo page test suite: Directive examples', () => {
and "event onHidden is fired"`, () => {
modals.clickByText(eventsModalsDemo, btnText);
modals.clickByText(modals.modalBtnX, btnX);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnXHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnXHidden);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHidden);
});

it(`when user user closes modal by click outside the modal window then should be messages
"event onHidden is fired" and "onHidden event has been fired"`, () => {
modals.clickByText(eventsModalsDemo, btnText);
modals.clickOutside(eventsModalsDemo);
modals.isModalEnabled(eventsModalsDemo, false);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnBackdropHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnBackdropHidden);
modals.isModalVisible(eventsModalsDemo, true);
modals.clickOnModal(eventsModalsDemo);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHidden);
});

it(`when user user closes modal by pressing ESC button then modal is closed and should be messages
it(`when user closes modal by pressing ESC button then modal is closed and should be messages
"event onHide is fired, dismissed by esc" and "event onHidden is fired, dismissed by esc"`, () => {
const modalText = 'Just another modal';

modals.clickByText(eventsModalsDemo, btnText);
modals.isDirectModalVisible(eventsModalsDemo, true);
modals.isItemTextContains(eventsModalsDemo, modals.modalBody, modalText);
modals.isBackdropExist(true);
modals.pressEsc();
modals.pressEscOnModal(eventsModalsDemo);
modals.isBackdropExist(false);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnShowFired);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnEscHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnEcsHidden);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHide);
modals.isDemoContainsTxt(eventsModalsDemo, eventOnHidden);
});
});

Expand Down
17 changes: 8 additions & 9 deletions cypress/full/modals_service_page_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,15 @@ describe('Modals demo page test suite: Service examples', () => {
modals.isDemoContainsTxt(eventsDemo, demoOnHiddenFired);
});

it(`when user user closes modal by click outside the modal window then should be messages
it(`when user closes modal by click outside the modal window then should be messages
"onHide event has been fired" and "onHidden event has been fired"`, () => {
modals.clickByText(eventsDemo, btnText);
modals.clickOutside(modals.modalContainer);
modals.isModalEnabled(modals.modalContainer, false);
modals.isBackdropExist(true);
modals.clickOnBackdrop();
modals.isDemoContainsTxt(eventsDemo, demoOnHideFired);
modals.isDemoContainsTxt(eventsDemo, demoHideDismissed);
modals.isDemoContainsTxt(eventsDemo, demoHiddenDismissed);
modals.clickByText(eventsDemo, btnText);
modals.isModalVisible(modals.modalContainer, true);
modals.clickOnBackdrop();
modals.clickOutside('modal-container');
modals.isDemoContainsTxt(eventsDemo, demoOnHideFired);
modals.isDemoContainsTxt(eventsDemo, demoHideDismissed);
modals.isDemoContainsTxt(eventsDemo, demoHiddenDismissed);
});

it(`when user closes modal by pressing ESC button then modal is closed and should be messages
Expand Down
6 changes: 5 additions & 1 deletion cypress/support/modals.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export class ModalsPo extends BaseComponent {
cy.get(this.modalBackdrop).click({force: true});
}

clickOnModal(baseSelector: string) {
cy.get(`${baseSelector} .modal`).click();
}

checkElementsQuantity(elementsSelector: string, expectedQuantity: number) {
cy.get(elementsSelector).should('have.length', expectedQuantity);
}
Expand Down Expand Up @@ -103,6 +107,6 @@ export class ModalsPo extends BaseComponent {
}

pressEscOnModal(baseSelector: string) {
cy.get(`${baseSelector} ${'.show'}`).type('{esc}');
cy.get(`${baseSelector} ${'.modal'}`).type('{esc}');
}
}
Loading

0 comments on commit b66b1bb

Please sign in to comment.