From f6f7b514d9d78e265681e21c68ea1e179a66baab Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Mon, 15 Apr 2019 17:32:16 +0300 Subject: [PATCH 01/10] fix(ios): application.displayedEvent does not depend on trace to fire (#7141) --- tests/app/app/app.ts | 30 ++++++++----------- .../application/application-tests-common.ts | 9 ++++-- .../application/application.ios.ts | 4 +-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/app/app/app.ts b/tests/app/app/app.ts index a0e348269..2460c988a 100644 --- a/tests/app/app/app.ts +++ b/tests/app/app/app.ts @@ -8,24 +8,6 @@ else { import * as application from "tns-core-modules/application"; -// Specify custom UIApplicationDelegate. -/* -class MyDelegate extends UIResponder implements UIApplicationDelegate { - public static ObjCProtocols = [UIApplicationDelegate]; - - applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary): boolean { - console.log("applicationWillFinishLaunchingWithOptions: " + launchOptions) - return true; - } - - applicationDidBecomeActive(application: UIApplication): void { - console.log("applicationDidBecomeActive: " + application) - } -} - -application.ios.delegate = MyDelegate; -*/ - if (application.ios) { // Observe application notifications. application.ios.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, (notification: NSNotification) => { @@ -34,6 +16,18 @@ if (application.ios) { } // Common events for both Android and iOS. +application.on(application.displayedEvent, function (args: application.ApplicationEventData) { + (global).isDisplayedEventFired = true; + + if (args.android) { + // For Android applications, args.android is an android activity class. + console.log("Activity: " + args.android); + } else if (args.ios) { + // For iOS applications, args.ios is UIApplication. + console.log("UIApplication: " + args.ios); + } +}); + application.on(application.launchEvent, function (args: application.ApplicationEventData) { if (args.android) { // For Android applications, args.android is an android.content.Intent class. diff --git a/tests/app/application/application-tests-common.ts b/tests/app/application/application-tests-common.ts index 0e7a76e30..29be43736 100644 --- a/tests/app/application/application-tests-common.ts +++ b/tests/app/application/application-tests-common.ts @@ -13,11 +13,16 @@ if (app.android) { import * as TKUnit from "../TKUnit"; -export var testInitialized = function () { +export function testInitialized() { if (platform.device.os === platform.platformNames.android) { // we have the android defined TKUnit.assert(app.android, "Application module not properly intialized"); } else if (platform.device.os === platform.platformNames.ios) { TKUnit.assert(app.ios, "Application module not properly intialized"); } -} +} + +export function testDisplayedEvent() { + // global.isDisplayedEventFired flag is set in app.ts application.displayedEvent handler + TKUnit.assert((global).isDisplayedEventFired, "application.displayedEvent not fired"); +} diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 53941c9ef..c302472d7 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -19,7 +19,7 @@ import { createViewFromEntry } from "../ui/builder"; import { ios as iosView, View } from "../ui/core/view"; import { Frame, NavigationEntry } from "../ui/frame"; import * as utils from "../utils/utils"; -import { profile, level as profilingLevel, Level } from "../profiling"; +import { profile } from "../profiling"; // NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430 // TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved: @@ -131,7 +131,7 @@ class IOSApplication implements IOSApplicationDefinition { @profile private didFinishLaunchingWithOptions(notification: NSNotification) { - if (!displayedOnce && profilingLevel() >= Level.lifecycle) { + if (!displayedOnce) { displayedLinkTarget = CADisplayLinkTarget.new(); displayedLink = CADisplayLink.displayLinkWithTargetSelector(displayedLinkTarget, "onDisplayed"); displayedLink.addToRunLoopForMode(NSRunLoop.mainRunLoop, NSDefaultRunLoopMode); From 4b16363d0bb73ae71e8864246efc00f1a610f414 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Thu, 2 May 2019 23:58:58 -0700 Subject: [PATCH 02/10] chore: remove http-server dependency (#7199) `npm i` fails on non windows os because of `http-server` dev dependency. Not sure we need it. --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index f65b9780f..f0f559373 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "grunt-simple-mocha": "0.4.1", "grunt-ts": "6.0.0-beta.11", "grunt-typedoc": "0.2.4", - "http-server": "^0.9.0", "madge": "^2.2.0", "markdown-snippet-injector": "0.2.2", "mocha": "^3.5.0", From c227c5050ac7b05e37830501e1817a36058d3afb Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Fri, 3 May 2019 10:14:31 +0300 Subject: [PATCH 03/10] fix(ios-http-get): http failure during parsing xml (#7175) --- .../http/http-request/http-request.ios.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/http/http-request/http-request.ios.ts b/tns-core-modules/http/http-request/http-request.ios.ts index 2475fb9c7..e0bca9d0a 100644 --- a/tns-core-modules/http/http-request/http-request.ios.ts +++ b/tns-core-modules/http/http-request/http-request.ios.ts @@ -200,11 +200,21 @@ export function request(options: httpModule.HttpRequestOptions): Promise Date: Fri, 3 May 2019 06:39:13 -0700 Subject: [PATCH 04/10] release: cut the 5.3.2 release (#7200) --- CHANGELOG.md | 12 ++++++++++++ tns-core-modules/package.json | 2 +- tns-platform-declarations/package.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd7f8cc0..e6a659ae6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [5.3.2](https://github.com/NativeScript/NativeScript/compare/5.3.1...5.3.2) (2019-05-03) + + +### Bug Fixes + +* no trace message on empty app.css ([#7135](https://github.com/NativeScript/NativeScript/issues/7135)) ([170d2a8](https://github.com/NativeScript/NativeScript/commit/170d2a8)) +* **ios:** application.displayedEvent does not depend on trace to fire ([#7141](https://github.com/NativeScript/NativeScript/issues/7141)) ([f6f7b51](https://github.com/NativeScript/NativeScript/commit/f6f7b51)) +* **ios:** flat action bar incorrect layout after navigation ([#7077](https://github.com/NativeScript/NativeScript/issues/7077)) ([1dc3952](https://github.com/NativeScript/NativeScript/commit/1dc3952)) +* **ios-http-get:** http failure during parsing xml ([#7175](https://github.com/NativeScript/NativeScript/issues/7175)) ([c227c50](https://github.com/NativeScript/NativeScript/commit/c227c50)) + + + ## [5.3.1](https://github.com/NativeScript/NativeScript/compare/5.3.0...5.3.1) (2019-03-28) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index b8e45d1ae..a67fafb53 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -1,7 +1,7 @@ { "name": "tns-core-modules", "description": "Telerik NativeScript Core Modules", - "version": "5.3.1", + "version": "5.3.2", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index 6d073a7ac..b5ea02141 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,6 +1,6 @@ { "name": "tns-platform-declarations", - "version": "5.3.1", + "version": "5.3.2", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", "main": "", "scripts": { From 29ad64576cd0ece03d99fae9df7bfe5ad9786b71 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Mon, 6 May 2019 10:40:15 +0300 Subject: [PATCH 05/10] test: add mochawesome reporter --- e2e/config/mocha.opts | 5 +- e2e/modal-navigation/.gitignore | 1 + .../e2e/android-back-button.e2e-spec.ts | 9 +- .../e2e/modal-frame.e2e-spec.ts | 33 +++--- .../e2e/modal-layout.e2e-spec.ts | 34 +++--- .../e2e/modal-page.e2e-spec.ts | 27 +++-- .../e2e/modal-tab.e2e-spec.ts | 33 +++--- e2e/modal-navigation/e2e/setup.ts | 16 ++- e2e/modal-navigation/package.json | 11 +- e2e/nested-frame-navigation/.gitignore | 1 + .../e2e/frame-root.e2e-spec.ts | 79 ++++++------ .../e2e/frame-tab-root.e2e-spec.ts | 10 +- .../e2e/issues.e2e.spec.ts | 13 +- .../e2e/layout-root.e2e-spec.ts | 112 ++++++++++-------- e2e/nested-frame-navigation/e2e/setup.ts | 16 ++- .../e2e/tab-root.e2e-spec.ts | 35 +++--- e2e/nested-frame-navigation/package.json | 11 +- 17 files changed, 256 insertions(+), 190 deletions(-) diff --git a/e2e/config/mocha.opts b/e2e/config/mocha.opts index a10a923f7..b6efaf4ac 100644 --- a/e2e/config/mocha.opts +++ b/e2e/config/mocha.opts @@ -1,4 +1,5 @@ --timeout 300000 --recursive e2e ---reporter mocha-multi ---reporter-options spec=-,mocha-junit-reporter=test-results.xml \ No newline at end of file +--reporter mochawesome +--reporter-options quiet=true,html=true,inline=true,autoOpen=true +--exit \ No newline at end of file diff --git a/e2e/modal-navigation/.gitignore b/e2e/modal-navigation/.gitignore index c6f9a448e..4e0f8a20e 100644 --- a/e2e/modal-navigation/.gitignore +++ b/e2e/modal-navigation/.gitignore @@ -1 +1,2 @@ .vscode/settings.json +mochawesome-report diff --git a/e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts b/e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts index 979728a6d..c9a4db3a8 100644 --- a/e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/android-back-button.e2e-spec.ts @@ -1,14 +1,15 @@ -import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium"; import { Screen, driverDefaultWaitTime, elementDefaultWaitTimeInSeconds } from "./screen" import { assert } from "chai"; const exampleAndroidBackBtnEvents = "Android Back Btn Events"; -describe("android-navigate-back", () => { +describe("android-navigate-back", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); driver.defaultWaitTime = driverDefaultWaitTime; screen = new Screen(driver); @@ -22,7 +23,7 @@ describe("android-navigate-back", () => { } }); - after(async () => { + after(async function () { await driver.resetApp(); }); diff --git a/e2e/modal-navigation/e2e/modal-frame.e2e-spec.ts b/e2e/modal-navigation/e2e/modal-frame.e2e-spec.ts index e4438c8ba..5b9b636c2 100644 --- a/e2e/modal-navigation/e2e/modal-frame.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/modal-frame.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; import { Screen, driverDefaultWaitTime } from "./screen" import { roots, @@ -10,21 +10,24 @@ import { testDialogBackground } from "./shared.e2e-spec" -describe("modal-frame:", () => { +describe("modal-frame:", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); driver.defaultWaitTime = driverDefaultWaitTime; screen = new Screen(driver); }); - roots.forEach(root => { - describe(`${root} modal frame background scenarios:`, () => { + for (let index = 0; index < roots.length; index++) { + const root = roots[index]; + describe(`${root} modal frame background scenarios:`, async function () { - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; await screen[root](); }); @@ -40,38 +43,38 @@ describe("modal-frame:", () => { } }); - after(async () => { + after(async function () { await screen.closeModal(); await screen.loadedHome(); }); - it("should show dialog confirm, run in background", async () => { + it("should show dialog confirm, run in background", async function () { await testDialogBackground(driver, screen); }); - it("should run modal page with frame in background", async () => { + it("should run modal page with frame in background", async function () { await modalFrameBackground(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); - it("should show nested modal page with frame, run in background, close", async () => { + it("should show nested modal page with frame, run in background, close", async function () { await testNestedModalFrameBackground(driver, screen); }); - it("should show nested modal page, run in background, close", async () => { + it("should show nested modal page, run in background, close", async function () { await testNestedModalPageBackground(driver, screen); }); - it("should navigate to second page, close", async () => { + it("should navigate to second page, close", async function () { await testSecondPageClose(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); }); - }); + }; }); diff --git a/e2e/modal-navigation/e2e/modal-layout.e2e-spec.ts b/e2e/modal-navigation/e2e/modal-layout.e2e-spec.ts index 5222d0229..1f3ab483e 100644 --- a/e2e/modal-navigation/e2e/modal-layout.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/modal-layout.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; import { Screen, driverDefaultWaitTime } from "./screen" import { roots, @@ -10,21 +10,25 @@ import { testDialogBackground } from "./shared.e2e-spec" -describe("modal-layout:", () => { +describe("modal-layout:", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); driver.defaultWaitTime = driverDefaultWaitTime; screen = new Screen(driver); }); - roots.forEach(root => { - describe(`${root} modal layout background scenarios:`, () => { + for (let index = 0; index < roots.length; index++) { + const root = roots[index]; + describe(`${root} modal layout background scenarios:`, async function () { + + before(async function () { + nsCapabilities.testReporter.context = this; - before(async () => { if (driver.isAndroid) { await driver.resetApp(); } @@ -43,38 +47,38 @@ describe("modal-layout:", () => { } }); - after(async () => { + after(async function () { await screen.closeModal(); await screen.loadedHome(); }); - it("should show dialog confirm, run in background", async () => { + it("should show dialog confirm, run in background", async function () { await testDialogBackground(driver, screen); }); - it("should run modal layout in background", async () => { + it("should run modal layout in background", async function () { await modalFrameBackground(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); - it("should show nested modal page with frame, run in background, close", async () => { + it("should show nested modal page with frame, run in background, close", async function () { await testNestedModalFrameBackground(driver, screen); }); - it("should show nested modal page, run in background, close", async () => { + it("should show nested modal page, run in background, close", async function () { await testNestedModalPageBackground(driver, screen); }); - it("should navigate to second page, close", async () => { + it("should navigate to second page, close", async function () { await testSecondPageClose(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); }); - }); + }; }); diff --git a/e2e/modal-navigation/e2e/modal-page.e2e-spec.ts b/e2e/modal-navigation/e2e/modal-page.e2e-spec.ts index e2d0462ed..bf978fba9 100644 --- a/e2e/modal-navigation/e2e/modal-page.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/modal-page.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; import { Screen, driverDefaultWaitTime } from "./screen" import { roots, @@ -9,21 +9,24 @@ import { testDialogBackground } from "./shared.e2e-spec" -describe("modal-page:", () => { +describe("modal-page:", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); driver.defaultWaitTime = driverDefaultWaitTime; screen = new Screen(driver); }); - roots.forEach(root => { - describe(`${root} modal page background scenarios:`, () => { + for (let index = 0; index < roots.length; index++) { + const root = roots[index]; + describe(`${root} modal page background scenarios:`, async function () { - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; if (driver.isAndroid) { await driver.resetApp(); } @@ -42,26 +45,26 @@ describe("modal-page:", () => { } }); - after(async () => { + after(async function () { await screen.closeModal(); await screen.loadedHome(); }); - it("should show dialog confirm, run in background", async () => { + it("should show dialog confirm, run in background", async function () { await testDialogBackground(driver, screen, false); }); - it("should run modal page in background", async () => { + it("should run modal page in background", async function () { await modalPageBackground(driver, screen, false); }); - it("should show nested modal page with frame, run in background, close", async () => { + it("should show nested modal page with frame, run in background, close", async function () { await testNestedModalFrameBackground(driver, screen, false); }); - it("should show nested modal page, run in background, close", async () => { + it("should show nested modal page, run in background, close", async function () { await testNestedModalPageBackground(driver, screen, false); }); }); - }); + }; }); diff --git a/e2e/modal-navigation/e2e/modal-tab.e2e-spec.ts b/e2e/modal-navigation/e2e/modal-tab.e2e-spec.ts index 8b784c1bb..ddfde1168 100644 --- a/e2e/modal-navigation/e2e/modal-tab.e2e-spec.ts +++ b/e2e/modal-navigation/e2e/modal-tab.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; import { Screen, driverDefaultWaitTime } from "./screen" import { roots, @@ -17,16 +17,19 @@ describe("modal-tab:", () => { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); driver.defaultWaitTime = driverDefaultWaitTime; screen = new Screen(driver); }); - roots.forEach(root => { - describe(`${root} modal tab view background scenarios:`, () => { + for (let index = 0; index < roots.length; index++) { + const root = roots[index]; - before(async () => { + describe(`${root} modal tab view background scenarios:`, () => { + before(async function () { + nsCapabilities.testReporter.context = this; if (driver.isAndroid) { await driver.resetApp(); } @@ -45,42 +48,42 @@ describe("modal-tab:", () => { } }); - after(async () => { + after(async function () { await screen.closeModal(); await screen.loadedHome(); }); - it("should show dialog confirm, run in background", async () => { + it("should show dialog confirm, run in background", async function () { await testDialogBackground(driver, screen); }); - it("should run modal tab view in background", async () => { + it("should run modal tab view in background", async function () { await modalTabViewBackground(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); - it("should show nested modal page with frame, run in background, close", async () => { + it("should show nested modal page with frame, run in background, close", async function () { await testNestedModalFrameBackground(driver, screen); }); - it("should show nested modal page, run in background, close", async () => { + it("should show nested modal page, run in background, close", async function () { await testNestedModalPageBackground(driver, screen); }); - it("should navigate to second item, run in background, navigate back to first item", async () => { + it("should navigate to second item, run in background, navigate back to first item", async function () { await testSecondItemBackground(driver, screen); }); - it("should navigate to second page, close", async () => { + it("should navigate to second page, close", async function () { await testSecondPageClose(driver, screen); }); - it("should navigate to second page, run in background, go back", async () => { + it("should navigate to second page, run in background, go back", async function () { await testSecondPageBackground(driver, screen); }); }); - }); + }; }); diff --git a/e2e/modal-navigation/e2e/setup.ts b/e2e/modal-navigation/e2e/setup.ts index 43adfb09f..2c632a6c3 100644 --- a/e2e/modal-navigation/e2e/setup.ts +++ b/e2e/modal-navigation/e2e/setup.ts @@ -1,14 +1,24 @@ -import { AppiumDriver, createDriver, startServer, stopServer } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, startServer, stopServer, LogImageType, ITestReporter, nsCapabilities } from "nativescript-dev-appium"; +const addContext = require('mochawesome/addContext'); let driver: AppiumDriver; -before("start server", async () => { +const testReporterContext = {}; +testReporterContext.name = "mochawesome"; +testReporterContext.reportDir = "mochawesome-report"; +testReporterContext.log = addContext; +testReporterContext.logImageTypes = [LogImageType.screenshots]; +nsCapabilities.testReporter = testReporterContext; + +before("start server", async function(){ + nsCapabilities.testReporter.context = this; await startServer(); driver = await createDriver(); await driver.setDontKeepActivities(true); }); -after("stop server", async () => { +after("stop server", async function(){ + nsCapabilities.testReporter.context = this; await driver.setDontKeepActivities(false); await driver.quit(); await stopServer(); diff --git a/e2e/modal-navigation/package.json b/e2e/modal-navigation/package.json index adb4a0f50..20a572498 100644 --- a/e2e/modal-navigation/package.json +++ b/e2e/modal-navigation/package.json @@ -9,7 +9,7 @@ "version": "next" }, "tns-android": { - "version": "next" + "version": "5.4.0-2019-05-02-235338-05" } }, "dependencies": { @@ -17,12 +17,11 @@ "tns-core-modules": "next" }, "devDependencies": { - "@types/chai": "~4.1.3", - "@types/mocha": "~5.2.1", + "@types/chai": "~4.1.7", + "@types/mocha": "~5.2.5", "@types/node": "^7.0.5", - "mocha": "^5.2.0", - "mocha-junit-reporter": "^1.18.0", - "mocha-multi": "^1.0.1", + "mocha": "~5.2.0", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "next", diff --git a/e2e/nested-frame-navigation/.gitignore b/e2e/nested-frame-navigation/.gitignore index c6f9a448e..bec5ea570 100644 --- a/e2e/nested-frame-navigation/.gitignore +++ b/e2e/nested-frame-navigation/.gitignore @@ -1 +1,2 @@ .vscode/settings.json +mochawesome-report \ 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.e2e-spec.ts index 3f64a2882..8e38b6702 100644 --- a/e2e/nested-frame-navigation/e2e/frame-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-root.e2e-spec.ts @@ -1,15 +1,16 @@ -import { AppiumDriver, createDriver, logWarn } from "nativescript-dev-appium"; +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"; const rootType = "frame-root"; -describe(rootType, () => { +describe(rootType, async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); screen = new Screen(driver); if (dontKeepActivities) { @@ -19,7 +20,7 @@ describe(rootType, () => { driver.defaultWaitTime = driverDefaultWaitTime; }); - after(async () => { + after(async function () { if (dontKeepActivities) { await driver.setDontKeepActivities(false); } @@ -41,8 +42,9 @@ describe(rootType, () => { const teamOne: Item = teamsData[`teamOne${transition}`]; const teamTwo: Item = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-transition-${transition}-scenarios:`, () => { + describe(`${rootType}-transition-${transition}-scenarios:`, async function () { before(async function () { + nsCapabilities.testReporter.context = this; logWarn(`==== Transition ${transition}`); if (transition === "Flip" && @@ -53,20 +55,20 @@ describe(rootType, () => { } }); - it("loaded home page", async () => { + it("loaded home page", async function () { await screen.loadedHome(); }); - it("loaded frame root with nested frame", async () => { + it("loaded frame root with nested frame", async function () { await screen.navigateToPageWithFrame(); await screen.loadedPageWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details and go back twice", async () => { + it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -85,7 +87,7 @@ describe(rootType, () => { await shared.testPlayerNavigatedBack(screen, driver); }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared[`testSomePageNavigated${transition}`](screen); if (appSuspendResume) { @@ -102,7 +104,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded player details and navigate parent frame and go back", async () => { + it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -129,7 +131,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.goBackFromFrameHome(); await screen.loadedHome(); @@ -139,20 +141,20 @@ describe(rootType, () => { } }); - it("loaded frame root with multi nested frames", async () => { + it("loaded frame root with multi nested frames", async function () { await screen.navigateToPageWithMultiFrame(); await screen.loadedPageWithMultiFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded teams list", async () => { + it("loaded teams list", async function () { await screen.loadedTeamsList(); }); - it("loaded player details and go back twice", async () => { + it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -171,7 +173,7 @@ describe(rootType, () => { await shared.testPlayerNavigatedBack(screen, driver); }); - it("navigate players parent frame and go back", async () => { + it("navigate players parent frame and go back", async function () { await shared[`testSomePageNavigated${transition}`](screen); if (appSuspendResume) { @@ -188,7 +190,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded players details and navigate parent frame and go back", async () => { + it("loaded players details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -216,19 +218,19 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded frame root with multi nested frames again", async () => { + it("loaded frame root with multi nested frames again", async function () { await screen.loadedPageWithMultiFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded teams list", async () => { + it("loaded teams list", async function () { await screen.loadedTeamsList(); }); - it("mix player and team list actions and go back", async () => { + it("mix player and team list actions and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -292,26 +294,30 @@ describe(rootType, () => { await screen.loadedTeamsList(); }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.goBackFromFrameHome(); await screen.loadedHome(); }); }); } - describe("frame to nested frame with non-default transition", () => { + describe("frame to nested frame with non-default transition", async function () { const playerOne = playersData["playerOneSlide"]; - it("loaded home page", async () => { + 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 () => { + 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 () => { + it("go back to home page again", async function () { if (appSuspendResume) { await driver.backgroundApp(suspendTime); await driver.waitForElement(playerOne.name); // wait for players list @@ -322,17 +328,22 @@ describe(rootType, () => { }); }); - describe("nested frame to frame with non-default transition", () => { - it("loaded home page", async () => { + 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 () => { + it("loaded frame root with nested frame", async function () { await screen.navigateToPageWithFrame(); await screen.loadedPageWithFrame(); }); - - it("navigate to some page with slide transition", async () => { + + it("navigate to some page with slide transition", async function () { shared.testSomePageNavigatedSlide(screen); if (appSuspendResume) { @@ -341,7 +352,7 @@ describe(rootType, () => { } }); - it("navigate to still other page and go back twice", async () => { + it("navigate to still other page and go back twice", async function () { shared.testStillOtherPageNavigatedSlide(screen); if (appSuspendResume) { @@ -378,7 +389,7 @@ describe(rootType, () => { await screen.loadedSomePage(); }); - it("go back to home page again", async () => { + it("go back to home page again", async function () { await screen.goBackFromSomePage(); await screen.goBackFromFrameHome(); diff --git a/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts index a2ab21dbe..f46a10e5f 100644 --- a/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/frame-tab-root.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver, logWarn } from "nativescript-dev-appium"; +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"; @@ -8,11 +8,12 @@ import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from " const roots = ["TabTop", "TabBottom"]; const rootType = "frame-tab-root"; -describe(rootType, () => { +describe(rootType, async function () { let driver: AppiumDriver; let screen: Screen; before(async () => { + nsCapabilities.testReporter.context = this; logWarn(`====== ${rootType} ========`); driver = await createDriver(); screen = new Screen(driver); @@ -40,7 +41,7 @@ describe(rootType, () => { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root} scenarios:`, () => { + describe(`${rootType}-${root} scenarios:`, async function () { logWarn(`===== Root: ${root}`); for (let trIndex = 0; trIndex < transitions.length; trIndex++) { const transition = transitions[trIndex]; @@ -49,9 +50,10 @@ describe(rootType, () => { const teamOne: Item = teamsData[`teamOne${transition}`]; const teamTwo: Item = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, () => { + describe(`${rootType}-${root}-transition-${transition}-scenarios:`, async function () { before(async function () { + nsCapabilities.testReporter.context = this; logWarn(`========= ${root}-${transition} =========`); if (transition === "Flip" && diff --git a/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts b/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts index e5c9c2d3b..e4a17c940 100644 --- a/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts +++ b/e2e/nested-frame-navigation/e2e/issues.e2e.spec.ts @@ -1,12 +1,13 @@ -import { AppiumDriver, createDriver } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium"; import { Screen } from "./screen"; import { suspendTime, dontKeepActivities } from "./config"; -describe("issues", () => { +describe("issues", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); screen = new Screen(driver); if (dontKeepActivities) { @@ -14,7 +15,7 @@ describe("issues", () => { } }); - after(async () => { + after(async function () { if (dontKeepActivities) { await driver.setDontKeepActivities(false); } @@ -29,9 +30,9 @@ describe("issues", () => { } }); - it("issue-6488", async () => { + it("issue-6488", async function () { await screen.loadedHome(); - const showSomePage = async () => { + const showSomePage = async function () { const somePageBtn = await driver.waitForElement("somePageOnRoot"); await somePageBtn.tap(); await screen.loadedSomePage(); diff --git a/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts index 15623e4e1..a153ac9a7 100644 --- a/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/layout-root.e2e-spec.ts @@ -1,15 +1,16 @@ -import { AppiumDriver, createDriver, logWarn } from "nativescript-dev-appium"; +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"; const rootType = "layout-root"; -describe(rootType, () => { +describe(rootType, async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); screen = new Screen(driver); logWarn("====== layout-root ========") @@ -20,7 +21,7 @@ describe(rootType, () => { driver.defaultWaitTime = driverDefaultWaitTime; }); - after(async () => { + after(async function () { if (dontKeepActivities) { await driver.setDontKeepActivities(false); } @@ -41,9 +42,10 @@ describe(rootType, () => { const playerTwo = playersData[`playerTwo${transition}`]; const teamOne = teamsData[`teamOne${transition}`]; - describe(`${rootType}-transition-${transition}-scenarios:`, () => { + describe(`${rootType}-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 @@ -52,20 +54,20 @@ describe(rootType, () => { } }); - it("loaded home page", async () => { + it("loaded home page", async function () { await screen.loadedHome(); }); - it("loaded layout root with nested frames", async () => { + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details and go back twice", async () => { + it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -84,7 +86,7 @@ describe(rootType, () => { await shared.testPlayerNavigatedBack(screen, driver); }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared[`testSomePageNavigated${transition}`](screen); if (appSuspendResume) { @@ -101,7 +103,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded player details and navigate parent frame and go back", async () => { + it("loaded player details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -128,7 +130,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); @@ -138,20 +140,20 @@ describe(rootType, () => { } }); - it("loaded layout root with multi nested frames", async () => { + it("loaded layout root with multi nested frames", async function () { await screen.navigateToLayoutWithMultiFrame(); await screen.loadedLayoutWithMultiFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded teams list", async () => { + it("loaded teams list", async function () { await screen.loadedTeamsList(); }); - it("loaded player details and go back twice", async () => { + it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -170,7 +172,7 @@ describe(rootType, () => { await shared.testPlayerNavigatedBack(screen, driver); }); - it("navigate players parent frame and go back", async () => { + it("navigate players parent frame and go back", async function () { await shared[`testSomePageNavigated${transition}`](screen); if (appSuspendResume) { @@ -187,7 +189,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded players details and navigate parent frame and go back", async () => { + it("loaded players details and navigate parent frame and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -214,19 +216,19 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded layout root with multi nested frames again", async () => { + it("loaded layout root with multi nested frames again", async function () { await screen.loadedLayoutWithMultiFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded teams list", async () => { + it("loaded teams list", async function () { await screen.loadedTeamsList(); }); - it("mix player and team list actions and go back", async () => { + it("mix player and team list actions and go back", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -299,27 +301,27 @@ describe(rootType, () => { await screen.loadedTeamsList(); }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); }); }; - describe(`${rootType}-players-list-slide-transition with parent frame default transition:`, () => { + describe(`${rootType}-players-list-slide-transition with parent frame default transition:`, async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; - it("loaded layout root with nested frames", async () => { + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details with slide", async () => { + it("loaded player details with slide", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -328,7 +330,7 @@ describe(rootType, () => { } }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared.testSomePageNavigatedDefault(screen); if (appSuspendResume) { @@ -350,7 +352,7 @@ describe(rootType, () => { await screen.loadedPlayerDetails(playerTwo); }); - it("loaded player list", async () => { + it("loaded player list", async function () { await screen.goBackToPlayersList(); if (appSuspendResume) { @@ -359,26 +361,26 @@ describe(rootType, () => { } }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); }); - describe(`${rootType}-players-list-slide-transition with parent frame no transition:`, () => { + describe(`${rootType}-players-list-slide-transition with parent frame no transition:`, async function () { const playerOne = playersData["playerOneSlide"]; const playerTwo = playersData["playerTwoSlide"]; - it("loaded layout root with nested frames", async () => { + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details with slide", async () => { + it("loaded player details with slide", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -387,7 +389,7 @@ describe(rootType, () => { } }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared.testSomePageNavigatedNone(screen); if (appSuspendResume) { @@ -409,7 +411,7 @@ describe(rootType, () => { await screen.loadedPlayerDetails(playerTwo); }); - it("loaded player list", async () => { + it("loaded player list", async function () { await screen.goBackToPlayersList(); if (appSuspendResume) { @@ -418,26 +420,30 @@ describe(rootType, () => { } }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); }); - describe(`${rootType}-players-list-flip-transition with parent frame default transition:`, () => { + describe(`${rootType}-players-list-flip-transition with parent frame default transition:`, async function () { const playerOne = playersData["playerOneFlip"]; const playerTwo = playersData["playerTwoFlip"]; - it("loaded layout root with nested frames", async () => { + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details with slide", async () => { + it("loaded player details with slide", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -446,7 +452,7 @@ describe(rootType, () => { } }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared.testSomePageNavigatedDefault(screen); if (appSuspendResume) { @@ -468,7 +474,7 @@ describe(rootType, () => { await screen.loadedPlayerDetails(playerTwo); }); - it("loaded player list", async () => { + it("loaded player list", async function () { await screen.goBackToPlayersList(); if (appSuspendResume) { @@ -477,26 +483,30 @@ describe(rootType, () => { } }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); }); - describe(`${rootType}-players-list-flip-transition with parent frame no transition:`, () => { + describe(`${rootType}-players-list-flip-transition with parent frame no transition:`, async function () { const playerOne = playersData["playerOneFlip"]; const playerTwo = playersData["playerTwoFlip"]; - it("loaded layout root with nested frames", async () => { + before(async function () { + nsCapabilities.testReporter.context = this; + }); + + it("loaded layout root with nested frames", async function () { await screen.navigateToLayoutWithFrame(); await screen.loadedLayoutWithFrame(); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details with slide", async () => { + it("loaded player details with slide", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -505,7 +515,7 @@ describe(rootType, () => { } }); - it("navigate parent frame and go back", async () => { + it("navigate parent frame and go back", async function () { await shared.testSomePageNavigatedNone(screen); if (appSuspendResume) { @@ -527,7 +537,7 @@ describe(rootType, () => { await screen.loadedPlayerDetails(playerTwo); }); - it("loaded player list", async () => { + it("loaded player list", async function () { await screen.goBackToPlayersList(); if (appSuspendResume) { @@ -536,7 +546,7 @@ describe(rootType, () => { } }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); diff --git a/e2e/nested-frame-navigation/e2e/setup.ts b/e2e/nested-frame-navigation/e2e/setup.ts index 8b26e66e9..7131c1e28 100644 --- a/e2e/nested-frame-navigation/e2e/setup.ts +++ b/e2e/nested-frame-navigation/e2e/setup.ts @@ -1,9 +1,19 @@ -import { startServer, stopServer } from "nativescript-dev-appium"; +import { startServer, stopServer, nsCapabilities, ITestReporter, LogImageType } from "nativescript-dev-appium"; +const addContext = require('mochawesome/addContext'); -before("start server", async () => { +const testReporterContext = {}; +testReporterContext.name = "mochawesome"; +testReporterContext.reportDir = "mochawesome-report"; +testReporterContext.log = addContext; +testReporterContext.logImageTypes = [LogImageType.screenshots]; +nsCapabilities.testReporter = testReporterContext; + +before("start server", async function () { + nsCapabilities.testReporter.context = this; await startServer(); }); -after("stop server", async () => { +after("stop server", async function () { + nsCapabilities.testReporter.context = this; await stopServer(); }); diff --git a/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts b/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts index 87f935703..8b8c536cf 100644 --- a/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts +++ b/e2e/nested-frame-navigation/e2e/tab-root.e2e-spec.ts @@ -1,4 +1,4 @@ -import { AppiumDriver, createDriver, logWarn } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescript-dev-appium"; import { Screen, playersData, teamsData } from "./screen"; import * as shared from "./shared.e2e-spec"; @@ -8,11 +8,12 @@ import { suspendTime, appSuspendResume, dontKeepActivities, transitions } from " const roots = ["TabTop", "TabBottom"]; const rootType = "tab-root"; -describe(rootType, () => { +describe(rootType, async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; logWarn(`====== ${rootType} ========`) driver = await createDriver(); screen = new Screen(driver); @@ -23,7 +24,7 @@ describe(rootType, () => { driver.defaultWaitTime = 8000; }); - after(async () => { + after(async function () { if (dontKeepActivities) { await driver.setDontKeepActivities(false); } @@ -39,7 +40,11 @@ describe(rootType, () => { for (let index = 0; index < roots.length; index++) { const root = roots[index]; - describe(`${rootType}-${root}-scenarios:`, () => { + 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]; @@ -49,9 +54,11 @@ describe(rootType, () => { const teamOne = teamsData[`teamOne${transition}`]; const teamTwo = teamsData[`teamTwo${transition}`]; - describe(`${rootType}-${root}-transition-${transition}-scenarios:`, () => { + 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 @@ -60,20 +67,20 @@ describe(rootType, () => { } }); - it("loaded home page", async () => { + it("loaded home page", async function () { await screen.loadedHome(); }); - it(`loaded ${root} root with frames`, async () => { + it(`loaded ${root} root with frames`, async function () { await screen[`navigateTo${root}RootWithFrames`](); await screen[`loaded${root}RootWithFrames`](); }); - it("loaded players list", async () => { + it("loaded players list", async function () { await screen.loadedPlayersList(); }); - it("loaded player details and go back twice", async () => { + it("loaded player details and go back twice", async function () { await shared.testPlayerNavigated(playerTwo, screen); if (appSuspendResume) { @@ -92,7 +99,7 @@ describe(rootType, () => { await shared.testPlayerNavigatedBack(screen, driver); }); - it("toggle teams tab", async () => { + it("toggle teams tab", async function () { await screen.toggleTeamsTab(); if (appSuspendResume) { @@ -101,11 +108,11 @@ describe(rootType, () => { } }); - it("loaded teams list", async () => { + it("loaded teams list", async function () { await screen.loadedTeamsList(); }); - it("mix player and team list actions and go back", async () => { + it("mix player and team list actions and go back", async function () { await screen.togglePlayersTab(); if (appSuspendResume) { @@ -163,7 +170,7 @@ describe(rootType, () => { await screen.loadedPlayersList(); }); - it("loaded home page again", async () => { + it("loaded home page again", async function () { await screen.resetToHome(); await screen.loadedHome(); }); diff --git a/e2e/nested-frame-navigation/package.json b/e2e/nested-frame-navigation/package.json index 719d0cd21..5e8435ca2 100644 --- a/e2e/nested-frame-navigation/package.json +++ b/e2e/nested-frame-navigation/package.json @@ -9,7 +9,7 @@ "version": "next" }, "tns-android": { - "version": "next" + "version": "5.4.0-2019-05-02-235338-05" } }, "dependencies": { @@ -17,12 +17,11 @@ "tns-core-modules": "next" }, "devDependencies": { - "@types/chai": "~4.1.3", - "@types/mocha": "~5.2.1", + "@types/chai": "~4.1.7", + "@types/mocha": "~5.2.5", "@types/node": "^7.0.5", - "mocha": "^5.2.0", - "mocha-junit-reporter": "^1.18.0", - "mocha-multi": "^1.0.1", + "mocha": "~5.2.0", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "next", From a7bfabcaec490f362cb134bbb58cb4f00159667b Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Mon, 6 May 2019 13:33:26 +0300 Subject: [PATCH 06/10] chore: fix tslint --- e2e/modal-navigation/e2e/setup.ts | 6 +++--- e2e/nested-frame-navigation/e2e/setup.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/modal-navigation/e2e/setup.ts b/e2e/modal-navigation/e2e/setup.ts index 2c632a6c3..34f4a15ed 100644 --- a/e2e/modal-navigation/e2e/setup.ts +++ b/e2e/modal-navigation/e2e/setup.ts @@ -1,5 +1,5 @@ import { AppiumDriver, createDriver, startServer, stopServer, LogImageType, ITestReporter, nsCapabilities } from "nativescript-dev-appium"; -const addContext = require('mochawesome/addContext'); +const addContext = require("mochawesome/addContext"); let driver: AppiumDriver; @@ -10,14 +10,14 @@ testReporterContext.log = addContext; testReporterContext.logImageTypes = [LogImageType.screenshots]; nsCapabilities.testReporter = testReporterContext; -before("start server", async function(){ +before("start server", async function () { nsCapabilities.testReporter.context = this; await startServer(); driver = await createDriver(); await driver.setDontKeepActivities(true); }); -after("stop server", async function(){ +after("stop server", async function () { nsCapabilities.testReporter.context = this; await driver.setDontKeepActivities(false); await driver.quit(); diff --git a/e2e/nested-frame-navigation/e2e/setup.ts b/e2e/nested-frame-navigation/e2e/setup.ts index 7131c1e28..ccb15d390 100644 --- a/e2e/nested-frame-navigation/e2e/setup.ts +++ b/e2e/nested-frame-navigation/e2e/setup.ts @@ -1,5 +1,5 @@ import { startServer, stopServer, nsCapabilities, ITestReporter, LogImageType } from "nativescript-dev-appium"; -const addContext = require('mochawesome/addContext'); +const addContext = require("mochawesome/addContext"); const testReporterContext = {}; testReporterContext.name = "mochawesome"; From a2a044cfa8e6722d68c7810d07e70be56ed385de Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 7 May 2019 09:55:41 +0300 Subject: [PATCH 07/10] tests: include mochawesome reporter --- e2e/animation/.gitignore | 1 + e2e/animation/e2e/animation.e2e-spec.ts | 17 +++++++++-------- e2e/animation/e2e/setup.ts | 14 +++++++++++--- e2e/animation/package.json | 11 +++++------ e2e/modal-navigation/package.json | 2 +- e2e/nested-frame-navigation/package.json | 2 +- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/e2e/animation/.gitignore b/e2e/animation/.gitignore index c6f9a448e..bec5ea570 100644 --- a/e2e/animation/.gitignore +++ b/e2e/animation/.gitignore @@ -1 +1,2 @@ .vscode/settings.json +mochawesome-report \ No newline at end of file diff --git a/e2e/animation/e2e/animation.e2e-spec.ts b/e2e/animation/e2e/animation.e2e-spec.ts index 5177934a9..aa015c6d2 100644 --- a/e2e/animation/e2e/animation.e2e-spec.ts +++ b/e2e/animation/e2e/animation.e2e-spec.ts @@ -1,20 +1,21 @@ -import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium"; +import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativescript-dev-appium"; import { Screen } from "./screen"; import { assert } from "chai"; -describe("animation:", () => { +describe("animation:", async function () { let driver: AppiumDriver; let screen: Screen; - before(async () => { + before(async function () { + nsCapabilities.testReporter.context = this; driver = await createDriver(); screen = new Screen(driver); await driver.resetApp(); }); - after(async () => { + after(async function () { await driver.quit(); console.log("Quit driver!"); }); @@ -26,12 +27,12 @@ describe("animation:", () => { } }); - it("should navigate to chaining with animation set example", async () => { + it("should navigate to chaining with animation set example", async function () { await screen.loadedHome(); await screen.loadedChainingWithAnimationSet(); }); - it("should play animation sequentially", async () => { + it("should play animation sequentially", async function () { const buttonAnimate = await driver.findElementByText("Animate Sequentially", SearchOptions.exact); await buttonAnimate.click(); @@ -39,7 +40,7 @@ describe("animation:", () => { assert.isTrue(await label.isDisplayed()); }); - it ("should reset example", async() => { + it("should reset example", async () => { const buttonReset = await driver.findElementByText("Reset", SearchOptions.exact); await buttonReset.click(); @@ -47,7 +48,7 @@ describe("animation:", () => { assert.isTrue(await label.isDisplayed()); }); - it("should play animation simultaneously", async () => { + it("should play animation simultaneously", async function () { const button = await driver.findElementByText("Animate Simultaneously", SearchOptions.exact); await button.click(); diff --git a/e2e/animation/e2e/setup.ts b/e2e/animation/e2e/setup.ts index 43adfb09f..644287cbd 100644 --- a/e2e/animation/e2e/setup.ts +++ b/e2e/animation/e2e/setup.ts @@ -1,14 +1,22 @@ -import { AppiumDriver, createDriver, startServer, stopServer } from "nativescript-dev-appium"; +import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType, AppiumDriver, createDriver } from "nativescript-dev-appium"; +const addContext = require('mochawesome/addContext'); +const testReporterContext = {}; +testReporterContext.name = "mochawesome"; +testReporterContext.reportDir = "mochawesome-report"; +testReporterContext.log = addContext; +testReporterContext.logImageTypes = [LogImageType.screenshots]; +nsCapabilities.testReporter = testReporterContext; let driver: AppiumDriver; -before("start server", async () => { +before("start server", async function () { + nsCapabilities.testReporter.context = this; await startServer(); driver = await createDriver(); await driver.setDontKeepActivities(true); }); -after("stop server", async () => { +after("stop server", async function () { await driver.setDontKeepActivities(false); await driver.quit(); await stopServer(); diff --git a/e2e/animation/package.json b/e2e/animation/package.json index 8466e4a80..00c40a851 100644 --- a/e2e/animation/package.json +++ b/e2e/animation/package.json @@ -17,16 +17,15 @@ "tns-core-modules": "next" }, "devDependencies": { - "@types/chai": "~4.1.3", - "@types/mocha": "~5.2.1", - "@types/node": "10.11.4", + "@types/chai": "~4.1.7", + "@types/mocha": "~5.2.5", + "@types/node": "~10.12.18", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "lazy": "1.0.11", - "mocha": "~5.1.0", - "mocha-junit-reporter": "~1.17.0", - "mocha-multi": "~1.0.0", + "mocha": "~5.2.0", + "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "next" diff --git a/e2e/modal-navigation/package.json b/e2e/modal-navigation/package.json index 20a572498..68db87859 100644 --- a/e2e/modal-navigation/package.json +++ b/e2e/modal-navigation/package.json @@ -9,7 +9,7 @@ "version": "next" }, "tns-android": { - "version": "5.4.0-2019-05-02-235338-05" + "version": "next" } }, "dependencies": { diff --git a/e2e/nested-frame-navigation/package.json b/e2e/nested-frame-navigation/package.json index 5e8435ca2..e9754a49e 100644 --- a/e2e/nested-frame-navigation/package.json +++ b/e2e/nested-frame-navigation/package.json @@ -9,7 +9,7 @@ "version": "next" }, "tns-android": { - "version": "5.4.0-2019-05-02-235338-05" + "version": "next" } }, "dependencies": { From 2ca4eba58fcc37936b9a379aaa55d9b5fc4acf46 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 7 May 2019 10:15:52 +0300 Subject: [PATCH 08/10] chore: fix tslint --- e2e/animation/e2e/setup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/animation/e2e/setup.ts b/e2e/animation/e2e/setup.ts index 644287cbd..d68b28048 100644 --- a/e2e/animation/e2e/setup.ts +++ b/e2e/animation/e2e/setup.ts @@ -1,5 +1,5 @@ import { startServer, stopServer, ITestReporter, nsCapabilities, LogImageType, AppiumDriver, createDriver } from "nativescript-dev-appium"; -const addContext = require('mochawesome/addContext'); +const addContext = require("mochawesome/addContext"); const testReporterContext = {}; testReporterContext.name = "mochawesome"; From 4f79d2e2a13cd727b94eb1e334e73606125c9d44 Mon Sep 17 00:00:00 2001 From: Luke Curran Date: Tue, 7 May 2019 13:44:12 -0500 Subject: [PATCH 09/10] fix(iOS): Image cache module not longer sets null in NSCache (#7171) * Image cache module fix * Cla verified | use const instead of let * Image cache module fix * Cla verified | use const instead of let * Improve tests --- AUTHORS | 3 +- tests/app/testRunner.ts | 3 + tests/app/ui/image-cache/image-cache-tests.ts | 74 ++++++++++++++----- .../ui/image-cache/image-cache.ios.ts | 6 +- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/AUTHORS b/AUTHORS index ab42c6100..80999269b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ John Bristowe Joe D Kamen Velikov Lubomir Blagoev +Luke Curran Matt Donovan Matthew Knight Mihail Slavchev @@ -37,4 +38,4 @@ Vasil Chimev Victor Nascimento Vladimir Enchev Wei Zhang -Yavor Georgiev \ No newline at end of file +Yavor Georgiev diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index aef985b13..7ca909f71 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -189,6 +189,9 @@ allTests["TAB-VIEW-NAVIGATION"] = tabViewNavigationTests; import * as imageTests from "./ui/image/image-tests"; allTests["IMAGE"] = imageTests; +import * as imageCacheTests from "./ui/image-cache/image-cache-tests"; +allTests["IMAGE-CACHE"] = imageCacheTests; + import * as sliderTests from "./ui/slider/slider-tests"; allTests["SLIDER"] = sliderTests; diff --git a/tests/app/ui/image-cache/image-cache-tests.ts b/tests/app/ui/image-cache/image-cache-tests.ts index c70fe9161..c6237b8ac 100644 --- a/tests/app/ui/image-cache/image-cache-tests.ts +++ b/tests/app/ui/image-cache/image-cache-tests.ts @@ -1,25 +1,21 @@ -// >> image-cache-require -import * as imageCacheModule from "tns-core-modules/ui/image-cache"; +import * as imageCacheModule from "tns-core-modules/ui/image-cache"; import * as imageSource from "tns-core-modules/image-source"; -import * as fs from "tns-core-modules/file-system"; -// << image-cache-require +import * as types from "tns-core-modules/utils/types"; +import * as TKUnit from "../../TKUnit"; -export function test_DummyTestForSnippetOnly() { - // >> image-cache-request-images - var cache = new imageCacheModule.Cache(); - cache.placeholder = imageSource.fromFile(fs.path.join(__dirname, "res/no-image.png")); +export const test_ImageCache_ValidUrl = function() { + const cache = new imageCacheModule.Cache(); cache.maxRequests = 5; - - // Enable download while not scrolling - cache.enableDownload(); - - var imgSouce: imageSource.ImageSource; - var url = "https://github.com/NativeScript.png"; + + let validKey: string; + + let imgSource: imageSource.ImageSource; + const url = "https://github.com/NativeScript.png"; // Try to read the image from the cache - var image = cache.get(url); + const image = cache.get(url); if (image) { // If present -- use it. - imgSouce = imageSource.fromNativeSource(image); + imgSource = imageSource.fromNativeSource(image); } else { // If not present -- request its download. @@ -28,13 +24,51 @@ export function test_DummyTestForSnippetOnly() { url: url, completed: (image: any, key: string) => { if (url === key) { - imgSouce = imageSource.fromNativeSource(image); + imgSource = imageSource.fromNativeSource(image); + validKey = key; + console.log("Valid url: ", key); } } }); } - // Disable download while scrolling - cache.disableDownload(); - // << image-cache-request-images + TKUnit.waitUntilReady(() => types.isDefined(validKey), 8); + TKUnit.assertEqual(validKey, url, "Key should equal the provided url"); +} + +export const test_ImageCache_NothingAtProvidedUrl = function() { + const cache = new imageCacheModule.Cache(); + cache.maxRequests = 5; + + let errorCaught = false; + let errorMessage: string; + + let imgSource: imageSource.ImageSource; + const url = "https://github.com/NativeScript-NoImage.png"; + // Try to read the image from the cache + const image = cache.get(url); + if (image) { + // If present -- use it. + imgSource = imageSource.fromNativeSource(image); + } + else { + // If not present -- request its download. + cache.push({ + key: url, + url: url, + completed: (image: any, key: string) => { + if (url === key) { + imgSource = imageSource.fromNativeSource(image); + } + }, + error: (key: string) => { + console.log("No image for key: ", key); + errorMessage = `No image for key: ${key}`; + errorCaught = true; + } + }); + } + + TKUnit.waitUntilReady(() => errorCaught); + TKUnit.assertEqual(`No image for key: ${url}`, errorMessage); } diff --git a/tns-core-modules/ui/image-cache/image-cache.ios.ts b/tns-core-modules/ui/image-cache/image-cache.ios.ts index f82391381..595cc0657 100644 --- a/tns-core-modules/ui/image-cache/image-cache.ios.ts +++ b/tns-core-modules/ui/image-cache/image-cache.ios.ts @@ -72,7 +72,11 @@ export class Cache extends common.Cache { .then((response) => { try { const image = UIImage.alloc().initWithData(response.content.raw); - this._onDownloadCompleted(request.key, image); + if (image) { + this._onDownloadCompleted(request.key, image); + } else { + this._onDownloadError(request.key, new Error("No result for provided url")); + } } catch (err) { this._onDownloadError(request.key, err); } From 2a023609f5fc515589bd50d00c9fb9b9cd763083 Mon Sep 17 00:00:00 2001 From: Yurii Cherniavskyi Date: Wed, 8 May 2019 08:51:40 +0300 Subject: [PATCH 10/10] fix(android/button): possible incorrect button visual state (#7190) --- tns-core-modules/ui/button/button.android.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tns-core-modules/ui/button/button.android.ts b/tns-core-modules/ui/button/button.android.ts index ef9e8bbcc..66db08e2d 100644 --- a/tns-core-modules/ui/button/button.android.ts +++ b/tns-core-modules/ui/button/button.android.ts @@ -91,6 +91,7 @@ export class Button extends ButtonBase { this._highlightedHandler = this._highlightedHandler || ((args: TouchGestureEventData) => { switch (args.action) { case TouchAction.up: + case TouchAction.cancel: this._goToVisualState("normal"); break; case TouchAction.down: