From c7605ccf05558ea6501a28bef3511faae26e3b3b Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 23 Nov 2020 20:17:00 +0200 Subject: [PATCH] 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 --- .../e2e/src/app.e2e-spec.ts | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts b/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts index 22403372ca..f0f7c7297b 100644 --- a/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/dynamic-component-loader/e2e/src/app.e2e-spec.ts @@ -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); }); });