test(docs-infra): fix the `dynamic-component-loader` e2e tests (#39818)
Previously, the test made no meaningful assertion. It seems that the intention was to ensure that some elements were present on the page, but all the assertions did was verify that the corresponding `ElementFinder`s were defined. The `ElementFinder`s would always be defined, even if there were no corresponding elements on the page. In fact, some of the `ElementFinder` selectors were incorrect, so they did not match any actual elements. This commit fixes the tests by fixing the `ElementFinder` selectors and asserting that the elements are actually present on the page. PR Close #39818
This commit is contained in:
parent
3d2c2c40d8
commit
c7605ccf05
|
@ -1,19 +1,24 @@
|
|||
import { browser, element, by } from 'protractor';
|
||||
|
||||
/* tslint:disable:quotemark */
|
||||
describe('Dynamic Component Loader', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
browser.get('');
|
||||
});
|
||||
// The tests trigger periodic asynchronous operations (via `setInterval()`), which will prevent
|
||||
// the app from stabilizing. See https://angular.io/api/core/ApplicationRef#is-stable-examples
|
||||
// for more details.
|
||||
// To allow the tests to complete, we will disable automatically waiting for the Angular app to
|
||||
// stabilize.
|
||||
beforeAll(() => browser.waitForAngularEnabled(false));
|
||||
afterAll(() => browser.waitForAngularEnabled(true));
|
||||
|
||||
it('should load ad banner', () => {
|
||||
const headline = element(by.xpath("//h4[text()='Featured Hero Profile']"));
|
||||
const name = element(by.xpath("//h3[text()='Bombasto']"));
|
||||
const bio = element(by.xpath("//p[text()='Brave as they come']"));
|
||||
beforeEach(() => browser.get(''));
|
||||
|
||||
expect(name).toBeDefined();
|
||||
expect(headline).toBeDefined();
|
||||
expect(bio).toBeDefined();
|
||||
it('should load ad banner', async () => {
|
||||
const headline = element(by.cssContainingText('h3', 'Featured Hero Profile'));
|
||||
const name = element(by.cssContainingText('h4', 'Bombasto'));
|
||||
const bio = element(by.cssContainingText('p', 'Brave as they come'));
|
||||
|
||||
expect(await headline.isPresent()).toBe(true);
|
||||
expect(await name.isPresent()).toBe(true);
|
||||
expect(await bio.isPresent()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue