test(elements): make e2e tests for elements docs examples less flaky (#26377)
PR Close #26377
This commit is contained in:
parent
31c462ae3f
commit
b647608c96
@ -1,12 +1,19 @@
|
|||||||
'use strict'; // necessary for es6 output in node
|
'use strict'; // necessary for es6 output in node
|
||||||
|
|
||||||
import { browser, by, element } from 'protractor';
|
import { browser, by, element, ElementFinder, ExpectedConditions as EC } from 'protractor';
|
||||||
|
|
||||||
/* tslint:disable:quotemark */
|
/* tslint:disable:quotemark */
|
||||||
describe('Elements', () => {
|
describe('Elements', () => {
|
||||||
const messageInput = element(by.css('input'));
|
const messageInput = element(by.css('input'));
|
||||||
const popupButtons = element.all(by.css('button'));
|
const popupButtons = element.all(by.css('button'));
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
const click = (elem: ElementFinder) => {
|
||||||
|
// Waiting for the element to be clickable, makes the tests less flaky.
|
||||||
|
browser.wait(EC.elementToBeClickable(elem), 5000);
|
||||||
|
elem.click();
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(() => browser.get(''));
|
beforeEach(() => browser.get(''));
|
||||||
|
|
||||||
describe('popup component', () => {
|
describe('popup component', () => {
|
||||||
@ -17,7 +24,7 @@ describe('Elements', () => {
|
|||||||
it('should be displayed on button click', () => {
|
it('should be displayed on button click', () => {
|
||||||
expect(popupComponent.isPresent()).toBe(false);
|
expect(popupComponent.isPresent()).toBe(false);
|
||||||
|
|
||||||
popupComponentButton.click();
|
click(popupComponentButton);
|
||||||
expect(popupComponent.isPresent()).toBe(true);
|
expect(popupComponent.isPresent()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -25,7 +32,7 @@ describe('Elements', () => {
|
|||||||
messageInput.clear();
|
messageInput.clear();
|
||||||
messageInput.sendKeys('Angular rocks!');
|
messageInput.sendKeys('Angular rocks!');
|
||||||
|
|
||||||
popupComponentButton.click();
|
click(popupComponentButton);
|
||||||
expect(popupComponent.getText()).toContain('Popup: Angular rocks!');
|
expect(popupComponent.getText()).toContain('Popup: Angular rocks!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -33,7 +40,7 @@ describe('Elements', () => {
|
|||||||
popupComponentButton.click();
|
popupComponentButton.click();
|
||||||
expect(popupComponent.isPresent()).toBe(true);
|
expect(popupComponent.isPresent()).toBe(true);
|
||||||
|
|
||||||
closeButton.click();
|
click(closeButton);
|
||||||
expect(popupComponent.isPresent()).toBe(false);
|
expect(popupComponent.isPresent()).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -46,7 +53,7 @@ describe('Elements', () => {
|
|||||||
it('should be displayed on button click', () => {
|
it('should be displayed on button click', () => {
|
||||||
expect(popupElement.isPresent()).toBe(false);
|
expect(popupElement.isPresent()).toBe(false);
|
||||||
|
|
||||||
popupElementButton.click();
|
click(popupElementButton);
|
||||||
expect(popupElement.isPresent()).toBe(true);
|
expect(popupElement.isPresent()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +61,7 @@ describe('Elements', () => {
|
|||||||
messageInput.clear();
|
messageInput.clear();
|
||||||
messageInput.sendKeys('Angular rocks!');
|
messageInput.sendKeys('Angular rocks!');
|
||||||
|
|
||||||
popupElementButton.click();
|
click(popupElementButton);
|
||||||
expect(popupElement.getText()).toContain('Popup: Angular rocks!');
|
expect(popupElement.getText()).toContain('Popup: Angular rocks!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -62,7 +69,7 @@ describe('Elements', () => {
|
|||||||
popupElementButton.click();
|
popupElementButton.click();
|
||||||
expect(popupElement.isPresent()).toBe(true);
|
expect(popupElement.isPresent()).toBe(true);
|
||||||
|
|
||||||
closeButton.click();
|
click(closeButton);
|
||||||
expect(popupElement.isPresent()).toBe(false);
|
expect(popupElement.isPresent()).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user