diff --git a/.travis.yml b/.travis.yml index 39d22ec..65363f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,23 @@ +env: + global: + - ANDROID_PACKAGE_JS='datetimepicker-debug-js.apk' + - ANDROID_PACKAGE_NG='datetimepicker-debug-ng.apk' + - ANDROID_PACKAGE_VUE='datetimepicker-debug-vue.apk' + - ANDROID_PACKAGE_FOLDER_JS=$TRAVIS_BUILD_DIR/demo/outputs + - ANDROID_PACKAGE_FOLDER_NG=$TRAVIS_BUILD_DIR/demo-angular/outputs + - ANDROID_PACKAGE_FOLDER_VUE=$TRAVIS_BUILD_DIR/demo-vue/outputs + - ANDROID_SAUCE_STORAGE="https://saucelabs.com/rest/v1/storage/$SAUCE_USER" + - IOS_PACKAGE_JS='datetimepicker-demo-js.zip' + - IOS_PACKAGE_NG='datetimepicker-demo-ng.zip' + - IOS_PACKAGE_VUE='datetimepicker-demo-vue.zip' + - IOS_PACKAGE_FOLDER_JS=$TRAVIS_BUILD_DIR/demo/outputs + - IOS_PACKAGE_FOLDER_NG=$TRAVIS_BUILD_DIR/demo-angular/outputs + - IOS_PACKAGE_FOLDER_VUE=$TRAVIS_BUILD_DIR/demo-vue/outputs + - IOS_SAUCE_STORAGE="https://saucelabs.com/rest/v1/storage/$SAUCE_USER" + +git: + depth: 1 + branches: only: - master @@ -12,56 +32,152 @@ matrix: - cd ../demo && npm run ci.tslint - cd ../demo-angular && npm run ci.tslint - - stage: "build demos" + - stage: "WebPack and Build" + os: osx + env: + - WebpackiOS="12.0" + - Type="VanillaJS" + osx_image: xcode10.0 + language: node_js + node_js: "8" + jdk: oraclejdk8 + before_script: pod repo update + script: + - cd src && npm run build + - cd ../demo && npm i && tns build ios --bundle --env.uglify --copy-to "./outputs/demo.app" + - cd $IOS_PACKAGE_FOLDER_JS && zip -r $IOS_PACKAGE_JS demo.app + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $IOS_SAUCE_STORAGE/$IOS_PACKAGE_JS?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_JS/$IOS_PACKAGE_JS" + - os: osx + env: + - WebpackiOS="12.0" + - Type="VueJS" + osx_image: xcode10.0 + language: node_js + node_js: "8" + jdk: oraclejdk8 + before_script: pod repo update + script: + - cd src && npm run build + - cd ../demo-vue && npm i && tns build ios --bundle --env.uglify --copy-to "./outputs/demovue.app" + - cd $IOS_PACKAGE_FOLDER_VUE && zip -r $IOS_PACKAGE_VUE demovue.app + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $IOS_SAUCE_STORAGE/$IOS_PACKAGE_VUE?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_VUE/$IOS_PACKAGE_VUE" + - os: osx + env: + - WebpackiOS="12.0" + - Type="Angular" + osx_image: xcode10.0 + language: node_js + node_js: "8" + jdk: oraclejdk8 + before_script: pod repo update + script: + - cd src && npm run build && npm pack + - cd ../demo-angular && tns plugin add ../src/*.tgz + - npm i && tns build ios --bundle --env.uglify --env.aot --copy-to "./outputs/demoangular.app" + - cd $IOS_PACKAGE_FOLDER_NG && zip -r $IOS_PACKAGE_NG demoangular.app + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $IOS_SAUCE_STORAGE/$IOS_PACKAGE_NG?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_NG/$IOS_PACKAGE_NG" + - language: android + os: linux + env: + - WebpackAndroid="28" + - Type="VanillaJS" + jdk: oraclejdk8 + before_install: nvm install 8 + script: + - cd src && npm run build + - cd ../demo && npm i && tns build android --bundle --env.uglify --env.snapshot --copy-to "./outputs/app-debug.apk" + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE/$ANDROID_PACKAGE_JS?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_JS/app-debug.apk" + - language: android os: linux - env: + env: + - WebpackAndroid="28" + - Type="VueJS" + jdk: oraclejdk8 + before_install: nvm install 8 + script: + - cd src && npm run build + - cd ../demo-vue && npm i && tns build android --bundle --env.uglify --copy-to "./outputs/app-debug.apk" + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE/$ANDROID_PACKAGE_VUE?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_VUE/app-debug.apk" + - language: android + os: linux + env: + - WebpackAndroid="28" + - Type="Angular" + jdk: oraclejdk8 + before_install: nvm install 8 + script: + - cd src && npm run build + - cd ../publish && sh pack.sh + - cd ../demo-angular && tns plugin add ../publish/package/*.tgz + - npm i && tns build android --bundle --env.uglify --env.snapshot --env.aot --copy-to "./outputs/app-debug.apk" + - "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE/$ANDROID_PACKAGE_NG?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_NG/app-debug.apk" + - language: android + env: - BuildAndroid="28" - language: android + - Type="VanillaJS" + os: linux jdk: oraclejdk8 before_install: nvm install 8.11.4 - script: + script: - cd src && npm run build - cd ../demo && tns build android + - language: android + env: + - BuildAndroid="28" + - Type="Angular" + os: linux + jdk: oraclejdk8 + before_install: nvm install 8.11.4 + script: + - cd src && npm run build - cd ../demo-angular && tns build android - - os: osx - env: + env: - BuildiOS="12.0" - Xcode="10.0" + - Type="VanillaJS" osx_image: xcode10.0 - language: node_js + language: node_js node_js: "8" jdk: oraclejdk8 - script: - - cd src && npm run build - - cd ../demo && tns build ios - - cd ../demo-angular && tns build ios - - - stage: "build demos with webpack" - os: linux - language: android - env: - - Webpack="Android" - jdk: oraclejdk8 - before_install: nvm install 8.11.4 - script: + before_script: pod repo update + script: - cd src && npm run build - - cd ../demo && tns build android --bundle --env.uglify --env.snapshot --env.aot - - cd ../demo-angular && tns build android --bundle --env.uglify --env.snapshot --env.aot - - cd ../demo-vue && tns build android --bundle --env.uglify --env.snapshot --env.aot - + - cd ../demo && tns build ios --bundle --env.uglify - os: osx env: - - Webpack="iOS" + - BuildiOS="12.0" + - Xcode="10.0" + - Type="Angular" osx_image: xcode10.0 - language: node_js + language: node_js node_js: "8" jdk: oraclejdk8 - script: + before_script: pod repo update + script: - cd src && npm run build - - cd ../demo && tns build ios --bundle --env.uglify --env.aot - - cd ../demo-angular && tns build ios --bundle --env.uglify --env.aot - - cd ../demo-vue && tns build ios --bundle --env.uglify --env.aot + - cd ../demo-angular && tns build ios + - stage: "UI Tests" + env: + - Android="24" + - Type="Angular" + language: node_js + os: linux + node_js: "8" + script: + - npm i -g appium + - cd demo-angular && npm i + - travis_wait travis_retry npm run e2e -- --runType android24 --sauceLab --appPath $ANDROID_PACKAGE_NG + - os: linux + env: + - iOS="12.0" + - Type="Angular" + language: node_js + node_js: "8" + script: + - npm i -g appium + - cd demo-angular && npm i + - travis_wait travis_retry npm run e2e -- --runType sim.iPhoneX --sauceLab --appPath $IOS_PACKAGE_NG android: components: diff --git a/demo-angular/e2e/config/appium.capabilities.json b/demo-angular/e2e/config/appium.capabilities.json new file mode 100644 index 0000000..b8c1f53 --- /dev/null +++ b/demo-angular/e2e/config/appium.capabilities.json @@ -0,0 +1,129 @@ +{ + "android19": { + "platformName": "Android", + "platformVersion": "4.4", + "deviceName": "Emulator-Api19-Default", + "avd": "Emulator-Api19-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android21": { + "platformName": "Android", + "platformVersion": "5.0", + "deviceName": "Emulator-Api21-Default", + "avd": "Emulator-Api21-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android23": { + "platformName": "Android", + "platformVersion": "6.0", + "deviceName": "Emulator-Api23-Default", + "avd": "Emulator-Api23-Default", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android24": { + "platformName": "Android", + "platformVersion": "7.0", + "deviceName": "Android GoogleAPI Emulator", + "lt": 60000, + "newCommandTimeout": 720, + "appium-version": "1.9.1", + "noReset": true, + "fullReset": false, + "app": "", + "idleTimeout": 120, + "automationName": "Appium" + }, + "android25": { + "platformName": "Android", + "platformVersion": "7.1", + "deviceName": "Emulator-Api25-Google", + "avd": "Emulator-Api25-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android26": { + "platformName": "Android", + "platformVersion": "8.0", + "deviceName": "Emulator-Api26-Google", + "avd": "Emulator-Api26-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android27": { + "platformName": "Android", + "platformVersion": "27", + "deviceName": "Emulator-Api27-Google", + "avd": "Emulator-Api27-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "android28": { + "platformName": "Android", + "platformVersion": "28", + "deviceName": "Emulator-Api28-Google", + "avd": "Emulator-Api28-Google", + "lt": 60000, + "newCommandTimeout": 720, + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhone7": { + "platformName": "iOS", + "platformVersion": "/12.*/", + "deviceName": "iPhone 7", + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhone8": { + "platformName": "iOS", + "platformVersion": "/12*/", + "deviceName": "iPhone 8", + "noReset": false, + "fullReset": false, + "app": "" + }, + "sim.iPhoneX": { + "platformName": "iOS", + "platformVersion": "12.0", + "deviceName": "iPhone X", + "appium-version": "1.9.1", + "app": "", + "noReset": true, + "fullReset": false, + "density": 3, + "offsetPixels": 87, + "idleTimeout": 120, + "automationName": "Appium" + }, + "sim.iPhoneXS": { + "platformName": "ios", + "platformVersion": "/12*/", + "deviceName": "iPhone XS", + "noReset": false, + "fullReset": false, + "app": "" + } +} \ No newline at end of file diff --git a/demo-angular/e2e/config/mocha.opts b/demo-angular/e2e/config/mocha.opts new file mode 100644 index 0000000..0642626 --- /dev/null +++ b/demo-angular/e2e/config/mocha.opts @@ -0,0 +1,5 @@ +--timeout 999999 +--recursive e2e +--reporter mocha-multi +--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml +--exit \ No newline at end of file diff --git a/demo-angular/e2e/helper.ts b/demo-angular/e2e/helper.ts new file mode 100644 index 0000000..9f31734 --- /dev/null +++ b/demo-angular/e2e/helper.ts @@ -0,0 +1,58 @@ +import { AppiumDriver, SearchOptions,createDriver, Direction, UIElement } from "nativescript-dev-appium"; +import { runType } from "nativescript-dev-appium/lib/parser"; + +const optionsText = "Options"; +const moreOptionsID = "More options"; +let driver: AppiumDriver; + + export async function getPickerTime(driver: AppiumDriver, format: number) { + let selector = driver.isAndroid ? "android.widget.EditText" : "XCUIElementTypePickerWheel"; + const pickerWheels = await driver.findElementsByClassName(selector); + let hourWheel = await (await pickerWheels[0]).text(); + let minutesWheel = await (await pickerWheels[1]).text(); + if(!driver.isAndroid){ + hourWheel = hourWheel.slice(0, hourWheel.indexOf(" ")); + minutesWheel = minutesWheel.slice(0, minutesWheel.indexOf(" ")); + } + let timeString = hourWheel + ":" + minutesWheel; + if(format == 12){ + const amPmWheel = await (await pickerWheels[2]).text(); + timeString += " " + amPmWheel; + } + return timeString; +} + +export async function getPickerDate(driver: AppiumDriver) { + let selector = driver.isAndroid ? "android.widget.EditText" : "XCUIElementTypePickerWheel"; + const pickerWheels = await driver.findElementsByClassName(selector); + let monthWheel = await (await pickerWheels[0]).text() + let month = monthWheel.toString().substring(0, 3); + let dayWheel = await (await pickerWheels[1]).text(); + if(parseInt(dayWheel) < 10 && driver.isAndroid){ + dayWheel = dayWheel.substring(1,2); + } + const yearWheel = await (await pickerWheels[2]).text(); + const dateString = month + " " + dayWheel + ", " + yearWheel; + return dateString; +} + +export async function clickOkBtn(driver: AppiumDriver){ + const okBtn = await driver.findElementByText("OK", SearchOptions.exact); + await okBtn.click(); +} + +export async function scrollToElement(driver: AppiumDriver, element: string, direction: Direction = Direction.down) { + let listView: UIElement; + if (driver.isAndroid) { + listView = await driver.findElementByClassName("android.widget.FrameLayout"); + } + else { + listView = await driver.findElementByClassName("XCUIElementTypeApplication"); + } + const listItem = await listView.scrollTo( + direction, + () => driver.findElementByText(element, SearchOptions.contains), + 600 + ); + return listItem; +} diff --git a/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssDatePicker.png b/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssDatePicker.png new file mode 100644 index 0000000..eec1d1e Binary files /dev/null and b/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssDatePicker.png differ diff --git a/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssTimePicker.png b/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssTimePicker.png new file mode 100644 index 0000000..eaebbec Binary files /dev/null and b/demo-angular/e2e/resources/images/datetimepicker-ng-android/Android GoogleAPI Emulator/cssTimePicker.png differ diff --git a/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssDatePicker.png b/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssDatePicker.png new file mode 100644 index 0000000..3a5c87f Binary files /dev/null and b/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssDatePicker.png differ diff --git a/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssTimePicker.png b/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssTimePicker.png new file mode 100644 index 0000000..8eba30d Binary files /dev/null and b/demo-angular/e2e/resources/images/datetimepicker-ng-ios/iPhone X/cssTimePicker.png differ diff --git a/demo-angular/e2e/setup.ts b/demo-angular/e2e/setup.ts new file mode 100644 index 0000000..8b26e66 --- /dev/null +++ b/demo-angular/e2e/setup.ts @@ -0,0 +1,9 @@ +import { startServer, stopServer } from "nativescript-dev-appium"; + +before("start server", async () => { + await startServer(); +}); + +after("stop server", async () => { + await stopServer(); +}); diff --git a/demo-angular/e2e/tests.e2e.ts b/demo-angular/e2e/tests.e2e.ts new file mode 100644 index 0000000..f1c7480 --- /dev/null +++ b/demo-angular/e2e/tests.e2e.ts @@ -0,0 +1,290 @@ +import { AppiumDriver, createDriver, SearchOptions, Direction } from "nativescript-dev-appium"; +import { isSauceLab, runType } from "nativescript-dev-appium/lib/parser"; +import { expect } from "chai"; +import { ok } from "assert"; +import { getPickerTime, clickOkBtn, scrollToElement, getPickerDate } from "./helper"; +const fs = require('fs'); +const addContext = require('mochawesome/addContext'); +const rimraf = require('rimraf'); +const isSauceRun = isSauceLab; + +const deMonths = { + "Jan":"01", + "Feb":"02", + "Mär": "03", + "Apr": "04", + "Mai":"05", + "Jun":"06", + "Jul":"07", + "Aug":"08", + "Sep":"09", + "Okt":"10", + "Nov":"11", + "Dez":"12" +} + +describe("DateTimePicker", () => { + const defaultWaitTime = 5000; + let driver: AppiumDriver; + + before(async () => { + driver = await createDriver(); + driver.defaultWaitTime = 15000; + let dir = "mochawesome-report"; + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } + rimraf('mochawesome-report/*', function () { }); + }); + + after(async () => { + if (isSauceRun) { + driver.sessionId().then(function (sessionId) { + console.log("Report https://saucelabs.com/beta/tests/" + sessionId); + }); + } + await driver.quit(); + console.log("Quit driver!"); + }); + + afterEach(async function () { + if (this.currentTest.state && this.currentTest.state === "failed") { + let png = await driver.logScreenshot(this.currentTest.title); + fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) { + if (err) { + throw err; + } + console.log('Screenshot saved.'); + }); + addContext(this, './' + this.currentTest.title + '.png'); + } + }); + + it("Should verify demo title", async () => { + const title = await driver.findElementByText("DateTimePicker Demo NG", SearchOptions.exact); + expect(title).to.exist; + }); + + it("Should select date and verify value of picker field", async () => { + const selectDateField = await driver.findElementByText("select date", SearchOptions.contains); + await selectDateField.click(); + const date = await getPickerDate(driver); + await clickOkBtn(driver); + const dateSelected = await driver.findElementByText(date); + expect(dateSelected).to.exist; + }); + + it("Should select time and verify value of picker field", async () => { + const selectTimeField = await driver.findElementByText("select time", SearchOptions.contains); + await selectTimeField.click(); + const timeString = await getPickerTime(driver, 12); + await clickOkBtn(driver); + const timeSelected = await driver.findElementByText(timeString, SearchOptions.contains); + expect(timeSelected).to.exist; + }); + + it("Should select date from min/max limited field", async () => { + const minMaxDatePicker = await driver.findElementByText("tap to select", SearchOptions.contains); + await minMaxDatePicker.click(); + const date = await getPickerDate(driver); + await clickOkBtn(driver); + console.log(date); + const dateSelected = await driver.findElementByText(date); + expect(dateSelected).to.exist; + }); + + it("Should open 12h time format and verify wheelers values", async () => { + const twelveHourFormat = await driver.findElementByText("4:00 PM", SearchOptions.contains); + await twelveHourFormat.click(); + const timeString = await getPickerTime(driver, 12); + await clickOkBtn(driver); + expect(timeString).to.equal("4:00 PM"); + }); + + it("Should open 24h format and verify wheeler value", async () => { + const twentyFourFormat = await scrollToElement(driver, "16:00", Direction.down); + await twentyFourFormat.click(); + const timeString = await getPickerTime(driver, 24); + await clickOkBtn(driver); + expect(timeString).to.equal("16:00"); + }); + + it("Should verify modified texts field for date picker", async () => { + await scrollToElement(driver, "preferred locale: en_US", Direction.down); + const pickers = await driver.findElementsByText("tap to choose"); + const datePicker = pickers[0]; + await datePicker.click(); + const date = await getPickerDate(driver); + const approveBtn = await driver.findElementByText("Approve", SearchOptions.contains); + const rejectBtn = await driver.findElementByText("Reject", SearchOptions.contains); + const title = await driver.findElementByText("Confirm predefined date selection", SearchOptions.contains); + expect(approveBtn).to.exist; + expect(rejectBtn).to.exist; + expect(title).to.exist; + await approveBtn.click(); + const dateString = await driver.findElementByText(date); + expect(dateString).to.exist; + }); + + it("Should verify modified texts field for time picker", async () => { + const datePicker = await driver.findElementByText("tap to choose"); + await datePicker.click(); + const time = await getPickerTime(driver, 12); + const approveBtn = await driver.findElementByText("Approve", SearchOptions.contains); + const rejectBtn = await driver.findElementByText("Reject", SearchOptions.contains); + const title = await driver.findElementByText("Confirm predefined time selection", SearchOptions.contains); + expect(approveBtn).to.exist; + expect(rejectBtn).to.exist; + expect(title).to.exist; + await approveBtn.click(); + const dateString = await driver.findElementByText(time); + expect(dateString).to.exist; + }); + + it("Should select date from de_De locale picker and verify format", async () => { + await scrollToElement(driver, "zeit wählen", Direction.down); + const deLocale = await driver.findElementByText("preferred locale: de_DE"); + expect(deLocale).to.exist; + const datePicker = await driver.findElementByText("datum auswählen", SearchOptions.contains); + await datePicker.click(); + const date = await getPickerDate(driver); + let selector = driver.isAndroid ? "android.widget.Button" : "Bestätigen"; + let acceptBtn; + let rejectBtn; + if(driver.isAndroid){ + let buttons = await driver.findElementsByClassName(selector); + acceptBtn = buttons[7]; + rejectBtn = buttons[6]; + } + else{ + acceptBtn = await driver.findElementByText(selector, SearchOptions.contains); + rejectBtn = await driver.findElementByText("Stornieren", SearchOptions.exact); + } + const title = await driver.findElementByText("Datum auswählen", SearchOptions.exact); + expect(acceptBtn).to.exist; + expect(rejectBtn).to.exist; + expect(title).to.exist; + await acceptBtn.click(); + let index = driver.isAndroid ? " " : "." + let day = date.substring(0, date.indexOf(index)); + let month = date.substring(date.indexOf(" ") + 1, date.indexOf(",")); + month = month.substring(0, 3); + let monthString = deMonths[month]; + let year = date.substring(date.lastIndexOf(" ") + 1, date.length); + const dateString = day + "." + monthString + "." + year; + console.log(dateString); + const dateField = await driver.findElementByText(dateString); + expect(dateString).to.exist; + }); + + it("Should select time from de_DE locale picker and verify format", async () => { + const timePicker = await driver.findElementByText("zeit wählen", SearchOptions.contains); + await timePicker.click(); + const time = await getPickerTime(driver, 24); + let acceptBtn; + let rejectBtn; + if(driver.isAndroid){ + let buttons = await driver.findElementsByClassName("android.widget.Button"); + acceptBtn = buttons[5]; + rejectBtn = buttons[4]; + } + else{ + acceptBtn = await driver.findElementByText("Bestätigen", SearchOptions.exact); + rejectBtn = await driver.findElementByText("Stornieren", SearchOptions.exact); + } + const title = await driver.findElementByText("Zeit wählen", SearchOptions.exact); + expect(acceptBtn).to.exist; + expect(rejectBtn).to.exist; + expect(title).to.exist; + await acceptBtn.click(); + const dateField = await driver.findElementByText(time); + expect(time).to.exist; + }); + + it("Should scroll to custom format and verify values", async () => { + await scrollToElement(driver, "binding", Direction.down); + const customFromatLabel = await driver.findElementByText("custom format"); + expect(customFromatLabel).to.exist; + const customFormatDate = await driver.findElementByText("date: 24 February 2019", SearchOptions.exact); + expect(customFormatDate).to.exist; + const customFormatTime = await driver.findElementByText("time: 01:00", SearchOptions.exact); + expect(customFormatTime).to.exist; + }); + + it("Should scroll to binding example and verify picker and label values", async () => { + await scrollToElement(driver, "css applied", Direction.down); + const bindingLabel = await driver.findElementByText("binding", SearchOptions.exact); + expect(bindingLabel).to.exist; + let selector = driver.isAndroid ? "android.widget.EditText" : "XCUIElementTypeTextField" + let fields = await driver.findElementsByClassName(selector); + let timeField; + let dateField; + if(driver.isAndroid){ + timeField = fields[2]; + dateField = fields[1]; + } + else{ + let index = fields.length - 3; + console.log("index: " + index); + timeField = fields[index]; + dateField = fields[index - 1]; + } + await dateField.click(); + let date = await getPickerDate(driver); + await clickOkBtn(driver); + let dateTime = new Date(date); + let year = dateTime.getFullYear().toString(); + let dateLabel = dateTime.toString().substring(0, dateTime.toString().indexOf(year) + 4); + console.log(dateLabel); + let bindingDate = await driver.findElementByText(dateLabel, SearchOptions.contains); + }); + + it("Should scroll to css styled DatePicker and verify picker style", async () => { + await scrollToElement(driver, "tap to select time", Direction.down); + let cssPickers = await driver.findElementsByText("Feb 24, 2019", SearchOptions.exact); + await cssPickers[cssPickers.length - 1].click(); + await getPickerDate(driver); + await driver.compareScreen("cssDatePicker"); + await clickOkBtn(driver); + }); + + it("Should scroll to css styled TimePicker and verify picker style", async () => { + const cssPickers = await driver.findElementsByText("1:00 AM", SearchOptions.exact); + await cssPickers[cssPickers.length - 1].click(); + await getPickerTime(driver, 12); + await driver.compareScreen("cssTimePicker"); + await clickOkBtn(driver); + }); + + it("Should tap button to select date and verify button text", async () => { + let dateButton = await driver.findElementByText("tap to select date", SearchOptions.contains); + await dateButton.click(); + const date = await getPickerDate(driver); + await clickOkBtn(driver); + const pickerDate = new Date(date); + let day = pickerDate.getDate(); + let dayString = day.toString(); + if(day < 10){ + dayString = "0" + day.toString(); + } + let month = pickerDate.getMonth() + 1; + let monthString = month.toString(); + if(month < 10){ + monthString = "0" + month.toString(); + } + let year = pickerDate.getFullYear(); + const dateString = dayString + "." + monthString+ "." + year; + console.log(dateString); + const dateField = await driver.findElementByText(dateString); + expect(dateString).to.exist; + }) + + it("Should tap button to select time and verify button text", async () => { + let timeButton = await driver.findElementByText("tap to select time", SearchOptions.contains); + await timeButton.click(); + const time = await getPickerTime(driver, 24); + await clickOkBtn(driver); + timeButton = await driver.findElementByText(time); + expect(timeButton).to.exist; + }); +}); \ No newline at end of file diff --git a/demo-angular/e2e/tsconfig.json b/demo-angular/e2e/tsconfig.json new file mode 100644 index 0000000..4aa39f6 --- /dev/null +++ b/demo-angular/e2e/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "importHelpers": false, + "sourceMap": true, + "types": [ + "mocha", + "chai" + ], + "lib": [ + "es2015", + "dom" + ], + "baseUrl": "." + } +} \ No newline at end of file diff --git a/demo-angular/package.json b/demo-angular/package.json index 2b2cded..3a7dfde 100644 --- a/demo-angular/package.json +++ b/demo-angular/package.json @@ -13,7 +13,9 @@ "repository": "https://github.com/NativeScript/nativescript-datetimepicker", "scripts": { "ci.tslint": "npm i && tslint --config '../tslint.json' 'src/**/*.ts'", - "build.plugin": "cd ../src && npm run build" + "build.plugin": "cd ../src && npm run build", + "e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js && tsc -p e2e && mocha --opts ./e2e/config/mocha.opts ", + "e2e-watch": "tsc -p e2e --watch" }, "dependencies": { "@angular/animations": "~7.2.0", @@ -39,6 +41,14 @@ "nativescript-dev-webpack": "~0.20.0", "@angular/compiler-cli": "~7.2.0", "@ngtools/webpack": "~7.2.0", + "@types/chai": "~4.1.7", + "@types/mocha": "~5.2.5", + "@types/node": "~10.12.18", + "mocha": "~5.2.0", + "mocha-junit-reporter": "~1.18.0", + "mocha-multi": "~1.0.1", + "mochawesome": "~3.1.1", + "nativescript-dev-appium": "~5.0.0", "tslint": "~5.11.0" }, "readme": "NativeScript DateTimePicker Demo NG" diff --git a/demo-angular/src/app/home/home.component.html b/demo-angular/src/app/home/home.component.html index 176dbfc..a2f8da3 100644 --- a/demo-angular/src/app/home/home.component.html +++ b/demo-angular/src/app/home/home.component.html @@ -44,7 +44,7 @@ + timeFormat="HH:mm" pickerCancelText="Stornieren" pickerTitle="Zeit wählen"> diff --git a/demo-vue/tsconfig.json b/demo-vue/tsconfig.json index 398b5b4..f7c65d6 100644 --- a/demo-vue/tsconfig.json +++ b/demo-vue/tsconfig.json @@ -21,7 +21,9 @@ ] } }, - "include": [ "index.ts" ], + "include": [ + "index.ts" + ], "exclude": [ "node_modules", "platforms"