From d2aa4a616eb629c20dae8fd6dcbed66827c203b7 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 17 Oct 2019 15:56:38 +0300 Subject: [PATCH 01/19] chore: bump tns-core-modules-compat (#7972) --- tns-core-modules-package/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tns-core-modules-package/package.json b/tns-core-modules-package/package.json index 9d250cd7c..71981a748 100644 --- a/tns-core-modules-package/package.json +++ b/tns-core-modules-package/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "Telerik NativeScript Core Modules", - "version": "6.1.0", + "version": "6.2.0", "homepage": "https://www.nativescript.org", "repository": { "type": "git", From 07abee748cf5eef1db40c60584e3551bb6e21c27 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Mon, 21 Oct 2019 23:50:55 +0300 Subject: [PATCH 02/19] tests: update gesture tests for api19 and api29 (#7975) --- CONTRIBUTING.md | 15 ++++++++++---- e2e/ui-tests-app/app/package.json | 3 ++- .../gestures/gestures.e2e-spec.ts | 20 +++++++++---------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a278151d..0da6639d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -244,7 +244,14 @@ cd .. 4. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-core-modules`, tag the release and update the CHANGELOG.md. Don't forget to check the auto-generated CHANGELOG.md ``` -cd tns-core-modules +cd nativescript-core +npm --no-git-tag-version version [major|minor|patch] -m "release: cut the %s release" +cd .. + +5. Execute [`npm version`](https://docs.npmjs.com/cli/version) to bump the version of `tns-core-modules`, +tag the release and update the CHANGELOG.md. Don't forget to check the auto-generated CHANGELOG.md +``` +cd tns-core-modules-package npm --no-git-tag-version version [major|minor|patch] -m "release: cut the %s release" cd .. ``` @@ -253,7 +260,7 @@ Usually tns-core-modules-widgets should already have been released and we need t 7. Create release-branch with change log ``` -git checkout -b release-[release-version] +git checkout -b release-[version] ``` 7. Add changes @@ -262,9 +269,9 @@ git add changed-files git commit -m "release: cut the %s release" git push ``` -8. Create git tag +8. Create git tag as git tag 6.3.0 or use git UI ``` -git tag release-version +git tag [release-version] git push --tags ``` 9. Create a pull request. Be careful to base your branch on the correct branch diff --git a/e2e/ui-tests-app/app/package.json b/e2e/ui-tests-app/app/package.json index 24cb7bc4c..c13032ce6 100644 --- a/e2e/ui-tests-app/app/package.json +++ b/e2e/ui-tests-app/app/package.json @@ -1,6 +1,7 @@ { "main": "app.js", "android": { - "v8Flags": "--expose_gc" + "v8Flags": "--expose_gc", + "markingMode": "none" } } diff --git a/e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures.e2e-spec.ts b/e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures.e2e-spec.ts index b7b5a66f1..257d1e89b 100644 --- a/e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures.e2e-spec.ts +++ b/e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures.e2e-spec.ts @@ -44,7 +44,7 @@ describe(`${imagePrefix}-suite`, () => { it("gestures_02_doubleTap", async function () { const lblDoubleTap = await driver.waitForElement("Double Tap here"); - await lblDoubleTap.doubleTap(); + await lblDoubleTap.doubleTap({ x: 20, y: 20 }); const result = await driver.findElementByTextIfExists("Double Tap gesture detected, true", SearchOptions.contains); assert.isTrue(result != null && result !== undefined, `Gestures event 'Double Tap gesture detected, true' not detected!`); }); @@ -59,7 +59,7 @@ describe(`${imagePrefix}-suite`, () => { it("gestures_longPress", async function () { const lblTapOrDoubleTap = await driver.waitForElement("Tap or Double Tap"); const rect = await lblTapOrDoubleTap.getRectangle(); - await lblTapOrDoubleTap.doubleTap(); + await lblTapOrDoubleTap.doubleTap({ x: 20, y: 20 }); let result = await driver.findElementByTextIfExists("Last action: Double tap gesture, true", SearchOptions.contains); assert.isTrue(result != null && result !== undefined, `Gestures event 'Last action: Double tap gesture, true' not detected!`); await driver.clickPoint(rect.x, rect.y); @@ -76,23 +76,23 @@ describe(`${imagePrefix}-suite`, () => { it("gestures_05_pan", async function () { const lblSwipe = await driver.waitForElement("Pan here"); - const rect = await lblSwipe.getRectangle(); await lblSwipe.pan([ - { x: rect.x + 100, y: rect.y + 100 }, - { x: rect.x + 140, y: rect.y + 120 }, - { x: rect.x + 160, y: rect.y + 120 } - ], { x: 50, y: 50 }); + { x: 10, y: 20 }, + { x: 40, y: 30 }, + { x: 50, y: 60 } + ], { x: 5, y: 5 }); const result = await driver.findElementByTextIfExists("Pan deltaX", SearchOptions.contains); const text = await result.text(); - assert.isTrue(/Pan deltaX:\d+; deltaY:\d+;, true, states: ended/.test(text), `Gestures event 'Pan deltaX: ...' not detected!`); + assert.isTrue(/Pan deltaX:([-+]?)\d+; deltaY:([-+]?)\d+;, true, states: ended/ig.test(text), `Gestures event 'Pan deltaX: ...' not detected!`); }); it("gestures_06_pinch", async function () { const lblPan = await driver.waitForElement("Pinch here"); await lblPan.pinch("out"); - const result = await driver.findElementByTextIfExists("Pinch Scale: 1, true, states: ended", SearchOptions.contains); - assert.isTrue(result != null && result !== undefined, `Gestures event '"Pinch Scale: 0, true, states: ended"' not detected!`); + const result = await driver.findElementByTextIfExists("Pinch Scale:", SearchOptions.contains); + const text = await result.text(); + assert.isTrue(/Pinch Scale: \d+, true, states: ended/ig.test(text), `Gestures event '"Pinch Scale: 0, true, states: ended"' not detected!`); }); it("gestures_07_rotate", async function () { From bfea96fbc06924c503c322d29116a82e04a465ea Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Tue, 22 Oct 2019 13:54:02 +0300 Subject: [PATCH 03/19] fix-next(css-classes): increase application CSS selector version at runtime (#7992) --- nativescript-core/application/application-common.ts | 10 ++++++++++ nativescript-core/ui/styling/style-scope.d.ts | 4 ++++ nativescript-core/ui/styling/style-scope.ts | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/nativescript-core/application/application-common.ts b/nativescript-core/application/application-common.ts index 536013ed4..10de66855 100644 --- a/nativescript-core/application/application-common.ts +++ b/nativescript-core/application/application-common.ts @@ -142,6 +142,14 @@ function removeCssClass(rootView: View, cssClass: string) { rootView.cssClasses.delete(cssClass); } +function increaseStyleScopeApplicationCssSelectorVersion(rootView: View) { + const styleScope = rootView._styleScope || ((rootView).currentPage && (rootView).currentPage._styleScope); + + if (styleScope) { + styleScope._increaseApplicationCssSelectorVersion(); + } +} + export function orientationChanged(rootView: View, newOrientation: "portrait" | "landscape" | "unknown"): void { if (!rootView) { return; @@ -151,6 +159,7 @@ export function orientationChanged(rootView: View, newOrientation: "portrait" | if (!rootView.cssClasses.has(newOrientationCssClass)) { ORIENTATION_CSS_CLASSES.forEach(cssClass => removeCssClass(rootView, cssClass)); applyCssClass(rootView, newOrientationCssClass); + increaseStyleScopeApplicationCssSelectorVersion(rootView); rootView._onCssStateChange(); } } @@ -164,6 +173,7 @@ export function systemAppearanceChanged(rootView: View, newSystemAppearance: "da if (!rootView.cssClasses.has(newSystemAppearanceCssClass)) { SYSTEM_APPEARANCE_CSS_CLASSES.forEach(cssClass => removeCssClass(rootView, cssClass)); applyCssClass(rootView, newSystemAppearanceCssClass); + increaseStyleScopeApplicationCssSelectorVersion(rootView); rootView._onCssStateChange(); } } diff --git a/nativescript-core/ui/styling/style-scope.d.ts b/nativescript-core/ui/styling/style-scope.d.ts index 4ea0bda82..b43e2b316 100644 --- a/nativescript-core/ui/styling/style-scope.d.ts +++ b/nativescript-core/ui/styling/style-scope.d.ts @@ -36,6 +36,10 @@ export class StyleScope { public static createSelectorsFromImports(tree: SyntaxTree, keyframes: Object): RuleSet[]; public ensureSelectors(): number; + /** + * Increase the application CSS selector version. + */ + public _increaseApplicationCssSelectorVersion(): void; public isApplicationCssSelectorsLatestVersionApplied(): boolean; public isLocalCssSelectorsLatestVersionApplied(): boolean; diff --git a/nativescript-core/ui/styling/style-scope.ts b/nativescript-core/ui/styling/style-scope.ts index 084eedfa6..6105cff89 100644 --- a/nativescript-core/ui/styling/style-scope.ts +++ b/nativescript-core/ui/styling/style-scope.ts @@ -760,6 +760,10 @@ export class StyleScope { return this._getSelectorsVersion(); } + public _increaseApplicationCssSelectorVersion(): void { + applicationCssSelectorVersion++; + } + public isApplicationCssSelectorsLatestVersionApplied(): boolean { return this._applicationCssSelectorsAppliedVersion === applicationCssSelectorVersion; } From 2412c0b6f574319ff25625132d7223330b9d5e37 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 22 Oct 2019 16:54:24 +0300 Subject: [PATCH 04/19] tests: fox modal navidation (#7997) --- e2e/modal-navigation/.vscode/launch.json | 35 +++++++++++++++-------- e2e/modal-navigation/e2e/screen.ts | 36 ++++++++++++------------ 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/e2e/modal-navigation/.vscode/launch.json b/e2e/modal-navigation/.vscode/launch.json index a017624a8..7a7dceac9 100644 --- a/e2e/modal-navigation/.vscode/launch.json +++ b/e2e/modal-navigation/.vscode/launch.json @@ -4,6 +4,25 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "node", + "request": "launch", + "name": "debug tests", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-u", + "tdd", + "--timeout", + "999999", + "--colors", + "--opts", + "../config/mocha.opts", + "-a", + "--grep", + "modal-frame:" + ], + "internalConsoleOptions": "openOnSessionStart" + }, { "type": "node", "request": "launch", @@ -15,13 +34,9 @@ "--timeout", "999999", "--colors", - // "${workspaceFolder}/test", "--opts", - "./e2e/config/mocha.opts", - "--runType", - "android23", - "--reuseDevice", - "--verbose" + "../config/mocha.opts", + "android" ], "internalConsoleOptions": "openOnSessionStart" }, @@ -36,13 +51,9 @@ "--timeout", "999999", "--colors", - // "${workspaceFolder}/test", "--opts", - "./e2e/config/mocha.opts", - "--runType", - "sim.iPhoneX.iOS112", - "--reuseDevice", - "--verbose" + "../config/mocha.opts", + "ios" ], "internalConsoleOptions": "openOnSessionStart" }, diff --git a/e2e/modal-navigation/e2e/screen.ts b/e2e/modal-navigation/e2e/screen.ts index ac2d22ae8..006de4e7e 100644 --- a/e2e/modal-navigation/e2e/screen.ts +++ b/e2e/modal-navigation/e2e/screen.ts @@ -48,18 +48,18 @@ export class Screen { resetFrameRootView = async () => { console.log("Setting frame root ..."); const btnResetFrameRootView = await this._driver.waitForElement(resetFrameRootView); - await btnResetFrameRootView.tap(); + await btnResetFrameRootView.click(); } resetLayoutRootView = async () => { console.log("Setting layout root ..."); const btnResetLayoutRootView = await this._driver.waitForElement(resetLayoutRootView); - await btnResetLayoutRootView.tap(); + await btnResetLayoutRootView.click(); } resetTabRootView = async () => { const btnResetTabRootView = await this._driver.waitForElement(resetTabRootView); - await btnResetTabRootView.tap(); + await btnResetTabRootView.click(); } loadedTabRootView = async () => { @@ -93,7 +93,7 @@ export class Screen { showModalFrame = async () => { const btnModalFrame = await this._driver.waitForElement(modalFrame); - await btnModalFrame.tap(); + await btnModalFrame.click(); } loadedModalFrame = async () => { @@ -104,7 +104,7 @@ export class Screen { showModalPage = async () => { const btnModalPage = await this._driver.waitForElement(modalPage); - await btnModalPage.tap(); + await btnModalPage.click(); } loadedModalPage = async () => { @@ -115,7 +115,7 @@ export class Screen { showModalLayout = async () => { const btnModalLayout = await this._driver.waitForElement(modalLayout); - await btnModalLayout.tap(); + await btnModalLayout.click(); } loadedModalLayout = async () => { @@ -124,7 +124,7 @@ export class Screen { showModalTabView = async () => { const btnModalTabView = await this._driver.waitForElement(modalTabView); - await btnModalTabView.tap(); + await btnModalTabView.click(); } loadedModalTabView = async () => { @@ -134,23 +134,23 @@ export class Screen { } navigateToSecondPage = async () => { - const btnNavToSecondPage = await this._driver.waitForElement(navToSecondPage); - await btnNavToSecondPage.tap(); + const btnNavToSecondPage = await this._driver.findElementByText(navToSecondPage); + await btnNavToSecondPage.click(); } showDialogConfirm = async () => { const btnShowDialogConfirm = await this._driver.waitForElement(showDialog); - await btnShowDialogConfirm.tap(); + await btnShowDialogConfirm.click(); } navigateToFirstItem = async () => { const itemModalFirst = await this._driver.waitForElement(modalFirst); - await itemModalFirst.tap(); + await itemModalFirst.click(); } navigateToSecondItem = async () => { const itemModalSecond = await this._driver.waitForElement(modalSecond); - await itemModalSecond.tap(); + await itemModalSecond.click(); } loadedConfirmDialog = async () => { @@ -179,17 +179,17 @@ export class Screen { closeDialog = async () => { const btnYesDialog = await this._driver.waitForElement(confirmDialog); - await btnYesDialog.tap(); + await btnYesDialog.click(); } goBackFromSecondPage = async () => { const btnGoBackFromSecondPage = await this._driver.waitForElement(goBack); - await btnGoBackFromSecondPage.tap(); + await btnGoBackFromSecondPage.click(); } showNestedModalFrame = async () => { const btnShowNestedModalFrame = await this._driver.waitForElement(showNestedModalFrame); - await btnShowNestedModalFrame.tap(); + await btnShowNestedModalFrame.click(); } loadedNestedModalFrame = async () => { @@ -200,12 +200,12 @@ export class Screen { closeModalNested = async () => { const btnCloseNestedModal = await this._driver.waitForElement(closeModalNested); - await btnCloseNestedModal.tap(); + await btnCloseNestedModal.click(); } showNestedModalPage = async () => { const btnShowNestedModalPage = await this._driver.waitForElement(showNestedModalPage); - await btnShowNestedModalPage.tap(); + await btnShowNestedModalPage.click(); } loadedNestedModalPage = async () => { @@ -216,7 +216,7 @@ export class Screen { closeModal = async () => { const btnCloseModal = await this._driver.waitForElement(closeModal); - await btnCloseModal.tap(); + await btnCloseModal.click(); } loadModalFrame = async () => { From ae6c02258e242e4cd7e3afe4f52ce3b57be7cdf2 Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Tue, 22 Oct 2019 16:57:32 +0300 Subject: [PATCH 05/19] chore: add re-exports for ts files (#7993) --- build/generate-tns-compat.ts | 12 + .../app/generated-tests/tests.ts | 244 ++++++++++++++++++ e2e/scoped-packages/package.json | 2 +- 3 files changed, 257 insertions(+), 1 deletion(-) diff --git a/build/generate-tns-compat.ts b/build/generate-tns-compat.ts index f2b4ea837..480034eb4 100644 --- a/build/generate-tns-compat.ts +++ b/build/generate-tns-compat.ts @@ -81,6 +81,13 @@ function processDefinitionFile(entry: EntryInfo) { } } +function processTypeScriptFile(entry: EntryInfo) { + const relativeFilePathNoExt = entry.path.replace(/\.ts$/, ""); + + createReExportFile(relativeFilePathNoExt, ".ts"); + addTestImport(relativeFilePathNoExt); +} + function createReExportFile(pathNoExt: string, ext: ".ts" | ".d.ts") { const outputFile = path.join(outputFolder, pathNoExt + ext); if (!fs.existsSync(outputFile)) { @@ -162,6 +169,11 @@ function generateExportsForPrivateModules() { // * .ts file with re-exports for the corresponding ts/js file (is such exists) await traverseInputDir(["*.d.ts"], processDefinitionFile); + console.log(" ------> GENERATING FILES FROM TYPESCRIPT"); + // Traverse all ts files which are not platform specific and create + // * .ts file with re-exports for the corresponding ts file + await traverseInputDir(["*(? Date: Tue, 22 Oct 2019 22:09:17 +0300 Subject: [PATCH 06/19] refactor: android.R to const for performance reasons (#8003) --- nativescript-core/ui/core/view/view.android.ts | 3 ++- nativescript-core/ui/frame/fragment.transitions.android.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nativescript-core/ui/core/view/view.android.ts b/nativescript-core/ui/core/view/view.android.ts index 7d6d6e20a..5b42e0047 100644 --- a/nativescript-core/ui/core/view/view.android.ts +++ b/nativescript-core/ui/core/view/view.android.ts @@ -33,6 +33,7 @@ const androidBackPressedEvent = "androidBackPressed"; const shortAnimTime = 17694720; // android.R.integer.config_shortAnimTime const statePressed = 16842919; // android.R.attr.state_pressed const stateEnabled = 16842910; // android.R.attr.state_enabled +const styleAnimationDialog = 16973826; // android.R.style.Animation_Dialog const sdkVersion = lazy(() => parseInt(device.sdkVersion)); @@ -187,7 +188,7 @@ function initializeDialogFragment() { dialog .getWindow() .setWindowAnimations( - android.R.style.Animation_Dialog + styleAnimationDialog ); } diff --git a/nativescript-core/ui/frame/fragment.transitions.android.ts b/nativescript-core/ui/frame/fragment.transitions.android.ts index 266dea6a7..6b024cd47 100644 --- a/nativescript-core/ui/frame/fragment.transitions.android.ts +++ b/nativescript-core/ui/frame/fragment.transitions.android.ts @@ -17,6 +17,9 @@ interface TransitionListener { const defaultInterpolator = lazy(() => new android.view.animation.AccelerateDecelerateInterpolator()); +const animFadeIn = 17432576; // android.R.anim.fade_in +const animFadeOut = 17432577; // android.R.anim.fade_out + export const waitingQueue = new Map>(); export const completedEntries = new Map(); @@ -105,7 +108,7 @@ export function _setAndroidFragmentTransitions( // Also setup empty/immediate transition to be executed when navigating back to this page. // TODO: Consider removing empty/immediate animator when migrating to official androidx.fragment.app.Fragment:1.2. if (isNestedDefaultTransition) { - fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); + fragmentTransaction.setCustomAnimations(animFadeIn, animFadeOut); setupAllAnimation(newEntry, noTransition); setupNewFragmentCustomTransition({ duration: 0, curve: null }, newEntry, noTransition); } else { From aacfce58acfb4bcf7f1f6f708fc0f44282588340 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Wed, 23 Oct 2019 10:32:57 +0300 Subject: [PATCH 07/19] refactor: deprecated goBack() usage (#8002) --- nativescript-core/ui/frame/frame.android.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nativescript-core/ui/frame/frame.android.ts b/nativescript-core/ui/frame/frame.android.ts index f8270d93b..096adb628 100644 --- a/nativescript-core/ui/frame/frame.android.ts +++ b/nativescript-core/ui/frame/frame.android.ts @@ -9,7 +9,7 @@ import { Page } from "../page"; import * as application from "../../application"; import { - _stack, FrameBase, goBack, NavigationType, Observable, + _stack, FrameBase, NavigationType, Observable, traceCategories, traceEnabled, traceError, traceWrite, View } from "./frame-common"; @@ -1189,7 +1189,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { const view = this._rootView; let callSuper = false; if (view instanceof Frame) { - callSuper = !goBack(); + callSuper = !FrameBase.goBack(); } else { const viewArgs = { eventName: "activityBackPressed", From 7e87fe001821e3098e74409570e098ff0c32fcb2 Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Wed, 23 Oct 2019 11:01:35 +0300 Subject: [PATCH 08/19] chore(hook): Add check for min webpack v1.3.0 (#7998) --- .../cli-hooks/before-checkForChanges.js | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/nativescript-core/cli-hooks/before-checkForChanges.js b/nativescript-core/cli-hooks/before-checkForChanges.js index eb525cb95..ec2735fe3 100644 --- a/nativescript-core/cli-hooks/before-checkForChanges.js +++ b/nativescript-core/cli-hooks/before-checkForChanges.js @@ -1,13 +1,62 @@ const semver = require("semver"); +const webpackPackageName = "nativescript-dev-webpack"; + module.exports = function ($staticConfig, hookArgs) { const cliVersion = semver.parse($staticConfig.version); - const majorVersion = cliVersion && cliVersion.major; - const minorVersion = cliVersion && cliVersion.minor; const platfrom = hookArgs.prepareData.platform; + const projectData = hookArgs.projectData; + // Required CLI version for building IOS: 6.2.0 if (platfrom.toLowerCase() === "ios" && - (majorVersion < 6 || (majorVersion === 6 && minorVersion < 2))) { + !satisfiesRequriredVersion(cliVersion, 6, 2)) { throw new Error(`Building @nativescript/core for iOS requires NativeScript CLI with version at least 6.2.0. Please upgrade your NativeScript CLI version (npm i -g nativescript).`); } + + // Required webpack version for angular projects: 1.3.0 + if (projectData.projectType === "Angular") { + const webpackMinVer = getMinWebpackVersion(projectData); + + if (webpackMinVer && !satisfiesRequriredVersion(webpackMinVer, 1, 3)) { + throw new Error(`Building @nativescript/core for Angular requires ${webpackPackageName} with version at least 1.3.0. Please upgrade: npm i ${webpackPackageName} --save-dev.`); + } + } }; + +/** + * Checks if semver object satisifies a major/minor requirement. Pre-release versions are OK too! + */ +function satisfiesRequriredVersion(actualVersion, requiredMajor, requiredMinor) { + // Return true for null version to handle tags (ex. "next", "rc") + if (!actualVersion) { + return true; + } + + if (actualVersion.major < requiredMajor) { + return false; + } + + if (actualVersion.major === requiredMajor && actualVersion.minor < requiredMinor) { + return false; + } + + return true; +} + +function getMinWebpackVersion(projectData) { + const devDependencies = projectData.devDependencies || {}; + const dependencies = projectData.dependencies || {}; + const webpackVer = dependencies[webpackPackageName] || devDependencies[webpackPackageName]; + + let webpackMinVer = null; + + if (semver.valid(webpackVer)) { + webpackMinVer = semver.parse(webpackVer); + } else if (semver.validRange(webpackVer)) { + webpackMinVer = semver.minVersion(webpackVer); + } else { + webpackMinVer = semver.coerce(webpackVer); + } + + return webpackMinVer; +} \ No newline at end of file From c9bfec1cbe20c58c7a5925fa62d8908032c5a77f Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Wed, 23 Oct 2019 13:31:19 +0300 Subject: [PATCH 09/19] fix(ios-bot-nav): incorrect layout on orientation change (#7927) --- .../bottom-navigation.android.ts | 6 +-- .../bottom-navigation.ios.ts | 51 ++++++++++++------- .../tab-strip-item/tab-strip-item.d.ts | 6 +++ .../tab-strip-item/tab-strip-item.ts | 3 +- nativescript-core/ui/tabs/tabs.android.ts | 10 ++-- nativescript-core/ui/tabs/tabs.ios.ts | 8 +-- 6 files changed, 54 insertions(+), 30 deletions(-) diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts index 6601ecded..ba8f96ff7 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts @@ -547,8 +547,8 @@ export class BottomNavigation extends TabNavigationBase { } const tabItems = new Array(); - items.forEach((item, i, arr) => { - (item).index = i; + items.forEach((tabStripItem, i, arr) => { + tabStripItem._index = i; if (items[i]) { const tabItemSpec = this.createTabItemSpec(items[i]); tabItems.push(tabItemSpec); @@ -699,7 +699,7 @@ export class BottomNavigation extends TabNavigationBase { } public setTabBarIconColor(tabStripItem: TabStripItem, value: number | Color): void { - const index = (tabStripItem).index; + const index = tabStripItem._index; const tabBarItem = this._bottomNavigationBar.getViewForItemAt(index); const imgView = tabBarItem.getChildAt(0); const drawable = this.getIcon(tabStripItem); diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts index 2e77299d2..b5e06d67a 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts @@ -72,12 +72,19 @@ class UITabBarControllerImpl extends UITabBarController { public viewWillTransitionToSizeWithTransitionCoordinator(size: CGSize, coordinator: UIViewControllerTransitionCoordinator): void { super.viewWillTransitionToSizeWithTransitionCoordinator(size, coordinator); UIViewControllerTransitionCoordinator.prototype.animateAlongsideTransitionCompletion - .call(coordinator, null, () => { + .call(coordinator, () => { const owner = this._owner.get(); - if (owner && owner.items) { - // owner.items.forEach(tabItem => tabItem._updateTitleAndIconPositions()); TODO: + if (owner && owner.tabStrip && owner.tabStrip.items) { + const tabStrip = owner.tabStrip; + tabStrip.items.forEach(tabStripItem => { + updateBackgroundPositions(tabStrip, tabStripItem); + + const index = tabStripItem._index; + const tabBarItemController = this.viewControllers[index]; + updateTitleAndIconPositions(tabStripItem, tabBarItemController.tabBarItem, tabBarItemController); + }); } - }); + }, null); } // Mind implementation for other controllers @@ -213,6 +220,26 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio } } +function updateBackgroundPositions(tabStrip: TabStrip, tabStripItem: TabStripItem) { + let bgView = (tabStripItem).bgView; + if (!bgView) { + const index = tabStripItem._index; + const width = tabStrip.nativeView.frame.size.width / tabStrip.items.length; + const frame = CGRectMake(width * index, 0, width, tabStrip.nativeView.frame.size.width); + bgView = UIView.alloc().initWithFrame(frame); + tabStrip.nativeView.insertSubviewAtIndex(bgView, 0); + (tabStripItem).bgView = bgView; + } else { + const index = tabStripItem._index; + const width = tabStrip.nativeView.frame.size.width / tabStrip.items.length; + const frame = CGRectMake(width * index, 0, width, tabStrip.nativeView.frame.size.width); + bgView.frame = frame; + } + + const backgroundColor = tabStripItem.style.backgroundColor; + bgView.backgroundColor = backgroundColor instanceof Color ? backgroundColor.ios : backgroundColor; +} + function updateTitleAndIconPositions(tabStripItem: TabStripItem, tabBarItem: UITabBarItem, controller: UIViewController) { if (!tabStripItem || !tabBarItem) { return; @@ -345,21 +372,11 @@ export class BottomNavigation extends TabNavigationBase { } public setTabBarItemBackgroundColor(tabStripItem: TabStripItem, value: UIColor | Color): void { - if (!this.tabStrip) { + if (!this.tabStrip || !tabStripItem) { return; } - let bgView = (tabStripItem).bgView; - if (!bgView) { - const index = (tabStripItem).index; - const width = this.tabStrip.nativeView.frame.size.width / this.tabStrip.items.length; - const frame = CGRectMake(width * index, 0, width, this.tabStrip.nativeView.frame.size.width); - bgView = UIView.alloc().initWithFrame(frame); - this.tabStrip.nativeView.insertSubviewAtIndex(bgView, 0); - (tabStripItem).bgView = bgView; - } - - bgView.backgroundColor = value instanceof Color ? value.ios : value; + updateBackgroundPositions(this.tabStrip, tabStripItem); } public setTabBarItemColor(tabStripItem: TabStripItem, value: UIColor | Color): void { @@ -509,7 +526,7 @@ export class BottomNavigation extends TabNavigationBase { applyStatesToItem(tabBarItem, states); controller.tabBarItem = tabBarItem; - (tabStripItem).index = i; + tabStripItem._index = i; tabStripItem.setNativeView(tabBarItem); } diff --git a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts index c25b7d85f..b9b8d0721 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.d.ts @@ -37,6 +37,12 @@ export class TabStripItem extends View { public static tapEvent: string; //@private + + /** + * @private + */ + _index: number; + /** * @private */ diff --git a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts index 913d11179..09ea676e7 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts @@ -26,6 +26,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi public image: Image; public label: Label; + public _index: number; private _title: string; private _iconSource: string; @@ -211,7 +212,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi const parent = this.parent; const tabStripParent = parent && parent.parent; - if ((this).index === tabStripParent.selectedIndex && + if (this._index === tabStripParent.selectedIndex && !(isIOS && tabStripParent instanceof Tabs)) { this._goToVisualState("highlighted"); } diff --git a/nativescript-core/ui/tabs/tabs.android.ts b/nativescript-core/ui/tabs/tabs.android.ts index 18d1745a0..f2ee8e65b 100644 --- a/nativescript-core/ui/tabs/tabs.android.ts +++ b/nativescript-core/ui/tabs/tabs.android.ts @@ -617,10 +617,10 @@ export class Tabs extends TabsBase { } const tabItems = new Array(); - items.forEach((item: TabStripItem, i, arr) => { - (item).index = i; - const tabItemSpec = this.createTabItemSpec(item); - (item).tabItemSpec = tabItemSpec; + items.forEach((tabStripItem: TabStripItem, i, arr) => { + tabStripItem._index = i; + const tabItemSpec = this.createTabItemSpec(tabStripItem); + (tabStripItem).tabItemSpec = tabItemSpec; tabItems.push(tabItemSpec); }); @@ -808,7 +808,7 @@ export class Tabs extends TabsBase { } public setTabBarIconColor(tabStripItem: TabStripItem, value: number | Color): void { - const index = (tabStripItem).index; + const index = tabStripItem._index; const tabBarItem = this._tabsBar.getViewForItemAt(index); const imgView = tabBarItem.getChildAt(0); const drawable = this.getIcon(tabStripItem); diff --git a/nativescript-core/ui/tabs/tabs.ios.ts b/nativescript-core/ui/tabs/tabs.ios.ts index 274b203fd..d7d622371 100644 --- a/nativescript-core/ui/tabs/tabs.ios.ts +++ b/nativescript-core/ui/tabs/tabs.ios.ts @@ -848,11 +848,11 @@ export class Tabs extends TabsBase { const tabBarItems = []; - items.forEach((item: TabStripItem, i) => { - (item).index = i; - const tabBarItem = this.createTabBarItem(item, i); + items.forEach((tabStripItem: TabStripItem, i) => { + tabStripItem._index = i; + const tabBarItem = this.createTabBarItem(tabStripItem, i); tabBarItems.push(tabBarItem); - item.setNativeView(tabBarItem); + tabStripItem.setNativeView(tabBarItem); }); this.tabBarItems = tabBarItems; From beca1c88281531e3bdca51069ec99e9dfc829a91 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Thu, 24 Oct 2019 10:15:03 +0300 Subject: [PATCH 10/19] fix-next(iOS): set root viewe css classes before setup UI (#8005) At application launch, `ns-root` class is not set when loading the theme. --- .../application/application.ios.ts | 25 +++++++++++-------- nativescript-core/css/system-classes.d.ts | 5 ---- nativescript-core/css/system-classes.ts | 5 ---- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/nativescript-core/application/application.ios.ts b/nativescript-core/application/application.ios.ts index 4f7a6a4f5..06c5a37a9 100644 --- a/nativescript-core/application/application.ios.ts +++ b/nativescript-core/application/application.ios.ts @@ -22,8 +22,7 @@ import { Builder } from "../ui/builder"; import { CLASS_PREFIX, getRootViewCssClasses, - pushToRootViewCssClasses, - resetRootViewCssClasses + pushToRootViewCssClasses } from "../css/system-classes"; import { ios as iosView, View } from "../ui/core/view"; @@ -308,7 +307,7 @@ class IOSApplication implements IOSApplicationDefinition { this._window.makeKeyAndVisible(); } - setupRootViewCssClasses(rootView); + setRootViewSystemAppearanceCssClass(rootView); rootView.on(iosView.traitCollectionColorAppearanceChangedEvent, () => { const userInterfaceStyle = controller.traitCollection.userInterfaceStyle; const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle); @@ -356,6 +355,8 @@ function createRootView(v?: View) { } } + setRootViewCssClasses(rootView); + return rootView; } @@ -398,7 +399,7 @@ export function _start(entry?: string | NavigationEntry) { // Mind root view CSS classes in future work // on embedding NativeScript applications - setupRootViewCssClasses(rootView); + setRootViewSystemAppearanceCssClass(rootView); rootView.on(iosView.traitCollectionColorAppearanceChangedEvent, () => { const userInterfaceStyle = controller.traitCollection.userInterfaceStyle; const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle); @@ -482,22 +483,24 @@ function setViewControllerView(view: View): void { } } -function setupRootViewCssClasses(rootView: View): void { - resetRootViewCssClasses(); - +function setRootViewCssClasses(rootView: View): void { const deviceType = device.deviceType.toLowerCase(); pushToRootViewCssClasses(`${CLASS_PREFIX}${IOS_PLATFORM}`); pushToRootViewCssClasses(`${CLASS_PREFIX}${deviceType}`); pushToRootViewCssClasses(`${CLASS_PREFIX}${iosApp.orientation}`); - if (majorVersion >= 13) { - pushToRootViewCssClasses(`${CLASS_PREFIX}${iosApp.systemAppearance}`); - } - const rootViewCssClasses = getRootViewCssClasses(); rootViewCssClasses.forEach(c => rootView.cssClasses.add(c)); } +function setRootViewSystemAppearanceCssClass(rootView: View): void { + if (majorVersion >= 13) { + const systemAppearanceCssClass = `${CLASS_PREFIX}${iosApp.systemAppearance}`; + pushToRootViewCssClasses(systemAppearanceCssClass); + rootView.cssClasses.add(systemAppearanceCssClass); + } +} + export function orientation(): "portrait" | "landscape" | "unknown" { return iosApp.orientation; } diff --git a/nativescript-core/css/system-classes.d.ts b/nativescript-core/css/system-classes.d.ts index 740854fec..cbef8e46d 100644 --- a/nativescript-core/css/system-classes.d.ts +++ b/nativescript-core/css/system-classes.d.ts @@ -28,8 +28,3 @@ export function pushToRootViewCssClasses(value: string): number; * @param value */ export function removeFromRootViewCssClasses(value: string): string; - -/** - * Resets CSS classes for root view. - */ -export function resetRootViewCssClasses(): string[]; diff --git a/nativescript-core/css/system-classes.ts b/nativescript-core/css/system-classes.ts index de763e55b..6e2f7e80c 100644 --- a/nativescript-core/css/system-classes.ts +++ b/nativescript-core/css/system-classes.ts @@ -30,8 +30,3 @@ export function removeFromRootViewCssClasses(value: string): string { return removedElement; } - -export function resetRootViewCssClasses(): string[] { - // Preserve the default `ns-root` CSS class - return rootViewCssClasses.splice(1); -} From d6bd90fd34ad7c13b4efad8532b68f1c2b2202ad Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Thu, 24 Oct 2019 13:23:24 +0300 Subject: [PATCH 11/19] chore: more forgiving verions check hook (#8009) --- nativescript-core/cli-hooks/before-checkForChanges.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/nativescript-core/cli-hooks/before-checkForChanges.js b/nativescript-core/cli-hooks/before-checkForChanges.js index ec2735fe3..ada6a55fe 100644 --- a/nativescript-core/cli-hooks/before-checkForChanges.js +++ b/nativescript-core/cli-hooks/before-checkForChanges.js @@ -54,8 +54,6 @@ function getMinWebpackVersion(projectData) { webpackMinVer = semver.parse(webpackVer); } else if (semver.validRange(webpackVer)) { webpackMinVer = semver.minVersion(webpackVer); - } else { - webpackMinVer = semver.coerce(webpackVer); } return webpackMinVer; From 640590627b926101ea722d18087b3a091f1b8423 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Fri, 25 Oct 2019 18:00:37 +0300 Subject: [PATCH 12/19] refactor(dev-tools): replace topmost() usage (#8013) --- nativescript-core/debugger/devtools-elements.common.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nativescript-core/debugger/devtools-elements.common.ts b/nativescript-core/debugger/devtools-elements.common.ts index 2e65afedc..5abfb667d 100644 --- a/nativescript-core/debugger/devtools-elements.common.ts +++ b/nativescript-core/debugger/devtools-elements.common.ts @@ -4,9 +4,6 @@ import { getNodeById } from "./dom-node"; import { ViewBase } from "../ui/core/view-base"; import { mainThreadify } from "../utils/utils"; -// Use lazy requires for core modules -const frameTopmost = () => require("../ui/frame").topmost(); - let unsetValue; function unsetViewValue(view, name) { if (!unsetValue) { @@ -27,7 +24,7 @@ function getViewById(nodeId: number): ViewBase { } export function getDocument() { - const topMostFrame = frameTopmost(); + const topMostFrame = require("../ui/frame").Frame.topmost(); if (!topMostFrame) { return undefined; } From 85b92b013615fee64f8b0cc9cb7f378a624f4e2f Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Mon, 28 Oct 2019 14:10:40 +0200 Subject: [PATCH 13/19] fix-next(css-class): set class before showing window (#8022) --- nativescript-core/application/application.ios.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nativescript-core/application/application.ios.ts b/nativescript-core/application/application.ios.ts index 06c5a37a9..13efff29b 100644 --- a/nativescript-core/application/application.ios.ts +++ b/nativescript-core/application/application.ios.ts @@ -300,14 +300,18 @@ class IOSApplication implements IOSApplicationDefinition { // setup view as styleScopeHost rootView._setupAsRootView({}); } + setViewControllerView(rootView); + const haveController = this._window.rootViewController !== null; this._window.rootViewController = controller; + + setRootViewSystemAppearanceCssClass(rootView); + if (!haveController) { this._window.makeKeyAndVisible(); } - setRootViewSystemAppearanceCssClass(rootView); rootView.on(iosView.traitCollectionColorAppearanceChangedEvent, () => { const userInterfaceStyle = controller.traitCollection.userInterfaceStyle; const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle); From a61de80a354cf9633a4dc8fc6ac2e97f26ffe5f8 Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Tue, 29 Oct 2019 17:01:05 +0200 Subject: [PATCH 14/19] fix(bottom-navigation-android): crash when changing tab and suspending app (#8030) --- .../ui/bottom-navigation/bottom-navigation.android.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts index ba8f96ff7..077a4096c 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.android.ts @@ -380,9 +380,7 @@ export class BottomNavigation extends TabNavigationBase { this._bottomNavigationBar.setVisibility(android.view.View.GONE); } - if (this._attachedToWindow) { - this.changeTab(this.selectedIndex); - } + this.changeTab(this.selectedIndex); } _onAttachedToWindow(): void { @@ -467,8 +465,9 @@ export class BottomNavigation extends TabNavigationBase { // TODO: Should we extract adapter-like class? // TODO: Rename this? public changeTab(index: number) { - // this is the case when there are no items - if (index === -1) { + // index is -1 when there are no items + // bot nav is not attached if you change the tab too early + if (index === -1 || !this._attachedToWindow) { return; } From 696280dc338b1710b62ad1b3aa66d369d7752ea1 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 29 Oct 2019 20:59:35 +0200 Subject: [PATCH 15/19] chore: cut the 6.2.0 release (#8011) --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dc5973a5..788d329cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,36 @@ + +# [6.2.0](https://github.com/NativeScript/NativeScript/compare/6.1.2...6.2.0) (2019-10-24) + + +### Bug Fixes + +* **action-bar:** font icon support to NavigationButton ([#7842](https://github.com/NativeScript/NativeScript/issues/7842)) ([4991e6d](https://github.com/NativeScript/NativeScript/commit/4991e6d)) ([#7918](https://github.com/NativeScript/NativeScript/issues/7918)) ([bdb411f](https://github.com/NativeScript/NativeScript/commit/bdb411f)) +* **action-bar-ios13:** action bar items population ([#7965](https://github.com/NativeScript/NativeScript/issues/7965)) ([ce96dad](https://github.com/NativeScript/NativeScript/commit/ce96dad)) +* **application-settings-android:** possible uninitialized sharedPreferences variable usage ([#7813](https://github.com/NativeScript/NativeScript/issues/7813)) ([4f421ff](https://github.com/NativeScript/NativeScript/commit/4f421ff)) +* **css:** parse css selectors with escape sequences ([#7689](https://github.com/NativeScript/NativeScript/issues/7689)) ([5520213](https://github.com/NativeScript/NativeScript/commit/5520213)) +* xml parsing when input value is reported as object instead of string ([#7916](https://github.com/NativeScript/NativeScript/issues/7916)) ([a06a5f9](https://github.com/NativeScript/NativeScript/commit/a06a5f9)) +* **css-android:** restore elements' native features if offending css is removed while the app is running ([#7789](https://github.com/NativeScript/NativeScript/issues/7789)) ([2beae5b](https://github.com/NativeScript/NativeScript/commit/2beae5b)) +* **css-calc:** reduce_css_calc_1.default is not a function ([#7787](https://github.com/NativeScript/NativeScript/issues/7787)) ([03d1ff0](https://github.com/NativeScript/NativeScript/commit/03d1ff0)) +* **bottom-navigation-ios:** incorrect layout on orientation change ([#7927](https://github.com/NativeScript/NativeScript/issues/7927)) ([c9bfec1](https://github.com/NativeScript/NativeScript/commit/c9bfec1)) + + +### Features + +* **action-bar-android:** add properties to control the titleView content insets ([#7805](https://github.com/NativeScript/NativeScript/issues/7805)) ([57a8605](https://github.com/NativeScript/NativeScript/commit/57a8605)) +* **css:** add attribute scoped css without global refresh ([#7907](https://github.com/NativeScript/NativeScript/issues/7907)) ([f791a40](https://github.com/NativeScript/NativeScript/commit/f791a40)) +* **css:** Add HSL/HSLA support ([#7730](https://github.com/NativeScript/NativeScript/issues/7730)) ([3cabdde](https://github.com/NativeScript/NativeScript/commit/3cabdde)) +* **dark-mode:** add system appearance property, event and CSS classes ([#7887](https://github.com/NativeScript/NativeScript/issues/7887)) ([5c9a217](https://github.com/NativeScript/NativeScript/commit/5c9a217)) +* **file-system:** async read/write ([#7671](https://github.com/NativeScript/NativeScript/issues/7671)) ([2146ac9](https://github.com/NativeScript/NativeScript/commit/2146ac9)) +* **dark-mode-ios:** adapt dynamic system colors ([#7826](https://github.com/NativeScript/NativeScript/issues/7826)) ([f82cf08](https://github.com/NativeScript/NativeScript/commit/f82cf08)) +* **platform-declarations:** add android29 typings ([#7923](https://github.com/NativeScript/NativeScript/issues/7923)) ([dc65402](https://github.com/NativeScript/NativeScript/commit/dc65402)) +* **platform-declarations:** generate typings from iOS 13.0 SDK ([#7817](https://github.com/NativeScript/NativeScript/issues/7817)) ([3e8d635](https://github.com/NativeScript/NativeScript/commit/3e8d635)) +* **segmented-bar-ios:** add support for the new selectedSegmentTintColor property ([#7880](https://github.com/NativeScript/NativeScript/issues/7880)) ([ca7c46d](https://github.com/NativeScript/NativeScript/commit/ca7c46d)) +* overhaul and streamline Android page navigation transitions ([#7925](https://github.com/NativeScript/NativeScript/issues/7925)) ([08e23bc](https://github.com/NativeScript/NativeScript/commit/08e23bc)) +* Scoped Packages ([#7911](https://github.com/NativeScript/NativeScript/issues/7911)) ([cc97a16](https://github.com/NativeScript/NativeScript/commit/cc97a16)) +* update material components dependency to 92.3 ([#7936](https://github.com/NativeScript/NativeScript/issues/7936)) ([866c2b0](https://github.com/NativeScript/NativeScript/commit/866c2b0)) + + + ## [6.1.2](https://github.com/NativeScript/NativeScript/compare/6.1.1...6.1.2) (2019-10-15) From 8b6c85243667983b7db2362a5711bd7be37b2ea8 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 29 Oct 2019 21:25:55 +0200 Subject: [PATCH 16/19] test: refactor frames root tests (#8012) --- .../.vscode/launch.json | 2 +- e2e/nested-frame-navigation/app/package.json | 5 +- .../e2e/bottom-navigation-root.e2e-spec.ts | 181 ------------ e2e/nested-frame-navigation/e2e/config.ts | 4 +- .../frame-bottom-navigation-root.e2e-spec.ts | 265 ------------------ .../frame-root/bottom-navigation.e2e-spec.ts | 259 +++++++++++++++++ .../multi-frames.e2e-spec.ts} | 215 ++------------ .../e2e/frame-root/single-frame.e2e-spec.ts | 232 +++++++++++++++ .../tab-view.e2e-spec.ts} | 71 +++-- .../tabs.e2e-spec.ts} | 89 +++--- .../e2e/{ => issues}/issues.e2e.spec.ts | 9 +- .../e2e/layout-root/multi-frames.e2e-spec.ts | 226 +++++++++++++++ .../single-frame.e2e-spec.ts} | 208 ++------------ .../e2e/{ => screens}/screen.ts | 12 +- .../{shared.e2e-spec.ts => screens/shared.ts} | 8 + .../{ => screens}/tab-navigation-screen.ts | 0 .../tabview-navigation-screen.ts | 0 .../bottom-navigation-root.e2e-spec.ts | 165 +++++++++++ .../tabs-root.e2e-spec.ts | 34 ++- .../tab-view-root.e2e-spec.ts} | 39 ++- 20 files changed, 1067 insertions(+), 957 deletions(-) delete mode 100644 e2e/nested-frame-navigation/e2e/bottom-navigation-root.e2e-spec.ts delete mode 100644 e2e/nested-frame-navigation/e2e/frame-bottom-navigation-root.e2e-spec.ts create mode 100644 e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts rename e2e/nested-frame-navigation/e2e/{frame-root.e2e-spec.ts => frame-root/multi-frames.e2e-spec.ts} (50%) create mode 100644 e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts rename e2e/nested-frame-navigation/e2e/{frame-tab-root.e2e-spec.ts => frame-root/tab-view.e2e-spec.ts} (78%) rename e2e/nested-frame-navigation/e2e/{frame-tabs-root.e2e-spec.ts => frame-root/tabs.e2e-spec.ts} (72%) rename e2e/nested-frame-navigation/e2e/{ => issues}/issues.e2e.spec.ts (84%) create mode 100644 e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts rename e2e/nested-frame-navigation/e2e/{layout-root.e2e-spec.ts => layout-root/single-frame.e2e-spec.ts} (61%) rename e2e/nested-frame-navigation/e2e/{ => screens}/screen.ts (98%) rename e2e/nested-frame-navigation/e2e/{shared.e2e-spec.ts => screens/shared.ts} (88%) rename e2e/nested-frame-navigation/e2e/{ => screens}/tab-navigation-screen.ts (100%) rename e2e/nested-frame-navigation/e2e/{ => screens}/tabview-navigation-screen.ts (100%) create mode 100644 e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts rename e2e/nested-frame-navigation/e2e/{ => tab-navigation-root}/tabs-root.e2e-spec.ts (85%) rename e2e/nested-frame-navigation/e2e/{tab-root.e2e-spec.ts => tab-view-root/tab-view-root.e2e-spec.ts} (84%) diff --git a/e2e/nested-frame-navigation/.vscode/launch.json b/e2e/nested-frame-navigation/.vscode/launch.json index bbd504901..71d650f2e 100644 --- a/e2e/nested-frame-navigation/.vscode/launch.json +++ b/e2e/nested-frame-navigation/.vscode/launch.json @@ -22,7 +22,7 @@ "4723", "-a", "--grep", - "layout-root" + "layout-root-with-multi-frames" ], "internalConsoleOptions": "openOnSessionStart" }, diff --git a/e2e/nested-frame-navigation/app/package.json b/e2e/nested-frame-navigation/app/package.json index 0d6fdb754..f94c1cdba 100644 --- a/e2e/nested-frame-navigation/app/package.json +++ b/e2e/nested-frame-navigation/app/package.json @@ -1,8 +1,9 @@ { "android": { - "v8Flags": "--expose_gc" + "v8Flags": "--expose_gc", + "markingMode": "none" }, "main": "app.js", "name": "tns-template-hello-world-ts", "version": "3.4.0" -} \ No newline at end of file +} diff --git a/e2e/nested-frame-navigation/e2e/bottom-navigation-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/bottom-navigation-root.e2e-spec.ts deleted file mode 100644 index 0e732be16..000000000 --- a/e2e/nested-frame-navigation/e2e/bottom-navigation-root.e2e-spec.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; - -import { Screen, playersData, teamsData } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabNavigationScreen } from "./tab-navigation-screen"; - -const roots = ["BottomNavigation"]; - -const rootType = "bottom-navigation-root"; -describe(rootType, async function () { - let driver: AppiumDriver; - let screen: Screen; - - before(async function () { - nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); - driver = await createDriver(); - screen = new TabNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); - } - - driver.defaultWaitTime = 8000; - }); - - after(async function () { - if (dontKeepActivities) { - await driver.setDontKeepActivities(false); - } - await driver.quit(); - console.log("Quit driver!"); - }); - - afterEach(async function () { - if (this.currentTest.state === "failed") { - await driver.logTestArtifacts(this.currentTest.title); - } - }); - - for (let index = 0; index < roots.length; index++) { - const root = roots[index]; - describe(`${rootType}-${root}-scenarios:`, async function () { - - before(async function () { - nsCapabilities.testReporter.context = this; - }); - - for (let index = 0; index < transitions.length; index++) { - const transition = transitions[index]; - - const playerOne = playersData[`playerOne${transition}`]; - const playerTwo = playersData[`playerTwo${transition}`]; - const teamOne = teamsData[`teamOne${transition}`]; - const teamTwo = teamsData[`teamTwo${transition}`]; - - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { - - before(async function () { - nsCapabilities.testReporter.context = this; - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } - }); - - it("loaded home page", async function () { - await screen.loadedHome(); - }); - - it(`loaded ${root} root with frames`, async function () { - await screen[`navigateTo${root}RootWithFrames`](); - await screen[`loaded${root}RootWithFrames`](); - }); - - it("loaded players list", async function () { - await screen.loadedPlayersList(); - }); - - it("loaded player details and go back twice", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - - await shared.testPlayerNavigatedBack(screen, driver); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await shared.testPlayerNavigated(playerTwo, screen); - await shared.testPlayerNavigatedBack(screen, driver); - }); - - it("toggle teams tab", async function () { - await screen.toggleTeamsTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(teamOne.name); // wait for teams list - } - }); - - it("loaded teams list", async function () { - await screen.loadedTeamsList(); - }); - - it("mix player and team list actions and go back", async function () { - await screen.togglePlayersTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await screen.loadedPlayersList(); - - await shared.testPlayerNavigated(playerTwo, screen); - - if (driver.isIOS) { - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - } - - await screen.toggleTeamsTab(); - - if (driver.isIOS) { - // TODO: run in background from appium breaks the test. Investigate the issue, once with the app and with appium - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(teamOne.name); // wait for teams list - } - } - - await screen.loadedTeamsList(); - - await shared.testTeamNavigated(teamTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(teamTwo.name); // wait for team - } - - await screen.togglePlayersTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.toggleTeamsTab(); - - await screen.goBackToTeamsList(); - await screen.loadedTeamsList(); - - await screen.togglePlayersTab(); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - }); - - it("loaded home page again", async function () { - await screen.resetToHome(); - await screen.loadedHome(); - }); - }); - } - }); - } -}); diff --git a/e2e/nested-frame-navigation/e2e/config.ts b/e2e/nested-frame-navigation/e2e/config.ts index 9f2147508..87200f16a 100644 --- a/e2e/nested-frame-navigation/e2e/config.ts +++ b/e2e/nested-frame-navigation/e2e/config.ts @@ -1,4 +1,4 @@ export const suspendTime = 1; export const appSuspendResume = true; -export const dontKeepActivities = true; -export const transitions = ["Default", "None", "Slide", "Flip"]; +export const dontKeepActivities = process.env["DONT_KEEP_ACTIVITIES"] === "true" ? true : false; +export const allTransitions = ["Default", "None", "Slide", "Flip"]; diff --git a/e2e/nested-frame-navigation/e2e/frame-bottom-navigation-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-bottom-navigation-root.e2e-spec.ts deleted file mode 100644 index 526fcc917..000000000 --- a/e2e/nested-frame-navigation/e2e/frame-bottom-navigation-root.e2e-spec.ts +++ /dev/null @@ -1,265 +0,0 @@ -import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; - -import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabNavigationScreen } from "./tab-navigation-screen"; - -const roots = ["BottomNavigation"]; - -const rootType = "frame-bottom-navigation-root"; -describe(rootType, async function () { - let driver: AppiumDriver; - let screen: Screen; - - before(async function () { - nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); - driver = await createDriver(); - screen = new TabNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); - } - - driver.defaultWaitTime = driverDefaultWaitTime; - }); - - after(async function () { - if (dontKeepActivities) { - await driver.setDontKeepActivities(false); - } - await driver.quit(); - console.log("Quit driver!"); - }); - - afterEach(async function () { - if (this.currentTest.state === "failed") { - await driver.logTestArtifacts(this.currentTest.title); - } - }); - - for (let index = 0; index < roots.length; index++) { - const root = roots[index]; - - describe(`${rootType}-${root} scenarios:`, async function () { - logWarn(`===== Root: ${root}`); - for (let trIndex = 0; trIndex < transitions.length; trIndex++) { - const transition = transitions[trIndex]; - const playerOne: Item = playersData[`playerOne${transition}`]; - const playerTwo: Item = playersData[`playerTwo${transition}`]; - const teamOne: Item = teamsData[`teamOne${transition}`]; - const teamTwo: Item = teamsData[`teamTwo${transition}`]; - - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { - - before(async function () { - nsCapabilities.testReporter.context = this; - logWarn(`========= ${root}-${transition} =========`); - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } - }); - - it("loaded home page", async function () { - await screen.loadedHome(); - }); - - it(`loaded frame ${root} root with nested frames`, async function () { - await screen[`navigateToPage${root}WithFrames`](); - await screen[`loadedPage${root}WithFrames`](); - }); - - it("loaded players list", async function () { - await screen.loadedPlayersList(); - }); - - it("loaded player details and go back twice", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player - } - - await shared.testPlayerNavigatedBack(screen, driver); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await shared.testPlayerNavigated(playerTwo, screen); - await shared.testPlayerNavigatedBack(screen, driver); - }); - - it("navigate parent frame and go back", async function () { - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayersList(); - }); - - it("loaded player details and navigate parent frame and go back", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player - } - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - }); - - it("toggle teams tab", async function () { - await screen.toggleTeamsTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamOne.name); // wait for team - } - }); - - it("loaded teams list", async function () { - await screen.loadedTeamsList(); - }); - - it("mix player and team list actions and go back", async function () { - await screen.togglePlayersTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerOne.name); // wait for players list - } - - await screen.loadedPlayersList(); - - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player - } - - await screen.loadedPlayerDetails(playerTwo); - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); - } else { - await screen.goBackFromSomePage(); - } - - if (appSuspendResume) { - // This sleeps prevent test to fail - await driver.sleep(1000); - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.toggleTeamsTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamOne.name); // wait for teams list - } - - await screen.loadedTeamsList(); - - await shared.testTeamNavigated(teamTwo, screen); - - if (appSuspendResume) { - await screen.loadedElement(teamTwo.name); // wait for team - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamTwo.name); // wait for team - } - - await screen.loadedTeamDetails(teamTwo); - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); - } else { - await screen.goBackFromSomePage(); - } - - if (appSuspendResume) { - await screen.loadedElement(teamTwo.name); // wait for team - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamTwo.name); // wait for team - } - - await screen.loadedTeamDetails(teamTwo); - - await screen.togglePlayersTab(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.toggleTeamsTab(); - - await screen.goBackToTeamsList(); - await screen.loadedTeamsList(); - - await screen.togglePlayersTab(); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - }); - - it("loaded home page again", async function () { - await screen[`goBackFrom${root}Page`](); - await screen.loadedHome(); - }); - }); - } - }); - } -}); \ No newline at end of file diff --git a/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts new file mode 100644 index 000000000..9d8c3ec0b --- /dev/null +++ b/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts @@ -0,0 +1,259 @@ +import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; + +import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; + +describe("frame-root-with-bottom-navigation", async function () { + let driver: AppiumDriver; + let screen: Screen; + let transitions = [...allTransitions]; + + before(async function () { + nsCapabilities.testReporter.context = this; + logWarn(`====== frame-root-with-bottom-navigation ========`); + driver = await createDriver(); + await driver.restartApp(); + screen = new TabNavigationScreen(driver); + await driver.setDontKeepActivities(dontKeepActivities); + driver.defaultWaitTime = driverDefaultWaitTime; + + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } + }); + + after(async function () { + if (dontKeepActivities) { + await driver.setDontKeepActivities(false); + } + await driver.quit(); + console.log("Quit driver!"); + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } + }); + + describe(`frame-root-with-bottom-navigation scenarios:`, async function () { + for (let trIndex = 0; trIndex < transitions.length; trIndex++) { + const transition = transitions[trIndex]; + const playerOne: Item = playersData[`playerOne${transition}`]; + const playerTwo: Item = playersData[`playerTwo${transition}`]; + const teamOne: Item = teamsData[`teamOne${transition}`]; + const teamTwo: Item = teamsData[`teamTwo${transition}`]; + + describe(`frame-root-with-bottom-navigation-transition-${transition}-scenario:`, async function () { + + before(async function () { + nsCapabilities.testReporter.context = this; + logWarn(`=========${trIndex++}. BottomNavigation-${transition} =========`); + }); + + it("loaded home page", async function () { + await screen.loadedHome(); + }); + + it(`loaded frame root with bottom-navigation`, async function () { + await screen[`navigateToPageBottomNavigationWithFrames`](); + await screen[`loadedPageBottomNavigationWithFrames`](); + }); + + it("loaded players list", async function () { + await screen.loadedPlayersList(); + }); + + it("loaded player details and go back twice", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } + + await shared.testPlayerNavigatedBack(screen, driver); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await shared.testPlayerNavigated(playerTwo, screen); + await shared.testPlayerNavigatedBack(screen, driver); + }); + + it("navigate parent frame and go back", async function () { + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayersList(); + }); + + it("loaded player details and navigate parent frame and go back", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } + } + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + }); + + it("toggle teams tab", async function () { + await screen.toggleTeamsTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamOne.name); // wait for team + } + }); + + it("loaded teams list", async function () { + await screen.loadedTeamsList(); + }); + + it("mix player and team list actions and go back", async function () { + await screen.togglePlayersTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerOne.name); // wait for players list + } + + await screen.loadedPlayersList(); + + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } + + await screen.loadedPlayerDetails(playerTwo); + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); + } else { + await screen.goBackFromSomePage(); + } + + if (appSuspendResume) { + // This sleeps prevent test to fail + await driver.sleep(1000); + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.toggleTeamsTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamOne.name); // wait for teams list + } + + await screen.loadedTeamsList(); + + await shared.testTeamNavigated(teamTwo, screen); + + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await screen.loadedElement(teamTwo.name); // wait for team + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamTwo.name); // wait for team + } + } + + await screen.loadedTeamDetails(teamTwo); + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); + } else { + await screen.goBackFromSomePage(); + } + + if (appSuspendResume) { + await screen.loadedElement(teamTwo.name); // wait for team + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamTwo.name); // wait for team + } + + await screen.loadedTeamDetails(teamTwo); + + await screen.togglePlayersTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.toggleTeamsTab(); + + await screen.goBackToTeamsList(); + await screen.loadedTeamsList(); + + await screen.togglePlayersTab(); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + }); + + it("loaded home page again", async function () { + await screen[`goBackFromBottomNavigationPage`](); + await screen.loadedHome(); + }); + }); + } + }); +}); \ No newline at end of file diff --git a/e2e/nested-frame-navigation/e2e/frame-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts similarity index 50% rename from e2e/nested-frame-navigation/e2e/frame-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts index 0936ffa07..59ac2d2d0 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts @@ -1,24 +1,29 @@ + import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item, stillOtherPage } from "./screen"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import * as shared from "./shared.e2e-spec"; -import { TabNavigationScreen } from "./tab-navigation-screen"; +import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item, stillOtherPage } from "../screens/screen"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import * as shared from "../screens/shared"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; -const rootType = "frame-root"; -describe(rootType, async function () { +describe("frame-root-with-multi-frames", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; driver = await createDriver(); + await driver.restartApp(); screen = new TabNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); - } - + await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = driverDefaultWaitTime; + + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } }); after(async function () { @@ -43,105 +48,16 @@ describe(rootType, async function () { const teamOne: Item = teamsData[`teamOne${transition}`]; const teamTwo: Item = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-transition-${transition}-scenarios:`, async function () { + describe(`frame-root-with-multi-frames-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`==== Transition ${transition}`); - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } + logWarn(`====${index}. Transition ${transition}`); }); it("loaded home page", async function () { await screen.loadedHome(); }); - it("loaded frame root with nested frame", async function () { - await screen.navigateToPageWithFrame(); - await screen.loadedPageWithFrame(); - }); - - it("loaded players list", async function () { - await screen.loadedPlayersList(); - }); - - it("loaded player details and go back twice", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); - } - - await shared.testPlayerNavigatedBack(screen, driver); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerOne.name); - } - - await shared.testPlayerNavigated(playerTwo, screen); - await shared.testPlayerNavigatedBack(screen, driver); - }); - - it("navigate parent frame and go back", async function () { - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedSomePage(); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayersList(); - }); - - it("loaded player details and navigate parent frame and go back", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); - } - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedSomePage(); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - }); - - it("loaded home page again", async function () { - await screen.goBackFromFrameHome(); - await screen.loadedHome(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedHome(); - } - }); - it("loaded frame root with multi nested frames", async function () { await screen.navigateToPageWithMultiFrame(); await screen.loadedPageWithMultiFrame(); @@ -301,101 +217,4 @@ describe(rootType, async function () { }); }); } - - describe("frame to nested frame with non-default transition", async function () { - const playerOne = playersData["playerOneSlide"]; - - before(async function () { - nsCapabilities.testReporter.context = this; - }); - - it("loaded home page", async function () { - await screen.loadedHome(); - }); - - it("loaded frame root with nested frame non-default transition", async function () { - await screen.navigateToPageWithFrameNonDefaultTransition(); - await screen.loadedPageWithFrame(); - }); - - it("go back to home page again", async function () { - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await screen.goBackFromFrameHome(); - await screen.loadedHome(); - }); - }); - - describe("nested frame to frame with non-default transition", async function () { - - before(async function () { - nsCapabilities.testReporter.context = this; - }); - - it("loaded home page", async function () { - await screen.loadedHome(); - }); - - it("loaded frame root with nested frame", async function () { - await screen.navigateToPageWithFrame(); - await screen.loadedPageWithFrame(); - }); - - it("navigate to some page with slide transition", async function () { - shared.testSomePageNavigatedSlide(screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(somePage); // wait for some page - } - }); - - it("navigate to still other page and go back twice", async function () { - shared.testStillOtherPageNavigatedSlide(screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(stillOtherPage); // wait for still other page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromStillOtherPage(); - } - - await screen.loadedSomePage(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(somePage); // wait for some page - } - - shared.testStillOtherPageNavigatedSlide(screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(stillOtherPage); // wait for still other page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromStillOtherPage(); - } - - await screen.loadedSomePage(); - }); - - it("go back to home page again", async function () { - await screen.goBackFromSomePage(); - - await screen.goBackFromFrameHome(); - - await screen.loadedHome(); - }); - }); }); diff --git a/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts new file mode 100644 index 000000000..802b06d32 --- /dev/null +++ b/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts @@ -0,0 +1,232 @@ +import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; + +import { Screen, playersData, somePage, driverDefaultWaitTime, Item, stillOtherPage } from "../screens/screen"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import * as shared from "../screens/shared"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; + +describe("frame-root-with-single-frame", async function () { + let driver: AppiumDriver; + let screen: Screen; + let transitions = [...allTransitions]; + + before(async function () { + nsCapabilities.testReporter.context = this; + driver = await createDriver(); + await driver.restartApp(); + screen = new TabNavigationScreen(driver); + await driver.setDontKeepActivities(dontKeepActivities); + driver.defaultWaitTime = driverDefaultWaitTime; + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } + }); + + after(async function () { + if (dontKeepActivities) { + await driver.setDontKeepActivities(false); + } + await driver.quit(); + console.log("Quit driver!"); + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } + }); + + for (let index = 0; index < transitions.length; index++) { + const transition = transitions[index]; + + const playerOne: Item = playersData[`playerOne${transition}`]; + const playerTwo: Item = playersData[`playerTwo${transition}`]; + + describe(`frame-root-with-single-frame-transition-${transition}-scenario:`, async function () { + before(async function () { + nsCapabilities.testReporter.context = this; + logWarn(`==== ${index}. Transition ${transition}`); + }); + + it("loaded home page", async function () { + await screen.loadedHome(); + }); + + it("loaded frame root with nested frame", async function () { + await screen.navigateToPageWithFrame(); + await screen.loadedPageWithFrame(); + }); + + it("loaded players list", async function () { + await screen.loadedPlayersList(); + }); + + it("loaded player details and go back twice", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); + } + + await shared.testPlayerNavigatedBack(screen, driver); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerOne.name); + } + + await shared.testPlayerNavigated(playerTwo, screen); + await shared.testPlayerNavigatedBack(screen, driver); + }); + + it("navigate parent frame and go back", async function () { + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedSomePage(); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayersList(); + }); + + it("loaded player details and navigate parent frame and go back", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); + } + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedSomePage(); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + }); + + it("loaded home page again", async function () { + await screen.goBackFromFrameHome(); + await screen.loadedHome(); + }); + }); + } + + describe("frame to nested frame with non-default transition", async function () { + const playerOne = playersData["playerOneSlide"]; + + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded home page", async function () { + await screen.loadedHome(); + }); + + it("loaded frame root with nested frame non-default transition", async function () { + await screen.navigateToPageWithFrameNonDefaultTransition(); + await screen.loadedPageWithFrame(); + }); + + it("go back to home page again", async function () { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await screen.goBackFromFrameHome(); + await screen.loadedHome(); + }); + }); + + describe("nested frame to frame with non-default transition", async function () { + + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded home page", async function () { + await screen.loadedHome(); + }); + + it("loaded frame root with nested frame", async function () { + await screen.navigateToPageWithFrame(); + await screen.loadedPageWithFrame(); + }); + + it("navigate to some page with slide transition", async function () { + shared.testSomePageNavigatedSlide(screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(somePage); // wait for some page + } + }); + + it("navigate to still other page and go back twice", async function () { + shared.testStillOtherPageNavigatedSlide(screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(stillOtherPage); // wait for still other page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromStillOtherPage(); + } + + await screen.loadedSomePage(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(somePage); // wait for some page + } + + shared.testStillOtherPageNavigatedSlide(screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(stillOtherPage); // wait for still other page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromStillOtherPage(); + } + + await screen.loadedSomePage(); + }); + + it("go back to home page again", async function () { + await screen.goBackFromSomePage(); + + await screen.goBackFromFrameHome(); + + await screen.loadedHome(); + }); + }); +}); diff --git a/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts similarity index 78% rename from e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts index ff15b7eea..22cd6f7d2 100644 --- a/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts @@ -1,27 +1,37 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabViewNavigationScreen } from "./tabview-navigation-screen"; +import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabViewNavigationScreen } from "../screens/tabview-navigation-screen"; // NOTE: TabViewTop is Android only scenario (for iOS we will essentially execute 2x TabViewBottom) const roots = ["TabViewTop", "TabViewBottom"]; -const rootType = "frame-tab-root"; -describe(rootType, async function () { +describe("frame-root-with-tab-view", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); + logWarn(`====== frame-root-with-tab-view ========`); driver = await createDriver(); await driver.restartApp(); screen = new TabViewNavigationScreen(driver); if (dontKeepActivities) { await driver.setDontKeepActivities(true); } + if (driver.isIOS) { + logWarn("NOTE: TabViewTop is Android only scenario (for iOS we will not execute it)"); + roots.shift(); + } + + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -43,7 +53,7 @@ describe(rootType, async function () { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root} scenarios:`, async function () { + describe(`frame-root-with-tab-view-${root} scenarios:`, async function () { logWarn(`===== Root: ${root}`); for (let trIndex = 0; trIndex < transitions.length; trIndex++) { const transition = transitions[trIndex]; @@ -52,18 +62,11 @@ describe(rootType, async function () { const teamOne: Item = teamsData[`teamOne${transition}`]; const teamTwo: Item = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { + describe(`frame-root-with-tab-view-${root}-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; logWarn(`========= ${root}-${transition} =========`); - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } }); it("loaded home page", async function () { @@ -82,11 +85,12 @@ describe(rootType, async function () { it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } - await shared.testPlayerNavigatedBack(screen, driver); if (appSuspendResume) { @@ -118,9 +122,11 @@ describe(rootType, async function () { it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await shared[`testSomePageNavigated${transition}`](screen); @@ -167,9 +173,11 @@ describe(rootType, async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await screen.loadedPlayerDetails(playerTwo); @@ -207,12 +215,13 @@ describe(rootType, async function () { await shared.testTeamNavigated(teamTwo, screen); - if (appSuspendResume) { - await screen.loadedElement(teamTwo.name); // wait for team - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamTwo.name); // wait for team + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await screen.loadedElement(teamTwo.name); // wait for team + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamTwo.name); // wait for team + } } - await screen.loadedTeamDetails(teamTwo); await shared[`testSomePageNavigated${transition}`](screen); diff --git a/e2e/nested-frame-navigation/e2e/frame-tabs-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts similarity index 72% rename from e2e/nested-frame-navigation/e2e/frame-tabs-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts index 263ca56a2..841d04a00 100644 --- a/e2e/nested-frame-navigation/e2e/frame-tabs-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts @@ -1,24 +1,28 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabNavigationScreen } from "./tab-navigation-screen"; +import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; const roots = ["TabsTop", "TabsBottom"]; -const rootType = "frame-tabs-root"; -describe(rootType, async function () { +describe("frame-root-with-tabs", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); + logWarn(`====== frame-root-with-tabs ========`); driver = await createDriver(); + await driver.restartApp(); screen = new TabNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); + await driver.setDontKeepActivities(dontKeepActivities); + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); } driver.defaultWaitTime = driverDefaultWaitTime; @@ -41,8 +45,8 @@ describe(rootType, async function () { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root} scenarios:`, async function () { - logWarn(`===== Root: ${root}`); + describe(`frame-root-with-tabs-${root} scenario:`, async function () { + logWarn(`===== ${index++}. Root: ${root}`); for (let trIndex = 0; trIndex < transitions.length; trIndex++) { const transition = transitions[trIndex]; const playerOne: Item = playersData[`playerOne${transition}`]; @@ -50,18 +54,11 @@ describe(rootType, async function () { const teamOne: Item = teamsData[`teamOne${transition}`]; const teamTwo: Item = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { + describe(`frame-root-with-tabs-${root}-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; logWarn(`========= ${root}-${transition} =========`); - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } }); it("loaded home page", async function () { @@ -116,9 +113,11 @@ describe(rootType, async function () { it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await shared[`testSomePageNavigated${transition}`](screen); @@ -165,18 +164,22 @@ describe(rootType, async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await screen.loadedPlayerDetails(playerTwo); await shared[`testSomePageNavigated${transition}`](screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(somePage); // wait for some page + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(somePage); // wait for some page + } } if (driver.isAndroid) { @@ -185,30 +188,36 @@ describe(rootType, async function () { await screen.goBackFromSomePage(); } - if (appSuspendResume) { - // This sleeps prevent test to fail - await driver.sleep(1000); - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + // This sleeps prevent test to fail + await driver.sleep(1000); + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await screen.loadedPlayerDetails(playerTwo); await screen.toggleTeamsTab(); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamOne.name); // wait for teams list + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamOne.name); // wait for teams list + } } await screen.loadedTeamsList(); await shared.testTeamNavigated(teamTwo, screen); - if (appSuspendResume) { - await screen.loadedElement(teamTwo.name); // wait for team - await driver.backgroundApp(suspendTime); - await screen.loadedElement(teamTwo.name); // wait for team + if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (appSuspendResume) { + await screen.loadedElement(teamTwo.name); // wait for team + await driver.backgroundApp(suspendTime); + await screen.loadedElement(teamTwo.name); // wait for team + } } await screen.loadedTeamDetails(teamTwo); diff --git a/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts b/e2e/nested-frame-navigation/e2e/issues/issues.e2e.spec.ts similarity index 84% rename from e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts rename to e2e/nested-frame-navigation/e2e/issues/issues.e2e.spec.ts index 3abce2423..0e29235b4 100644 --- a/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts +++ b/e2e/nested-frame-navigation/e2e/issues/issues.e2e.spec.ts @@ -1,7 +1,7 @@ import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; -import { Screen } from "./screen"; -import { suspendTime, dontKeepActivities } from "./config"; -import { TabViewNavigationScreen } from "./tabview-navigation-screen"; +import { Screen } from "../screens/screen"; +import { suspendTime, dontKeepActivities } from "../config"; +import { TabViewNavigationScreen } from "../screens/tabview-navigation-screen"; describe("issues", async function () { let driver: AppiumDriver; @@ -10,6 +10,7 @@ describe("issues", async function () { before(async function () { nsCapabilities.testReporter.context = this; driver = await createDriver(); + await driver.restartApp(); screen = new TabViewNavigationScreen(driver); if (dontKeepActivities) { await driver.setDontKeepActivities(true); @@ -35,7 +36,7 @@ describe("issues", async function () { await screen.loadedHome(); const showSomePage = async function () { const somePageBtn = await driver.waitForElement("somePageOnRoot"); - await somePageBtn.tap(); + await somePageBtn.click(); await screen.loadedSomePage(); }; diff --git a/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts new file mode 100644 index 000000000..320e1dd8d --- /dev/null +++ b/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts @@ -0,0 +1,226 @@ +import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; + +import { Screen, playersData, somePage, otherPage, teamsData, driverDefaultWaitTime } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; + +describe("layout-root-with-multi-frames", async function () { + let driver: AppiumDriver; + let screen: Screen; + let transitions = [...allTransitions]; + + before(async function () { + nsCapabilities.testReporter.context = this; + driver = await createDriver(); + await driver.restartApp(); + screen = new TabNavigationScreen(driver); + logWarn("====== layout-root-with-multi-frames ========"); + await driver.setDontKeepActivities(dontKeepActivities); + + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } + + driver.defaultWaitTime = driverDefaultWaitTime; + }); + + after(async function () { + if (dontKeepActivities) { + await driver.setDontKeepActivities(false); + } + await driver.quit(); + console.log("Quit driver!"); + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } + }); + + for (let index = 0; index < transitions.length; index++) { + const transition = allTransitions[index]; + + const playerOne = playersData[`playerOne${transition}`]; + const playerTwo = playersData[`playerTwo${transition}`]; + const teamOne = teamsData[`teamOne${transition}`]; + + describe(`layout-root-with-multi-frames-transition-${transition}-scenario:`, async function () { + + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded layout root with multi nested frames", async function () { + await screen.loadedHome(); + + await screen.navigateToLayoutWithMultiFrame(); + await screen.loadedLayoutWithMultiFrame(); + }); + + it("loaded players list", async function () { + await screen.loadedPlayersList(); + }); + + it("loaded teams list", async function () { + await screen.loadedTeamsList(); + }); + + it("loaded player details and go back twice", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + + await shared.testPlayerNavigatedBack(screen, driver); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await shared.testPlayerNavigated(playerTwo, screen); + await shared.testPlayerNavigatedBack(screen, driver); + }); + + it("navigate players parent frame and go back", async function () { + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayersList(); + }); + + it("loaded players details and navigate parent frame and go back", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(somePage); // wait for some page + } + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + }); + + it("loaded layout root with multi nested frames again", async function () { + await screen.loadedLayoutWithMultiFrame(); + }); + + it("loaded players list", async function () { + await screen.loadedPlayersList(); + }); + + it("loaded teams list", async function () { + await screen.loadedTeamsList(); + }); + + it("mix player and team list actions and go back", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + + await shared[`testOtherPageNavigated${transition}`](screen); // "teams" parent frame navigation + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(otherPage); // wait for other page + } + + await screen.loadedPlayerDetails(playerTwo); // assert no changes in the sibling frame + + if (driver.isAndroid) { + await driver.navBack(); // other page back navigation + } else { + await screen.goBackFromOtherPage(); + } + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(teamOne.name); // wait for teams list + } + + await screen.loadedTeamsList(); + await screen.loadedPlayerDetails(playerTwo); // assert no changes in the sibling frame + + await shared[`testOtherPageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(otherPage); // wait for other page + } + + await shared[`testSomePageNavigated${transition}`](screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(somePage); // wait for some page + } + + await screen.loadedOtherPage(); // assert no changes in the sibling frame + + if (driver.isAndroid) { + await driver.navBack(); // some page back navigation + } else { + await screen.goBackFromSomePage(); + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await screen.goBackFromOtherPage(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(teamOne.name); // wait for team + } + + await screen.loadedTeamsList(); + }); + + it("loaded home page again", async function () { + await screen.resetToHome(); + await screen.loadedHome(); + }); + }); + } +}); diff --git a/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts similarity index 61% rename from e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts index 2346a9c1d..de11ab012 100644 --- a/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts @@ -1,24 +1,27 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, home, somePage, otherPage, teamsData, driverDefaultWaitTime } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabNavigationScreen } from "./tab-navigation-screen"; +import { Screen, playersData, home, somePage, teamsData, driverDefaultWaitTime } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; -const rootType = "layout-root"; -describe(rootType, async function () { +describe("layout-root-with-single-frame", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; driver = await createDriver(); + await driver.restartApp(); screen = new TabNavigationScreen(driver); - logWarn("====== layout-root ========"); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); + logWarn("====== layout-root-with-single-frame ========"); + await driver.setDontKeepActivities(dontKeepActivities); + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); } - driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -41,18 +44,11 @@ describe(rootType, async function () { const playerOne = playersData[`playerOne${transition}`]; const playerTwo = playersData[`playerTwo${transition}`]; - const teamOne = teamsData[`teamOne${transition}`]; - describe(`${rootType}-transition-${transition}-scenarios:`, async function () { + describe(`layout-root-with-single-frame-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } }); it("loaded home page", async function () { @@ -140,176 +136,10 @@ describe(rootType, async function () { await driver.waitForElement(home); // wait for home page } }); - - it("loaded layout root with multi nested frames", async function () { - await screen.navigateToLayoutWithMultiFrame(); - await screen.loadedLayoutWithMultiFrame(); - }); - - it("loaded players list", async function () { - await screen.loadedPlayersList(); - }); - - it("loaded teams list", async function () { - await screen.loadedTeamsList(); - }); - - it("loaded player details and go back twice", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - - await shared.testPlayerNavigatedBack(screen, driver); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await shared.testPlayerNavigated(playerTwo, screen); - await shared.testPlayerNavigatedBack(screen, driver); - }); - - it("navigate players parent frame and go back", async function () { - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayersList(); - }); - - it("loaded players details and navigate parent frame and go back", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(somePage); // wait for some page - } - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - }); - - it("loaded layout root with multi nested frames again", async function () { - await screen.loadedLayoutWithMultiFrame(); - }); - - it("loaded players list", async function () { - await screen.loadedPlayersList(); - }); - - it("loaded teams list", async function () { - await screen.loadedTeamsList(); - }); - - it("mix player and team list actions and go back", async function () { - await shared.testPlayerNavigated(playerTwo, screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerTwo.name); // wait for player - } - - await shared[`testOtherPageNavigated${transition}`](screen); // "teams" parent frame navigation - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(otherPage); // wait for other page - } - - await screen.loadedPlayerDetails(playerTwo); // assert no changes in the sibling frame - - if (driver.isAndroid) { - await driver.navBack(); // other page back navigation - } else { - await screen.goBackFromOtherPage(); - } - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(teamOne.name); // wait for teams list - } - - await screen.loadedTeamsList(); - await screen.loadedPlayerDetails(playerTwo); // assert no changes in the sibling frame - - await shared[`testOtherPageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(otherPage); // wait for other page - } - - await shared[`testSomePageNavigated${transition}`](screen); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(somePage); // wait for some page - } - - await screen.loadedOtherPage(); // assert no changes in the sibling frame - - if (driver.isAndroid) { - await driver.navBack(); // some page back navigation - } else { - await screen.goBackFromSomePage(); - } - - await screen.loadedPlayerDetails(playerTwo); - - await screen.goBackToPlayersList(); - await screen.loadedPlayersList(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(playerOne.name); // wait for players list - } - - await screen.goBackFromOtherPage(); - - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await driver.waitForElement(teamOne.name); // wait for team - } - - await screen.loadedTeamsList(); - }); - - it("loaded home page again", async function () { - await screen.resetToHome(); - await screen.loadedHome(); - }); }); } - describe(`${rootType}-players-list-slide-transition with parent frame default transition:`, async function () { + describe(`layout-root-with-single-frame-players-list-slide-transition with parent frame default transition:`, async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; @@ -368,7 +198,7 @@ describe(rootType, async function () { }); }); - describe(`${rootType}-players-list-slide-transition with parent frame no transition:`, async function () { + describe(`layout-root-with-single-frame-players-list-slide-transition with parent frame no transition:`, async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; @@ -427,7 +257,7 @@ describe(rootType, async function () { }); }); - describe(`${rootType}-players-list-flip-transition with parent frame default transition:`, async function () { + describe(`layout-root-with-single-frame-players-list-flip-transition with parent frame default transition:`, async function () { const playerOne = playersData["playerOneFlip"]; const playerTwo = playersData["playerTwoFlip"]; @@ -490,14 +320,14 @@ describe(rootType, async function () { }); }); - describe(`${rootType}-players-list-flip-transition with parent frame no transition:`, async function () { + describe(`layout-root-with-single-frame-players-list-flip-transition with parent frame no transition:`, async function () { const playerOne = playersData["playerOneFlip"]; const playerTwo = playersData["playerTwoFlip"]; before(async function () { nsCapabilities.testReporter.context = this; }); - + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); diff --git a/e2e/nested-frame-navigation/e2e/screen.ts b/e2e/nested-frame-navigation/e2e/screens/screen.ts similarity index 98% rename from e2e/nested-frame-navigation/e2e/screen.ts rename to e2e/nested-frame-navigation/e2e/screens/screen.ts index b496144ad..446c4a4b9 100644 --- a/e2e/nested-frame-navigation/e2e/screen.ts +++ b/e2e/nested-frame-navigation/e2e/screens/screen.ts @@ -272,7 +272,7 @@ export abstract class Screen { const btnReset = await this._driver.waitForElement(resetApp); console.info(`====== Reset home "${resetApp}"`); - await btnReset.tap(); + await btnReset.click(); } goBackToPlayersList = async () => { @@ -322,13 +322,13 @@ export abstract class Screen { togglePlayersTab = async () => { const lblPlayers = await this._driver.waitForElement(this.playersTab); logInfo(`====== Navigate to "${this.players}"`); - await lblPlayers.tap(); + await lblPlayers.click(); } toggleTeamsTab = async () => { const lblTeams = await this._driver.waitForElement(this.teamsTab); logInfo(`====== Navigate to "${this.teams}"`); - await lblTeams.tap(); + await lblTeams.click(); } loadedHome = async () => { @@ -435,7 +435,7 @@ export abstract class Screen { private navigateToPage = async (page: string) => { const btnPage = await this._driver.waitForElement(page); logInfo(`====== Navigate to "${page}"`); - await btnPage.tap(); + await btnPage.click(); } private loadedPage = async (page: string) => { @@ -447,7 +447,7 @@ export abstract class Screen { private navigateToItem = async (item: Item) => { const lblItem = await this._driver.waitForElement(item.name); logInfo(`====== Navigate to "${item.name}"`); - await lblItem.tap(); + await lblItem.click(); } private loadedItem = async (item: Item) => { @@ -463,6 +463,6 @@ export abstract class Screen { private goBack = async (accessibilityId: string) => { const btnBack = await this._driver.waitForElement(accessibilityId); logInfo(`====== Go back with "${accessibilityId}"`); - await btnBack.tap(); + await btnBack.click(); } } \ No newline at end of file diff --git a/e2e/nested-frame-navigation/e2e/shared.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/screens/shared.ts similarity index 88% rename from e2e/nested-frame-navigation/e2e/shared.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/screens/shared.ts index d3aed10de..0f3756287 100644 --- a/e2e/nested-frame-navigation/e2e/shared.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/screens/shared.ts @@ -2,6 +2,14 @@ import { AppiumDriver } from "nativescript-dev-appium"; import { Screen, Item } from "./screen"; +export const preventApplicationCrashCauesByAutomation = (driver: AppiumDriver) => { + return +driver.nsCapabilities.device.apiLevel > 23 && driver.isAndroid; +}; + +export const isApiLevel19 = (driver: AppiumDriver) => { + return +driver.nsCapabilities.device.apiLevel === 19 && driver.isAndroid; +}; + export async function testPlayerNavigated(player: Item, screen: Screen) { await screen.navigateToPlayerDetails(player); await screen.loadedPlayerDetails(player); diff --git a/e2e/nested-frame-navigation/e2e/tab-navigation-screen.ts b/e2e/nested-frame-navigation/e2e/screens/tab-navigation-screen.ts similarity index 100% rename from e2e/nested-frame-navigation/e2e/tab-navigation-screen.ts rename to e2e/nested-frame-navigation/e2e/screens/tab-navigation-screen.ts diff --git a/e2e/nested-frame-navigation/e2e/tabview-navigation-screen.ts b/e2e/nested-frame-navigation/e2e/screens/tabview-navigation-screen.ts similarity index 100% rename from e2e/nested-frame-navigation/e2e/tabview-navigation-screen.ts rename to e2e/nested-frame-navigation/e2e/screens/tabview-navigation-screen.ts diff --git a/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts new file mode 100644 index 000000000..65ae33ae3 --- /dev/null +++ b/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts @@ -0,0 +1,165 @@ +import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; + +import { Screen, playersData, teamsData } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; + +describe("tab-navigation-bottom-navigation-root", async function () { + let driver: AppiumDriver; + let screen: Screen; + let transitions = [...allTransitions]; + + before(async function () { + nsCapabilities.testReporter.context = this; + logWarn(`====== "bottom-navigation-root" ========`); + driver = await createDriver(); + await driver.restartApp(); + screen = new TabNavigationScreen(driver); + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); + } + await driver.setDontKeepActivities(dontKeepActivities); + driver.defaultWaitTime = 8000; + }); + + after(async function () { + if (dontKeepActivities) { + await driver.setDontKeepActivities(false); + } + await driver.quit(); + console.log("Quit driver!"); + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } + }); + + for (let index = 0; index < transitions.length; index++) { + const transition = transitions[index]; + + const playerOne = playersData[`playerOne${transition}`]; + const playerTwo = playersData[`playerTwo${transition}`]; + const teamOne = teamsData[`teamOne${transition}`]; + const teamTwo = teamsData[`teamTwo${transition}`]; + + describe(`bottom-navigation-root-transition-${transition}-scenario:`, async function () { + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded home page", async function () { + await screen.loadedHome(); + }); + + it(`loaded BottomNavigation root with frames`, async function () { + await screen[`navigateToBottomNavigationRootWithFrames`](); + await screen[`loadedBottomNavigationRootWithFrames`](); + }); + + it("loaded players list", async function () { + await screen.loadedPlayersList(); + }); + + it("loaded player details and go back twice", async function () { + await shared.testPlayerNavigated(playerTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + + await shared.testPlayerNavigatedBack(screen, driver); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await shared.testPlayerNavigated(playerTwo, screen); + await shared.testPlayerNavigatedBack(screen, driver); + }); + + it("toggle teams tab", async function () { + await screen.toggleTeamsTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(teamOne.name); // wait for teams list + } + }); + + it("loaded teams list", async function () { + await screen.loadedTeamsList(); + }); + + it("mix player and team list actions and go back", async function () { + await screen.togglePlayersTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerOne.name); // wait for players list + } + + await screen.loadedPlayersList(); + + await shared.testPlayerNavigated(playerTwo, screen); + + if (driver.isIOS) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + } + + await screen.toggleTeamsTab(); + + if (driver.isIOS) { + // TODO: run in background from appium breaks the test. Investigate the issue, once with the app and with appium + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(teamOne.name); // wait for teams list + } + } + + await screen.loadedTeamsList(); + + await shared.testTeamNavigated(teamTwo, screen); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(teamTwo.name); // wait for team + } + + await screen.togglePlayersTab(); + + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await driver.waitForElement(playerTwo.name); // wait for player + } + + await screen.loadedPlayerDetails(playerTwo); + + await screen.toggleTeamsTab(); + + await screen.goBackToTeamsList(); + await screen.loadedTeamsList(); + + await screen.togglePlayersTab(); + + await screen.goBackToPlayersList(); + await screen.loadedPlayersList(); + }); + + it("loaded home page again", async function () { + await screen.resetToHome(); + await screen.loadedHome(); + }); + }); + } + +}); diff --git a/e2e/nested-frame-navigation/e2e/tabs-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts similarity index 85% rename from e2e/nested-frame-navigation/e2e/tabs-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts index 24266595e..c28b50221 100644 --- a/e2e/nested-frame-navigation/e2e/tabs-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts @@ -1,26 +1,31 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, teamsData } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabNavigationScreen } from "./tab-navigation-screen"; +import { Screen, playersData, teamsData } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabNavigationScreen } from "../screens/tab-navigation-screen"; const roots = ["TabsTop", "TabsBottom"]; -const rootType = "tabs-root"; -describe(rootType, async function () { +describe("tab-navigation-tabs-root", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); + logWarn(`====== "tabs-root" ========`); driver = await createDriver(); + await driver.restartApp(); screen = new TabNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); + + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); } + await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = 8000; }); @@ -40,7 +45,7 @@ describe(rootType, async function () { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root}-scenarios:`, async function () { + describe(`tab-navigation-tabs-root-${root}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; @@ -54,17 +59,10 @@ describe(rootType, async function () { const teamOne = teamsData[`teamOne${transition}`]; const teamTwo = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { + describe(`tabs-root-${root}-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } }); it("loaded home page", async function () { diff --git a/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts similarity index 84% rename from e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts rename to e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts index f01741f12..ad4500b3f 100644 --- a/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts @@ -1,27 +1,29 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, teamsData } from "./screen"; -import * as shared from "./shared.e2e-spec"; -import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from "./config"; -import { TabViewNavigationScreen } from "./tabview-navigation-screen"; +import { Screen, playersData, teamsData } from "../screens/screen"; +import * as shared from "../screens/shared"; +import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; +import { TabViewNavigationScreen } from "../screens/tabview-navigation-screen"; // NOTE: TabViewTop is Android only scenario (for iOS we will essentially execute 2x TabViewBottom) const roots = ["TabViewTop", "TabViewBottom"]; -const rootType = "tab-root"; -describe(rootType, async function () { +describe("tab-view-root", async function () { let driver: AppiumDriver; let screen: Screen; - + let transitions = [...allTransitions]; before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`====== ${rootType} ========`); + logWarn(`====== tab-view-root ========`); driver = await createDriver(); + await driver.restartApp(); screen = new TabViewNavigationScreen(driver); - if (dontKeepActivities) { - await driver.setDontKeepActivities(true); + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + console.log("Skipping flip transition tests on api level 19"); + transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); } - + await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = 8000; }); @@ -29,6 +31,10 @@ describe(rootType, async function () { if (dontKeepActivities) { await driver.setDontKeepActivities(false); } + if (driver.isIOS) { + roots.shift(); + logWarn("TabViewTop is Android only scenario (for iOS it will be skipped)"); + } await driver.quit(); console.log("Quit driver!"); }); @@ -41,7 +47,7 @@ describe(rootType, async function () { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root}-scenarios:`, async function () { + describe(`tab-view-root-${root}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; @@ -55,17 +61,10 @@ describe(rootType, async function () { const teamOne = teamsData[`teamOne${transition}`]; const teamTwo = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { + describe(`tab-view-root-${root}-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - - if (transition === "Flip" && - driver.isAndroid && parseInt(driver.platformVersion) === 19) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("skipping flip transition tests on api level 19"); - this.skip(); - } }); it("loaded home page", async function () { From 04c65392a2e8a29c059b67d1b26425ac1dd2a632 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Sat, 2 Nov 2019 01:48:38 +0200 Subject: [PATCH 17/19] test: ignore None transition scenario for api19 (#8035) --- .../frame-root/bottom-navigation.e2e-spec.ts | 29 ++++++++++-------- .../e2e/frame-root/multi-frames.e2e-spec.ts | 16 +++++----- .../e2e/frame-root/single-frame.e2e-spec.ts | 13 ++++---- .../e2e/frame-root/tab-view.e2e-spec.ts | 23 +++++++------- .../e2e/frame-root/tabs.e2e-spec.ts | 26 ++++++++-------- .../e2e/layout-root/multi-frames.e2e-spec.ts | 14 ++++----- .../e2e/layout-root/single-frame.e2e-spec.ts | 30 +++++++++++++++---- .../e2e/screens/shared.ts | 25 ++++++++++++++-- .../bottom-navigation-root.e2e-spec.ts | 14 +++++---- .../tab-navigation-root/tabs-root.e2e-spec.ts | 14 ++++----- .../tab-view-root/tab-view-root.e2e-spec.ts | 12 ++++---- 11 files changed, 131 insertions(+), 85 deletions(-) diff --git a/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts index 9d8c3ec0b..2c339f257 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/bottom-navigation.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, logWarn, nsCapabilities, logInfo } from "nativescript-dev-appium"; import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item } from "../screens/screen"; import * as shared from "../screens/shared"; @@ -8,6 +8,7 @@ import { TabNavigationScreen } from "../screens/tab-navigation-screen"; describe("frame-root-with-bottom-navigation", async function () { let driver: AppiumDriver; let screen: Screen; + let transitions = [...allTransitions]; before(async function () { @@ -18,12 +19,6 @@ describe("frame-root-with-bottom-navigation", async function () { screen = new TabNavigationScreen(driver); await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = driverDefaultWaitTime; - - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } }); after(async function () { @@ -52,7 +47,13 @@ describe("frame-root-with-bottom-navigation", async function () { before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`=========${trIndex++}. BottomNavigation-${transition} =========`); + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`${trIndex++}. BottomNavigation-${transition} =========`); + } }); it("loaded home page", async function () { @@ -107,7 +108,7 @@ describe("frame-root-with-bottom-navigation", async function () { it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -158,9 +159,11 @@ describe("frame-root-with-bottom-navigation", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (appSuspendResume) { - await driver.backgroundApp(suspendTime); - await screen.loadedElement(playerTwo.name); // wait for player + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { + if (appSuspendResume) { + await driver.backgroundApp(suspendTime); + await screen.loadedElement(playerTwo.name); // wait for player + } } await screen.loadedPlayerDetails(playerTwo); @@ -198,7 +201,7 @@ describe("frame-root-with-bottom-navigation", async function () { await shared.testTeamNavigated(teamTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await screen.loadedElement(teamTwo.name); // wait for team await driver.backgroundApp(suspendTime); diff --git a/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts index 59ac2d2d0..b917caf40 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/multi-frames.e2e-spec.ts @@ -1,7 +1,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; -import { Screen, playersData, somePage, teamsData, driverDefaultWaitTime, Item, stillOtherPage } from "../screens/screen"; +import { Screen, playersData, teamsData, driverDefaultWaitTime, Item } from "../screens/screen"; import { suspendTime, appSuspendResume, dontKeepActivities, allTransitions } from "../config"; import * as shared from "../screens/shared"; import { TabNavigationScreen } from "../screens/tab-navigation-screen"; @@ -18,12 +18,6 @@ describe("frame-root-with-multi-frames", async function () { screen = new TabNavigationScreen(driver); await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = driverDefaultWaitTime; - - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } }); after(async function () { @@ -51,7 +45,13 @@ describe("frame-root-with-multi-frames", async function () { describe(`frame-root-with-multi-frames-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`====${index}. Transition ${transition}`); + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`==== ${index}. Transition ${transition}`); + } }); it("loaded home page", async function () { diff --git a/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts index 802b06d32..950ac6f26 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/single-frame.e2e-spec.ts @@ -17,11 +17,6 @@ describe("frame-root-with-single-frame", async function () { screen = new TabNavigationScreen(driver); await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = driverDefaultWaitTime; - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } }); after(async function () { @@ -47,7 +42,13 @@ describe("frame-root-with-single-frame", async function () { describe(`frame-root-with-single-frame-transition-${transition}-scenario:`, async function () { before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`==== ${index}. Transition ${transition}`); + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`==== ${index}. Transition ${transition}`); + } }); it("loaded home page", async function () { diff --git a/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts index 22cd6f7d2..d83572f41 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/tab-view.e2e-spec.ts @@ -27,12 +27,6 @@ describe("frame-root-with-tab-view", async function () { roots.shift(); } - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } - driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -63,10 +57,15 @@ describe("frame-root-with-tab-view", async function () { const teamTwo: Item = teamsData[`teamTwo${transition}`]; describe(`frame-root-with-tab-view-${root}-transition-${transition}-scenario:`, async function () { - before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`========= ${root}-${transition} =========`); + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${root}-${transition} =========`); + } }); it("loaded home page", async function () { @@ -85,7 +84,7 @@ describe("frame-root-with-tab-view", async function () { it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -122,7 +121,7 @@ describe("frame-root-with-tab-view", async function () { it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -173,7 +172,7 @@ describe("frame-root-with-tab-view", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -215,7 +214,7 @@ describe("frame-root-with-tab-view", async function () { await shared.testTeamNavigated(teamTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await screen.loadedElement(teamTwo.name); // wait for team await driver.backgroundApp(suspendTime); diff --git a/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts index 841d04a00..ba5fd3693 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root/tabs.e2e-spec.ts @@ -19,12 +19,6 @@ describe("frame-root-with-tabs", async function () { await driver.restartApp(); screen = new TabNavigationScreen(driver); await driver.setDontKeepActivities(dontKeepActivities); - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } - driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -58,7 +52,13 @@ describe("frame-root-with-tabs", async function () { before(async function () { nsCapabilities.testReporter.context = this; - logWarn(`========= ${root}-${transition} =========`); + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${root}-${transition} =========`); + } }); it("loaded home page", async function () { @@ -113,7 +113,7 @@ describe("frame-root-with-tabs", async function () { it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -164,7 +164,7 @@ describe("frame-root-with-tabs", async function () { await shared.testPlayerNavigated(playerTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(playerTwo.name); // wait for player @@ -175,7 +175,7 @@ describe("frame-root-with-tabs", async function () { await shared[`testSomePageNavigated${transition}`](screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(somePage); // wait for some page @@ -188,7 +188,7 @@ describe("frame-root-with-tabs", async function () { await screen.goBackFromSomePage(); } - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { // This sleeps prevent test to fail await driver.sleep(1000); @@ -201,7 +201,7 @@ describe("frame-root-with-tabs", async function () { await screen.toggleTeamsTab(); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await screen.loadedElement(teamOne.name); // wait for teams list @@ -212,7 +212,7 @@ describe("frame-root-with-tabs", async function () { await shared.testTeamNavigated(teamTwo, screen); - if (!shared.preventApplicationCrashCauesByAutomation(driver)) { + if (!shared.preventApplicationCrashCausedByAutomation(driver)) { if (appSuspendResume) { await screen.loadedElement(teamTwo.name); // wait for team await driver.backgroundApp(suspendTime); diff --git a/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts index 320e1dd8d..db1ac9a63 100644 --- a/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/layout-root/multi-frames.e2e-spec.ts @@ -17,13 +17,6 @@ describe("layout-root-with-multi-frames", async function () { screen = new TabNavigationScreen(driver); logWarn("====== layout-root-with-multi-frames ========"); await driver.setDontKeepActivities(dontKeepActivities); - - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } - driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -52,6 +45,13 @@ describe("layout-root-with-multi-frames", async function () { before(async function () { nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${index}. ${transition} =========`); + } }); it("loaded layout root with multi nested frames", async function () { diff --git a/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts index de11ab012..f407467e8 100644 --- a/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/layout-root/single-frame.e2e-spec.ts @@ -17,11 +17,6 @@ describe("layout-root-with-single-frame", async function () { screen = new TabNavigationScreen(driver); logWarn("====== layout-root-with-single-frame ========"); await driver.setDontKeepActivities(dontKeepActivities); - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } driver.defaultWaitTime = driverDefaultWaitTime; }); @@ -49,6 +44,13 @@ describe("layout-root-with-single-frame", async function () { before(async function () { nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${index}. ${transition} =========`); + } }); it("loaded home page", async function () { @@ -143,6 +145,10 @@ describe("layout-root-with-single-frame", async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; + before(async function () { + nsCapabilities.testReporter.context = this; + }); + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); @@ -202,6 +208,15 @@ describe("layout-root-with-single-frame", async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; + before(async function () { + nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skip tests on api level 19"); + this.skip(); + } + }); + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); @@ -326,6 +341,11 @@ describe("layout-root-with-single-frame", async function () { before(async function () { nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver)) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skip tests on api level 19"); + this.skip(); + } }); it("loaded layout root with nested frames", async function () { diff --git a/e2e/nested-frame-navigation/e2e/screens/shared.ts b/e2e/nested-frame-navigation/e2e/screens/shared.ts index 0f3756287..e1daeba66 100644 --- a/e2e/nested-frame-navigation/e2e/screens/shared.ts +++ b/e2e/nested-frame-navigation/e2e/screens/shared.ts @@ -1,13 +1,32 @@ import { AppiumDriver } from "nativescript-dev-appium"; import { Screen, Item } from "./screen"; +import { logWarn } from "nativescript-dev-appium"; -export const preventApplicationCrashCauesByAutomation = (driver: AppiumDriver) => { - return +driver.nsCapabilities.device.apiLevel > 23 && driver.isAndroid; +export const preventApplicationCrashCausedByAutomation = (driver: AppiumDriver) => { + if (driver.isIOS) { + return false; + } + + let preventApplicationCrashCauesByAutomation = false; + + if (Number.isInteger(+driver.nsCapabilities.device.apiLevel)) { + preventApplicationCrashCauesByAutomation = +driver.nsCapabilities.device.apiLevel > 23; + } else { + const majorVersion = driver.nsCapabilities.device.apiLevel.split(".")[0]; + preventApplicationCrashCauesByAutomation = +majorVersion > 6; + } + if (preventApplicationCrashCauesByAutomation) { + logWarn("Skip run in background app, since it causes crash related to automation!"); + } + + return preventApplicationCrashCauesByAutomation; }; export const isApiLevel19 = (driver: AppiumDriver) => { - return +driver.nsCapabilities.device.apiLevel === 19 && driver.isAndroid; + return driver.isAndroid + && (`${driver.nsCapabilities.device.apiLevel}`.startsWith("19") + || `${driver.nsCapabilities.device.apiLevel}`.startsWith("4.4.2")); }; export async function testPlayerNavigated(player: Item, screen: Screen) { diff --git a/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts index 65ae33ae3..a1e56b17c 100644 --- a/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-navigation-root/bottom-navigation-root.e2e-spec.ts @@ -16,12 +16,7 @@ describe("tab-navigation-bottom-navigation-root", async function () { driver = await createDriver(); await driver.restartApp(); screen = new TabNavigationScreen(driver); - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } - await driver.setDontKeepActivities(dontKeepActivities); + driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = 8000; }); @@ -49,6 +44,13 @@ describe("tab-navigation-bottom-navigation-root", async function () { describe(`bottom-navigation-root-transition-${transition}-scenario:`, async function () { before(async function () { + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${index}. ${transition} =========`); + } nsCapabilities.testReporter.context = this; }); diff --git a/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts index c28b50221..03bb70501 100644 --- a/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-navigation-root/tabs-root.e2e-spec.ts @@ -18,13 +18,6 @@ describe("tab-navigation-tabs-root", async function () { driver = await createDriver(); await driver.restartApp(); screen = new TabNavigationScreen(driver); - - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } - await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = 8000; }); @@ -63,6 +56,13 @@ describe("tab-navigation-tabs-root", async function () { before(async function () { nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${root}-${transition} =========`); + } }); it("loaded home page", async function () { diff --git a/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts index ad4500b3f..cc9f6f235 100644 --- a/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-view-root/tab-view-root.e2e-spec.ts @@ -18,11 +18,6 @@ describe("tab-view-root", async function () { driver = await createDriver(); await driver.restartApp(); screen = new TabViewNavigationScreen(driver); - if (shared.isApiLevel19(driver)) { - // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 - console.log("Skipping flip transition tests on api level 19"); - transitions = transitions.filter(tr => !tr.toLowerCase().includes("flip")); - } await driver.setDontKeepActivities(dontKeepActivities); driver.defaultWaitTime = 8000; }); @@ -65,6 +60,13 @@ describe("tab-view-root", async function () { before(async function () { nsCapabilities.testReporter.context = this; + if (shared.isApiLevel19(driver) && (transition === "None" || transition === "Flip")) { + // TODO: known issue https://github.com/NativeScript/NativeScript/issues/6798 + logWarn("Skipping flip or none transition tests on api level 19"); + this.skip(); + } else { + logWarn(`========= ${root}-${transition} =========`); + } }); it("loaded home page", async function () { From 2a343684650d54d5b4901b8399172957868cba1d Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Wed, 6 Nov 2019 12:07:34 +0000 Subject: [PATCH 18/19] feat(application): add system appearance changed event to typings (#8034) --- nativescript-core/application/application.d.ts | 5 +++++ nativescript-core/ui/enums/enums.d.ts | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nativescript-core/application/application.d.ts b/nativescript-core/application/application.d.ts index 0a1bd4e54..ddab72616 100644 --- a/nativescript-core/application/application.d.ts +++ b/nativescript-core/application/application.d.ts @@ -52,6 +52,11 @@ export const lowMemoryEvent: string; */ export const orientationChangedEvent: string; +/** + * String value used when hooking to systemAppearanceChanged event. + */ +export const systemAppearanceChangedEvent: string; + /** * Event data containing information for the application events. */ diff --git a/nativescript-core/ui/enums/enums.d.ts b/nativescript-core/ui/enums/enums.d.ts index c9006da08..7181606b3 100644 --- a/nativescript-core/ui/enums/enums.d.ts +++ b/nativescript-core/ui/enums/enums.d.ts @@ -641,7 +641,7 @@ export module AnimationCurve { } /** - * @deprecated use `UserInterfaceStyle` instead. + * @deprecated use `SystemAppearance` instead. * * Specifies the types of the status bar style. */ @@ -657,8 +657,24 @@ export module StatusBarStyle { export const dark: string; } +/** + * Specifies the types of the system appearance. + */ +export module SystemAppearance { + /** + * The light system appearance. + */ + export const light: string; + + /** + * The dark system appearance. + */ + export const dark: string; +} /** + * @deprecated use `SystemAppearance` instead. + * * Specifies the types of the user interface style. */ export module UserInterfaceStyle { From eb33ede5a78b29ec053bb8e8dbfe09f0a1a0e4c9 Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Wed, 6 Nov 2019 16:37:59 +0200 Subject: [PATCH 19/19] fix(gradient): import LinearGradient with alias (#8063) --- nativescript-core/ui/styling/gradient.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nativescript-core/ui/styling/gradient.d.ts b/nativescript-core/ui/styling/gradient.d.ts index 414680e9d..58c081d53 100644 --- a/nativescript-core/ui/styling/gradient.d.ts +++ b/nativescript-core/ui/styling/gradient.d.ts @@ -4,15 +4,15 @@ import { LengthPercentUnit } from "./style-properties"; import { Color } from "../../color"; -import { LinearGradient } from "../../css/parser"; +import { LinearGradient as LinearGradientDefinition } from "../../css/parser"; export class LinearGradient { public angle: number; public colorStops: ColorStop[]; - public static parse(value: LinearGradient): LinearGradient; + public static parse(value: LinearGradientDefinition): LinearGradientDefinition; - public static equals(first: LinearGradient, second: LinearGradient): boolean; + public static equals(first: LinearGradientDefinition, second: LinearGradientDefinition): boolean; } export interface ColorStop {