From 53a7ed43177e67ec9e046589f47ceb830458aebc Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 25 Sep 2020 19:17:49 +0300 Subject: [PATCH] test(docs-infra): fix and enable remaining `component-interaction` e2e tests (#39001) Previously, some of the e2e tests of the `component-interaction` docs example were disabled because they were failing. This commit fixes and re-enables them. PR Close #39001 --- .../e2e/src/app.e2e-spec.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts index ea6a998285..d5727cc70c 100644 --- a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts +++ b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts @@ -145,19 +145,25 @@ describe('Component Communication Cookbook Tests', () => { // #enddocregion child-to-parent }); - // Can't run timer tests in protractor because - // interaction w/ zones causes all tests to freeze & timeout. - xdescribe('Parent calls child via local var', () => { + describe('Parent calls child via local var', () => { countDownTimerTests('app-countdown-parent-lv'); }); - xdescribe('Parent calls ViewChild', () => { + describe('Parent calls ViewChild', () => { countDownTimerTests('app-countdown-parent-vc'); }); function countDownTimerTests(parentTag: string) { // #docregion countdown-timer-tests // ... + // 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. + beforeEach(() => browser.waitForAngularEnabled(false)); + afterEach(() => browser.waitForAngularEnabled(true)); + it('timer and parent seconds should match', async () => { const parent = element(by.tagName(parentTag)); const startButton = parent.element(by.buttonText('Start')); @@ -165,7 +171,9 @@ describe('Component Communication Cookbook Tests', () => { const timer = parent.element(by.tagName('app-countdown-timer')); await startButton.click(); - await browser.sleep(10); // give `seconds` a chance to catchup with `timer` + + // Wait for `` to be populated with any text. + await browser.wait(() => timer.getText(), 2000); expect(await timer.getText()).toContain(await seconds.getText()); });