diff --git a/change/react-native-windows-2020-08-17-15-28-29-VisitAllPagesFix.json b/change/react-native-windows-2020-08-17-15-28-29-VisitAllPagesFix.json new file mode 100644 index 00000000000..dc97317ab4b --- /dev/null +++ b/change/react-native-windows-2020-08-17-15-28-29-VisitAllPagesFix.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "fix instability in VisitAllPages test", + "packageName": "react-native-windows", + "email": "kmelmon@microsoft.com", + "dependentChangeType": "patch", + "date": "2020-08-17T22:28:29.230Z" +} diff --git a/packages/E2ETest/wdio/pages/BasePage.ts b/packages/E2ETest/wdio/pages/BasePage.ts index 52e5ebd4aca..55f653607eb 100644 --- a/packages/E2ETest/wdio/pages/BasePage.ts +++ b/packages/E2ETest/wdio/pages/BasePage.ts @@ -21,18 +21,18 @@ export function wait(timeout: number) { } export class BasePage { - isPageLoaded(): boolean { - return this.homeButton.isDisplayed(); + isElementLoaded(element: string): boolean { + return By(element).isDisplayed(); } - waitForPageLoaded(timeout?: number) { + waitForElementLoaded(element: string, timeout?: number) { // eslint-disable-next-line no-undef browser.waitUntil( () => { - return this.isPagedLoadedOrLoadBundleError(); + return this.isElementLoadedOrLoadBundleError(element); }, this.timeoutForPageLoaded(timeout), - 'Wait for page ' + this.constructor.name + ' timeout' + 'Wait for element ' + element + ' timeout' ); } @@ -73,12 +73,12 @@ export class BasePage { return By(REACT_CONTROL_ERROR_TEST_ID); } - private isPagedLoadedOrLoadBundleError(): boolean { + private isElementLoadedOrLoadBundleError(element: string): boolean { if (this.reactControlErrorMessage.isDisplayed()) { throw "ReactControl doesn't load bundle successfully: " + this.reactControlErrorMessage.getText(); } - return this.isPageLoaded(); + return this.isElementLoaded(element); } private get treeDumpResult() { @@ -86,5 +86,5 @@ export class BasePage { } // Default timeout for waitForPageLoaded command in PageObject - private waitforPageTimeout: number = 10000; + private waitforPageTimeout: number = 60000; } diff --git a/packages/E2ETest/wdio/pages/ControlStylePage.ts b/packages/E2ETest/wdio/pages/ControlStylePage.ts index 1d95975d583..ab0995d90a2 100644 --- a/packages/E2ETest/wdio/pages/ControlStylePage.ts +++ b/packages/E2ETest/wdio/pages/ControlStylePage.ts @@ -7,15 +7,6 @@ import { BasePage, By } from './BasePage'; import { SHOWBORDER_ON_CONTROLSTYLE } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class ControlStyleTestPage extends BasePage { - backToHomePage() { - this.homeButton.click(); - this.waitForPageLoaded(); - } - - isPageLoaded() { - return super.isPageLoaded(); - } - toggleControlBorder() { this._controlBorder.click(); } diff --git a/packages/E2ETest/wdio/pages/DirectManipulationPage.ts b/packages/E2ETest/wdio/pages/DirectManipulationPage.ts index 58191f3ba4b..986910e43b6 100644 --- a/packages/E2ETest/wdio/pages/DirectManipulationPage.ts +++ b/packages/E2ETest/wdio/pages/DirectManipulationPage.ts @@ -11,15 +11,6 @@ import { } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class DirectManipulationPage extends BasePage { - backToHomePage() { - this.homeButton.click(); - this.waitForPageLoaded(); - } - - isPageLoaded() { - return super.isPageLoaded() && this.measureInWindowButton.isDisplayed(); - } - clickMeasureInWindowAndGetResult() { this.measureInWindowButton.click(); return this.directManipulationResult.getText(); diff --git a/packages/E2ETest/wdio/pages/HomePage.ts b/packages/E2ETest/wdio/pages/HomePage.ts index da11b578c39..8894972d5f8 100644 --- a/packages/E2ETest/wdio/pages/HomePage.ts +++ b/packages/E2ETest/wdio/pages/HomePage.ts @@ -4,86 +4,24 @@ */ import { BasePage, By } from './BasePage'; -import TextInputTestPage from './TextInputTestPage'; import { - TEXTINPUT_TESTPAGE, - LOGIN_TESTPAGE, - DIRECT_MANIPULATION_TESTPAGE, - IMAGE_TESTPAGE, - CONTROL_STYLE_TESTPAGE, - TRANSFORM_TESTPAGE, + SEARCH_BOX, + BACK_BUTTON, } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; -import LoginPage from './LoginPage'; -import DirectManipulationPage from './DirectManipulationPage'; -import ImageTestPage from './ImageTestPage'; -import ControlStyleTestPage from './ControlStylePage'; class HomePage extends BasePage { - backToHomePage() { - this.homeButton.click(); - this.waitForPageLoaded(); - } - - isPageLoaded() { - return super.isPageLoaded() && this.testInputTestPageButton.isDisplayed(); - } - - clickAndGoToTextInputPage() { - this.testInputTestPageButton.click(); - TextInputTestPage.waitForPageLoaded(); - } - - clickAndGotoLoginPage() { - this.loginTestPageButton.click(); - LoginPage.waitForPageLoaded(); - } - - clickAndGotoDirectManipulationPage() { - this.directManipulationPageButton.click(); - DirectManipulationPage.waitForPageLoaded(); - } - - clickAndGotoImagePage() { - this.ImagePageButton.click(); - ImageTestPage.waitForPageLoaded(); - } - - clickControlStylePageButton() { - this.ControlStylePageButton.click(); - } - - clickAndGotoControlStylePage() { - this.ControlStylePageButton.click(); - ControlStyleTestPage.waitForPageLoaded(); - } - - clickAndGotoTransformTestPage() { - this.TransformTestPageButton.click(); - ControlStyleTestPage.waitForPageLoaded(); - } - - private get testInputTestPageButton() { - return By(TEXTINPUT_TESTPAGE); - } - - private get loginTestPageButton() { - return By(LOGIN_TESTPAGE); + goToTestPage(page: string) { + // Filter the list down to the one test, to improve the stability of selectors + this.waitForElementLoaded(SEARCH_BOX); + let editBox = By(SEARCH_BOX); + editBox.setValue(page); + let pageItem = By(page); + pageItem.click(); + super.waitForElementLoaded(BACK_BUTTON); } - private get directManipulationPageButton() { - return By(DIRECT_MANIPULATION_TESTPAGE); - } - - private get ImagePageButton() { - return By(IMAGE_TESTPAGE); - } - - private get ControlStylePageButton() { - return By(CONTROL_STYLE_TESTPAGE); - } - - private get TransformTestPageButton() { - return By(TRANSFORM_TESTPAGE); + backToHomePage() { + this.homeButton.click(); } } diff --git a/packages/E2ETest/wdio/pages/ImageTestPage.ts b/packages/E2ETest/wdio/pages/ImageTestPage.ts index 1a9c92eb9ba..fc4e2ad0d7e 100644 --- a/packages/E2ETest/wdio/pages/ImageTestPage.ts +++ b/packages/E2ETest/wdio/pages/ImageTestPage.ts @@ -10,15 +10,6 @@ import { } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class ImageTestPage extends BasePage { - backToHomePage() { - this.homeButton.click(); - this.waitForPageLoaded(); - } - - isPageLoaded() { - return super.isPageLoaded(); - } - toggleImageBorder() { this._imageBorder.click(); } diff --git a/packages/E2ETest/wdio/pages/LoginPage.ts b/packages/E2ETest/wdio/pages/LoginPage.ts index 23c883aa31e..39a4721501d 100644 --- a/packages/E2ETest/wdio/pages/LoginPage.ts +++ b/packages/E2ETest/wdio/pages/LoginPage.ts @@ -13,10 +13,6 @@ import { } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class LoginPage extends BasePage { - isPageLoaded() { - return super.isPageLoaded() && this._userName.isDisplayed(); - } - setLoginInfo(userName: string, password: string) { this._userName.setValue(userName); this._password.setValue(password); diff --git a/packages/E2ETest/wdio/pages/TextInputTestPage.ts b/packages/E2ETest/wdio/pages/TextInputTestPage.ts index ec0b92c6f78..a482598e99b 100644 --- a/packages/E2ETest/wdio/pages/TextInputTestPage.ts +++ b/packages/E2ETest/wdio/pages/TextInputTestPage.ts @@ -12,10 +12,6 @@ import { } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class TextInputTestPage extends BasePage { - isPageLoaded() { - return super.isPageLoaded() && this.textInput.isDisplayed(); - } - clickTextInput() { this.textInput.click(); } diff --git a/packages/E2ETest/wdio/pages/TransformTestPage.ts b/packages/E2ETest/wdio/pages/TransformTestPage.ts index 3e0a3516aff..1043bc31045 100644 --- a/packages/E2ETest/wdio/pages/TransformTestPage.ts +++ b/packages/E2ETest/wdio/pages/TransformTestPage.ts @@ -11,15 +11,6 @@ import { } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; class DirectManipulationPage extends BasePage { - backToHomePage() { - this.homeButton.click(); - this.waitForPageLoaded(); - } - - isPageLoaded() { - return super.isPageLoaded() && this.measureLayoutButton.isDisplayed(); - } - clickApplyScaleTransform() { this.applyScaleTransformButton.click(); } diff --git a/packages/E2ETest/wdio/test/AAA_SmokeTest.spec.ts b/packages/E2ETest/wdio/test/AAA_SmokeTest.spec.ts deleted file mode 100644 index 42bdcae7c7e..00000000000 --- a/packages/E2ETest/wdio/test/AAA_SmokeTest.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ -import HomePage from '../pages/HomePage'; - -describe('SmokeTest', () => { - it('SmokeTest', () => { - // Only click the button to try to go to the ControlStyle test page, - // to workaround an instability in WinAppDriver (?) on first test launch, - // which causes the click to not actually work if the control needs to - // first be scrolled into view. - HomePage.clickControlStylePageButton(); - }); -}); diff --git a/packages/E2ETest/wdio/test/DirectManipulation.spec.ts b/packages/E2ETest/wdio/test/DirectManipulation.spec.ts index 9b2743a83c2..e3c832f8cf2 100644 --- a/packages/E2ETest/wdio/test/DirectManipulation.spec.ts +++ b/packages/E2ETest/wdio/test/DirectManipulation.spec.ts @@ -6,9 +6,10 @@ import HomePage from '../pages/HomePage'; import DirectManipulationPage from '../pages/DirectManipulationPage'; import assert from 'assert'; +import { DIRECT_MANIPULATION_TESTPAGE } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; beforeAll(() => { - HomePage.clickAndGotoDirectManipulationPage(); + HomePage.goToTestPage(DIRECT_MANIPULATION_TESTPAGE); }); describe('DirectManipulationTest', () => { diff --git a/packages/E2ETest/wdio/test/Image.spec.ts b/packages/E2ETest/wdio/test/Image.spec.ts index cbab8e95e4a..a81c5876835 100644 --- a/packages/E2ETest/wdio/test/Image.spec.ts +++ b/packages/E2ETest/wdio/test/Image.spec.ts @@ -6,9 +6,10 @@ import HomePage from '../pages/HomePage'; import ImageTestPage from '../pages/ImageTestPage'; import assert from 'assert'; +import { IMAGE_TESTPAGE } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; beforeAll(() => { - HomePage.clickAndGotoImagePage(); + HomePage.goToTestPage(IMAGE_TESTPAGE); }); describe('ImageWithoutBorderTest', () => { diff --git a/packages/E2ETest/wdio/test/TransformTest.spec.ts b/packages/E2ETest/wdio/test/TransformTest.spec.ts index 07336d90fc5..2d530c59021 100644 --- a/packages/E2ETest/wdio/test/TransformTest.spec.ts +++ b/packages/E2ETest/wdio/test/TransformTest.spec.ts @@ -6,9 +6,10 @@ import HomePage from '../pages/HomePage'; import TransformTestPage from '../pages/TransformTestPage'; import assert from 'assert'; +import { TRANSFORM_TESTPAGE } from 'react-native-windows/RNTester/js/examples-win/LegacyTests/Consts'; beforeAll(() => { - HomePage.clickAndGotoTransformTestPage(); + HomePage.goToTestPage(TRANSFORM_TESTPAGE); }); describe('TransformTest', () => { diff --git a/packages/E2ETest/wdio/test/VisitAllPages.spec.ts b/packages/E2ETest/wdio/test/VisitAllPages.spec.ts index a05a184ea8e..43205f0e49c 100644 --- a/packages/E2ETest/wdio/test/VisitAllPages.spec.ts +++ b/packages/E2ETest/wdio/test/VisitAllPages.spec.ts @@ -3,12 +3,10 @@ * Licensed under the MIT License. */ -import { BasePage, By } from '../pages/BasePage'; +import HomePage from '../pages/HomePage'; let pages = [ '', - /* TODO: Disabling most of the test for now due to - instability, tracked by #5661 '