test: make elements
integration tests less flaky (#26869)
PR Close #26869
This commit is contained in:
parent
952ca59336
commit
53bae68617
@ -1,20 +1,22 @@
|
|||||||
import { browser, element, by } from 'protractor';
|
import { browser, element, ExpectedConditions as EC, by } from 'protractor';
|
||||||
|
|
||||||
browser.waitForAngularEnabled(false);
|
browser.waitForAngularEnabled(false);
|
||||||
describe('Element E2E Tests', function () {
|
describe('Element E2E Tests', function () {
|
||||||
describe('Hello World Elements', () => {
|
describe('Hello World Elements', () => {
|
||||||
it('should display: Hello world!', function () {
|
const helloWorldEl = element(by.css('hello-world-el'));
|
||||||
browser.get('hello-world.html');
|
|
||||||
const helloWorldEl = element(by.css('hello-world-el'));
|
beforeEach(() => browser.get('hello-world.html'));
|
||||||
|
|
||||||
|
it('should display "Hello World!"', function () {
|
||||||
expect(helloWorldEl.getText()).toEqual('Hello World!');
|
expect(helloWorldEl.getText()).toEqual('Hello World!');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display: Hello Foo! via name attribute', function () {
|
it('should display "Hello Foo!" via name attribute', function () {
|
||||||
browser.get('hello-world.html');
|
|
||||||
const helloWorldEl = element(by.css('hello-world-el'));
|
|
||||||
const input = element(by.css('input[type=text]'));
|
const input = element(by.css('input[type=text]'));
|
||||||
['f', 'o', 'o'].forEach((key) => input.sendKeys(key));
|
input.sendKeys('Foo');
|
||||||
expect(helloWorldEl.getText()).toEqual('Hello foo!');
|
|
||||||
|
// Make tests less flaky on CI by waiting up to 5s for the element text to be updated.
|
||||||
|
browser.wait(EC.textToBePresentInElement(helloWorldEl, 'Hello Foo!'), 5000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -19,5 +19,3 @@ export class AppModule {
|
|||||||
}
|
}
|
||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {HelloWorldComponent};
|
|
||||||
|
@ -3,11 +3,8 @@ import {AppModuleNgFactory} from './app.ngfactory';
|
|||||||
|
|
||||||
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory, {ngZone: 'noop'});
|
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory, {ngZone: 'noop'});
|
||||||
|
|
||||||
|
const input = document.querySelector('input');
|
||||||
const helloWorld = document.querySelector('hello-world-el');
|
const helloWorld = document.querySelector('hello-world-el');
|
||||||
const input = document.querySelector('input[type=text]');
|
|
||||||
if(input && helloWorld){
|
if(input && helloWorld){
|
||||||
input.addEventListener('input', e => {
|
input.addEventListener('input', () => helloWorld.setAttribute('name', input.value));
|
||||||
const newText = (e.target as any).value;
|
|
||||||
helloWorld.setAttribute('name', newText);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user