Merge pull request #7698 from NativeScript/vsetoslavtsenov/merge-release-in-master

chore: merge release in master
This commit is contained in:
Svetoslav
2019-08-20 11:18:32 +03:00
committed by GitHub
20 changed files with 188 additions and 58 deletions

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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"];
@@ -15,7 +16,7 @@ describe(rootType, async function () {
nsCapabilities.testReporter.context = this;
logWarn(`====== ${rootType} ========`);
driver = await createDriver();
screen = new Screen(driver);
screen = new TabNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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"];
@@ -11,11 +12,11 @@ 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);
screen = new TabNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}
@@ -23,7 +24,7 @@ describe(rootType, async function () {
driver.defaultWaitTime = driverDefaultWaitTime;
});
after(async () => {
after(async function () {
if (dontKeepActivities) {
await driver.setDontKeepActivities(false);
}
@@ -63,20 +64,20 @@ describe(rootType, async function () {
}
});
it("loaded home page", async () => {
it("loaded home page", async function () {
await screen.loadedHome();
});
it(`loaded frame ${root} root with nested frames`, async () => {
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 () => {
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) {
@@ -95,7 +96,7 @@ describe(rootType, async function () {
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) {
@@ -112,7 +113,7 @@ describe(rootType, async function () {
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) {
@@ -139,7 +140,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("toggle teams tab", async () => {
it("toggle teams tab", async function () {
await screen.toggleTeamsTab();
if (appSuspendResume) {
@@ -148,11 +149,11 @@ describe(rootType, async function () {
}
});
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) {
@@ -253,7 +254,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("loaded home page again", async () => {
it("loaded home page again", async function () {
await screen[`goBackFrom${root}Page`]();
await screen.loadedHome();
});

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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";
const rootType = "frame-root";
describe(rootType, async function () {
@@ -12,7 +13,7 @@ describe(rootType, async function () {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
screen = new TabNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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";
// NOTE: TabViewTop is Android only scenario (for iOS we will essentially execute 2x TabViewBottom)
const roots = ["TabViewTop", "TabViewBottom"];
@@ -12,11 +13,12 @@ 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);
await driver.restartApp();
screen = new TabViewNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}
@@ -24,7 +26,7 @@ describe(rootType, async function () {
driver.defaultWaitTime = driverDefaultWaitTime;
});
after(async () => {
after(async function () {
if (dontKeepActivities) {
await driver.setDontKeepActivities(false);
}
@@ -64,20 +66,20 @@ describe(rootType, async function () {
}
});
it("loaded home page", async () => {
it("loaded home page", async function () {
await screen.loadedHome();
});
it(`loaded frame ${root} root with nested frames`, async () => {
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 () => {
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) {
@@ -96,7 +98,7 @@ describe(rootType, async function () {
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) {
@@ -113,7 +115,7 @@ describe(rootType, async function () {
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) {
@@ -140,7 +142,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("toggle teams tab", async () => {
it("toggle teams tab", async function () {
await screen.toggleTeamsTab();
if (appSuspendResume) {
@@ -149,11 +151,11 @@ describe(rootType, async function () {
}
});
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) {
@@ -254,7 +256,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("loaded home page again", async () => {
it("loaded home page again", async function () {
await screen[`goBackFrom${root}Page`]();
await screen.loadedHome();
});

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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 = ["TabsTop", "TabsBottom"];
@@ -11,11 +12,11 @@ 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);
screen = new TabNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}
@@ -23,7 +24,7 @@ describe(rootType, async function () {
driver.defaultWaitTime = driverDefaultWaitTime;
});
after(async () => {
after(async function () {
if (dontKeepActivities) {
await driver.setDontKeepActivities(false);
}
@@ -63,20 +64,20 @@ describe(rootType, async function () {
}
});
it("loaded home page", async () => {
it("loaded home page", async function () {
await screen.loadedHome();
});
it(`loaded frame ${root} root with nested frames`, async () => {
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 () => {
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) {
@@ -95,7 +96,7 @@ describe(rootType, async function () {
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) {
@@ -112,7 +113,7 @@ describe(rootType, async function () {
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) {
@@ -139,7 +140,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("toggle teams tab", async () => {
it("toggle teams tab", async function () {
await screen.toggleTeamsTab();
if (appSuspendResume) {
@@ -148,11 +149,11 @@ describe(rootType, async function () {
}
});
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) {
@@ -253,7 +254,7 @@ describe(rootType, async function () {
await screen.loadedPlayersList();
});
it("loaded home page again", async () => {
it("loaded home page again", async function () {
await screen[`goBackFrom${root}Page`]();
await screen.loadedHome();
});

View File

@@ -1,6 +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";
describe("issues", async function () {
let driver: AppiumDriver;
@@ -9,7 +10,7 @@ describe("issues", async function () {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
screen = new TabViewNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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";
const rootType = "layout-root";
describe(rootType, async function () {
@@ -12,7 +13,7 @@ describe(rootType, async function () {
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
screen = new Screen(driver);
screen = new TabNavigationScreen(driver);
logWarn("====== layout-root ========");
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);

View File

@@ -39,10 +39,6 @@ const navigateToOtherPageDefault = "navigate to other page (default transition)"
const navigateToOtherPageNone = "navigate to other page (no transition)";
const navigateToOtherPageSlide = "navigate to other page (slide transition)";
const navigateToOtherPageFlip = "navigate to other page (flip transition)";
const players = "Players";
const teams = "Teams";
const playersTab = "playersTabNavigation";
const teamsTab = "teamsTabNavigation";
const dummyTab = "dummyTabNavigation";
const playerBack = "playerBack";
const stillOtherPageBack = "stillOtherPageBack";
@@ -153,9 +149,14 @@ export interface Item {
description: string;
}
export class Screen {
export abstract class Screen {
private _driver: AppiumDriver;
protected _driver: AppiumDriver;
protected abstract players;
protected abstract teams;
protected abstract playersTab;
protected abstract teamsTab;
public currentAnimation: string;
@@ -319,14 +320,14 @@ export class Screen {
}
togglePlayersTab = async () => {
const lblPlayers = await this._driver.waitForElement(playersTab);
logInfo(`====== Navigate to "${players}"`);
const lblPlayers = await this._driver.waitForElement(this.playersTab);
logInfo(`====== Navigate to "${this.players}"`);
await lblPlayers.tap();
}
toggleTeamsTab = async () => {
const lblTeams = await this._driver.waitForElement(teamsTab);
logInfo(`====== Navigate to "${teams}"`);
const lblTeams = await this._driver.waitForElement(this.teamsTab);
logInfo(`====== Navigate to "${this.teams}"`);
await lblTeams.tap();
}
@@ -392,7 +393,7 @@ export class Screen {
loadedBottomNavigationRootWithFrames = async () => {
await this.loadedPage(bottomNavigationRootHome);
}
loadedStillOtherPage = async () => {
await this.loadedPage(stillOtherPage);
}
@@ -408,7 +409,7 @@ export class Screen {
loadedPlayersList = async () => {
const lblPlayerOne = await this._driver.waitForElement(playersData["playerOneDefault"].name);
assert.isDefined(lblPlayerOne);
console.log(players + " loaded!");
console.log(this.players + " loaded!");
}
loadedPlayerDetails = async (player: Item) => {
@@ -418,7 +419,7 @@ export class Screen {
loadedTeamsList = async () => {
const lblTeamOne = await this._driver.waitForElement(teamsData["teamOneDefault"].name);
assert.isDefined(lblTeamOne);
console.log(teams + " loaded!");
console.log(this.teams + " loaded!");
}
loadedTeamDetails = async (team: Item) => {

View File

@@ -0,0 +1,14 @@
import { AppiumDriver } from "nativescript-dev-appium";
import { Screen } from "./screen";
export class TabNavigationScreen extends Screen {
protected readonly players = "Players";
protected readonly teams = "Teams";
protected readonly playersTab = "playersTabNavigation";
protected readonly teamsTab = "teamsTabNavigation";
constructor(driver: AppiumDriver) {
super(driver);
}
}

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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";
// NOTE: TabViewTop is Android only scenario (for iOS we will essentially execute 2x TabViewBottom)
const roots = ["TabViewTop", "TabViewBottom"];
@@ -16,7 +17,7 @@ describe(rootType, async function () {
nsCapabilities.testReporter.context = this;
logWarn(`====== ${rootType} ========`);
driver = await createDriver();
screen = new Screen(driver);
screen = new TabViewNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}

View File

@@ -3,6 +3,7 @@ import { AppiumDriver, createDriver, logWarn, nsCapabilities } from "nativescrip
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 = ["TabsTop", "TabsBottom"];
@@ -15,7 +16,7 @@ describe(rootType, async function () {
nsCapabilities.testReporter.context = this;
logWarn(`====== ${rootType} ========`);
driver = await createDriver();
screen = new Screen(driver);
screen = new TabNavigationScreen(driver);
if (dontKeepActivities) {
await driver.setDontKeepActivities(true);
}

View File

@@ -0,0 +1,14 @@
import { AppiumDriver } from "nativescript-dev-appium";
import { Screen } from "./screen";
export class TabViewNavigationScreen extends Screen {
protected readonly players = "Players";
protected readonly teams = "Teams";
protected readonly playersTab = "Players";
protected readonly teamsTab = "Teams";
constructor(driver: AppiumDriver) {
super(driver);
}
}

View File

@@ -30,6 +30,8 @@
"scripts": {
"e2e": "npm run clean-e2e && tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json",
"e2e-watch": "tsc -p e2e --watch",
"e2e-debug": "./node_modules/.bin/ns-dev-appium --startSession",
"e2e-tsc": "tsc -p e2e",
"clean-e2e": "rimraf 'e2e/**/*.js' 'e2e/**/*.js.map' 'e2e/**/*.map'"
}
}

View File

View File

View File

@@ -0,0 +1,15 @@
import { View, ShowModalOptions } from "tns-core-modules/ui/core/view";
const LIVESYNC_FOLDER = "livesync/";
const buttonPageModuleName = `${LIVESYNC_FOLDER}livesync-button-page`;
export function onLoaded(args) {
const view = args.object as View;
let options: ShowModalOptions = {
context: "context",
closeCallback: () => console.log("modal view closeCallback raised."),
animated: false
};
view.showModal(buttonPageModuleName, options);
}

View File

@@ -0,0 +1,3 @@
<Page loaded="onLoaded">
</Page>

View File

@@ -30,6 +30,13 @@ const buttonTsPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.ts`;
const buttonScssPageFileName = `${LIVESYNC_FOLDER}livesync-button-page.scss`;
const labelPageModuleName = `${LIVESYNC_FOLDER}livesync-label-page`;
const modalViewPageModuleName = `${LIVESYNC_FOLDER}livesync-modal-view-page`;
const modalViewXmlPageFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.xml`;
const modalViewJsPageFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.js`;
const modalViewTsPageFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.ts`;
const modalViewScssPageFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.scss`;
const modalViewCssFileName = `${LIVESYNC_FOLDER}livesync-modal-view-page.css`;
const green = new Color("green");
export function setUp() {
@@ -111,6 +118,26 @@ export function test_onLiveSync_ModuleContext_MarkupHtml_ScriptTs_StyleScss_File
]);
}
export function test_onLiveSync_ModalViewClosed_MarkupXml() {
_test_onLiveSync_ModalViewClosed({ type: "markup", path: modalViewXmlPageFileName });
}
export function test_onLiveSync_ModalViewClosed_ScriptTs() {
_test_onLiveSync_ModalViewClosed({ type: "script", path: modalViewTsPageFileName });
}
export function test_onLiveSync_ModalViewClosed_ScriptJs() {
_test_onLiveSync_ModalViewClosed({ type: "script", path: modalViewJsPageFileName });
}
export function test_onLiveSync_ModalViewClosed_StyleCss() {
_test_onLiveSync_ModalViewClosed({ type: "style", path: modalViewCssFileName });
}
export function test_onLiveSync_ModalViewClosed_StyleScss() {
_test_onLiveSync_ModalViewClosed({ type: "style", path: modalViewScssPageFileName });
}
function _test_onLiveSync_ModuleContext_AppStyle(appStyleFileName: string, livesyncStyleFileName: string) {
const pageBeforeNavigation = helper.getCurrentPage();
const buttonPage = <Page>createViewFromEntry(({ moduleName: buttonPageModuleName }));
@@ -209,6 +236,18 @@ function _test_onLiveSync_ModuleReplace_Multiple(context: ModuleContext[]) {
TKUnit.assertEqual(pageBeforeNavigation, pageAfterBackNavigation, "Pages are different!");
}
function _test_onLiveSync_ModalViewClosed(context: ModuleContext) {
const modalViewPage = <Page>createViewFromEntry(({ moduleName: modalViewPageModuleName }));
helper.navigateWithHistory(() => modalViewPage);
livesync({ type: context.type, path: context.path });
TKUnit.waitUntilReady(() => !!frame.topmost());
const topmostFrame = frame.topmost();
TKUnit.waitUntilReady(() => topmostFrame.currentPage && topmostFrame.currentPage.isLoaded && topmostFrame.canGoBack());
TKUnit.assertTrue(topmostFrame._getRootModalViews().length === 0);
}
function livesync(context: ModuleContext) {
const ls = (<any>global).__hmrSyncBackup || global.__onLiveSync;
ls(context);

View File

@@ -156,11 +156,31 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
}
public _closeAllModalViewsInternal(): boolean {
if (_rootModalViews && _rootModalViews.length > 0) {
_rootModalViews.forEach(v => {
v.closeModal();
});
return true;
}
return false;
}
public _getRootModalViews(): Array<ViewBase> {
return _rootModalViews;
}
public _onLivesync(context?: ModuleContext): boolean {
if (traceEnabled()) {
traceWrite(`${this}._onLivesync(${JSON.stringify(context)})`, traceCategories.Livesync);
}
if (this._closeAllModalViewsInternal()) {
return true;
}
if (this._handleLivesync(context)) {
return true;
}

View File

@@ -610,6 +610,18 @@ export abstract class View extends ViewBase {
// Lifecycle events
_getNativeViewsCount(): number;
/**
* Internal method:
* Closes all modal views. Should be used by plugins like `nativescript-angular` which implement their own `modal views` service.
*/
_closeAllModalViewsInternal(): boolean;
/**
* Internal method:
* Gets all modal views of the current view.
*/
_getRootModalViews(): Array<ViewBase>
_eachLayoutView(callback: (View) => void): void;
/**