diff --git a/.travis.yml b/.travis.yml index 34e115c..e068e72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,28 +6,52 @@ os: node_js: - "8" - - "6" - "4" env: - TEST="eslint-non-3rd-party" TYPE="unit" - - TEST="browserstack-tunnel" TYPE="unit" + - TEST="core-scriptjob" TYPE="unit" + - TEST="core-integration-tests" TYPE="integration" + - TEST="core-functional-tests" TYPE="functional" - TEST="saucelabs-tunnel" TYPE="unit" + - TEST="browserstack-tunnel" TYPE="unit" - TEST="crossbrowsertesting-tunnel" TYPE="unit" - - TEST="core-scriptjob" TYPE="unit" - - TEST="browserstack-scriptjob" TYPE="unit" - TEST="saucelabs-scriptjob" TYPE="unit" + - TEST="browserstack-scriptjob" TYPE="unit" - TEST="crossbrowsertesting-scriptjob" TYPE="unit" - - TEST="browserstack-job" TYPE="unit" - TEST="saucelabs-job" TYPE="unit" + - TEST="browserstack-job" TYPE="unit" - TEST="crossbrowsertesting-job" TYPE="unit" - - TEST="browserstack-platform" TYPE="unit" - - TEST="saucelabs-platform" TYPE="unit" - - TEST="crossbrowsertesting-platform" TYPE="unit" - - TEST="integration-tests" TYPE="integration" - - TEST="utils-tests" TYPE="functional" - - TEST="testem" TYPE="functional" - - TEST="native-runner" TYPE="functional" + - TEST="saucelabs-platform-open" TYPE="unit" + - TEST="browserstack-platform-open" TYPE="unit" + - TEST="crossbrowsertesting-platform-open" TYPE="unit" + - TEST="saucelabs-platform-job" TYPE="unit" + - TEST="browserstack-platform-job" TYPE="unit" + - TEST="crossbrowsertesting-platform-job" TYPE="unit" + - TEST="saucelabs-platform-scriptjob" TYPE="unit" + - TEST="browserstack-platform-scriptjob" TYPE="unit" + - TEST="crossbrowsertesting-platform-scriptjob" TYPE="unit" + - TEST="saucelabs-platform-status" TYPE="unit" + - TEST="browserstack-platform-status" TYPE="unit" + - TEST="crossbrowsertesting-platform-status" TYPE="unit" + - TEST="saucelabs-platform-stop" TYPE="unit" + - TEST="browserstack-platform-stop" TYPE="unit" + - TEST="crossbrowsertesting-platform-stop" TYPE="unit" + - TEST="saucelabs-platform-close" TYPE="unit" + - TEST="browserstack-platform-close" TYPE="unit" + - TEST="crossbrowsertesting-platform-close" TYPE="unit" + - TEST="saucelabs-integration-tests" TYPE="integration" + - TEST="browserstack-integration-tests" TYPE="integration" + - TEST="crossbrowsertesting-integration-tests" TYPE="integration" + - TEST="utils-saucelabs-tests" TYPE="functional" + - TEST="utils-browserstack-tests" TYPE="functional" + - TEST="utils-crossbrowsertesting-tests" TYPE="functional" + - TEST="testem-saucelabs" TYPE="functional" + - TEST="testem-browserstack" TYPE="functional" + - TEST="testem-crossbrowsertesting" TYPE="functional" + - TEST="native-runner-cases" TYPE="functional" + - TEST="native-runner-retries" TYPE="functional" + - TEST="native-runner-working" TYPE="functional" branches: only: diff --git a/appveyor.yml b/appveyor.yml index 960f033..0d8f690 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,111 +7,163 @@ environment: - nodejs_version: "8" cbtr_test: "eslint-non-3rd-party-win" - nodejs_version: "8" - cbtr_test: "browserstack-tunnel-win" + cbtr_test: "core-scriptjob-win" + - nodejs_version: "8" + cbtr_test: "core-integration-tests-win" + - nodejs_version: "8" + cbtr_test: "core-functional-tests-win" - nodejs_version: "8" cbtr_test: "saucelabs-tunnel-win" + - nodejs_version: "8" + cbtr_test: "browserstack-tunnel-win" - nodejs_version: "8" cbtr_test: "crossbrowsertesting-tunnel-win" - nodejs_version: "8" - cbtr_test: "core-scriptjob-win" + cbtr_test: "saucelabs-scriptjob-win" - nodejs_version: "8" cbtr_test: "browserstack-scriptjob-win" - - nodejs_version: "8" - cbtr_test: "saucelabs-scriptjob-win" - nodejs_version: "8" cbtr_test: "crossbrowsertesting-scriptjob-win" - - nodejs_version: "8" - cbtr_test: "browserstack-job-win" - nodejs_version: "8" cbtr_test: "saucelabs-job-win" + - nodejs_version: "8" + cbtr_test: "browserstack-job-win" - nodejs_version: "8" cbtr_test: "crossbrowsertesting-job-win" - nodejs_version: "8" - cbtr_test: "browserstack-platform-win" + cbtr_test: "saucelabs-platform-open-win" + - nodejs_version: "8" + cbtr_test: "browserstack-platform-open-win" + - nodejs_version: "8" + cbtr_test: "crossbrowsertesting-platform-open-win" + - nodejs_version: "8" + cbtr_test: "saucelabs-platform-job-win" + - nodejs_version: "8" + cbtr_test: "browserstack-platform-job-win" + - nodejs_version: "8" + cbtr_test: "crossbrowsertesting-platform-job-win" - nodejs_version: "8" - cbtr_test: "saucelabs-platform-win" + cbtr_test: "saucelabs-platform-scriptjob-win" - nodejs_version: "8" - cbtr_test: "crossbrowsertesting-platform-win" + cbtr_test: "browserstack-platform-scriptjob-win" - nodejs_version: "8" - cbtr_test: "integration-tests-win" + cbtr_test: "crossbrowsertesting-platform-scriptjob-win" - nodejs_version: "8" - cbtr_test: "utils-tests-win" + cbtr_test: "saucelabs-platform-status-win" - nodejs_version: "8" - cbtr_test: "testem-win" + cbtr_test: "browserstack-platform-status-win" - nodejs_version: "8" - cbtr_test: "native-runner-win" - - nodejs_version: "6" + cbtr_test: "crossbrowsertesting-platform-status-win" + - nodejs_version: "8" + cbtr_test: "saucelabs-platform-stop-win" + - nodejs_version: "8" + cbtr_test: "browserstack-platform-stop-win" + - nodejs_version: "8" + cbtr_test: "crossbrowsertesting-platform-stop-win" + - nodejs_version: "8" + cbtr_test: "saucelabs-platform-close-win" + - nodejs_version: "8" + cbtr_test: "browserstack-platform-close-win" + - nodejs_version: "8" + cbtr_test: "crossbrowsertesting-platform-close-win" + - nodejs_version: "8" + cbtr_test: "utils-saucelabs-tests-win" + - nodejs_version: "8" + cbtr_test: "utils-browserstack-tests-win" + - nodejs_version: "8" + cbtr_test: "utils-crossbrowsertesting-tests-win" + - nodejs_version: "8" + cbtr_test: "testem-saucelabs-win" + - nodejs_version: "8" + cbtr_test: "testem-browserstack-win" + - nodejs_version: "8" + cbtr_test: "testem-crossbrowsertesting-win" + - nodejs_version: "8" + cbtr_test: "native-runner-cases-win" + - nodejs_version: "8" + cbtr_test: "native-runner-retries-win" + - nodejs_version: "8" + cbtr_test: "native-runner-working-win" + - nodejs_version: "4" cbtr_test: "eslint-non-3rd-party-win" - - nodejs_version: "6" - cbtr_test: "browserstack-tunnel-win" - - nodejs_version: "6" + - nodejs_version: "4" + cbtr_test: "core-scriptjob-win" + - nodejs_version: "4" + cbtr_test: "core-integration-tests-win" + - nodejs_version: "4" + cbtr_test: "core-functional-tests-win" + - nodejs_version: "4" cbtr_test: "saucelabs-tunnel-win" - - nodejs_version: "6" + - nodejs_version: "4" + cbtr_test: "browserstack-tunnel-win" + - nodejs_version: "4" cbtr_test: "crossbrowsertesting-tunnel-win" - - nodejs_version: "6" - cbtr_test: "core-scriptjob-win" - - nodejs_version: "6" - cbtr_test: "browserstack-scriptjob-win" - - nodejs_version: "6" + - nodejs_version: "4" cbtr_test: "saucelabs-scriptjob-win" - - nodejs_version: "6" + - nodejs_version: "4" + cbtr_test: "browserstack-scriptjob-win" + - nodejs_version: "4" cbtr_test: "crossbrowsertesting-scriptjob-win" - - nodejs_version: "6" - cbtr_test: "browserstack-job-win" - - nodejs_version: "6" + - nodejs_version: "4" cbtr_test: "saucelabs-job-win" - - nodejs_version: "6" + - nodejs_version: "4" + cbtr_test: "browserstack-job-win" + - nodejs_version: "4" cbtr_test: "crossbrowsertesting-job-win" - - nodejs_version: "6" - cbtr_test: "browserstack-platform-win" - - nodejs_version: "6" - cbtr_test: "saucelabs-platform-win" - - nodejs_version: "6" - cbtr_test: "crossbrowsertesting-platform-win" - - nodejs_version: "6" - cbtr_test: "integration-tests-win" - - nodejs_version: "6" - cbtr_test: "utils-tests-win" - - nodejs_version: "6" - cbtr_test: "testem-win" - - nodejs_version: "6" - cbtr_test: "native-runner-win" - nodejs_version: "4" - cbtr_test: "eslint-non-3rd-party-win" + cbtr_test: "saucelabs-platform-open-win" - nodejs_version: "4" - cbtr_test: "browserstack-tunnel-win" + cbtr_test: "browserstack-platform-open-win" - nodejs_version: "4" - cbtr_test: "saucelabs-tunnel-win" + cbtr_test: "crossbrowsertesting-platform-open-win" - nodejs_version: "4" - cbtr_test: "crossbrowsertesting-tunnel-win" + cbtr_test: "saucelabs-platform-job-win" - nodejs_version: "4" - cbtr_test: "core-scriptjob-win" + cbtr_test: "browserstack-platform-job-win" - nodejs_version: "4" - cbtr_test: "browserstack-scriptjob-win" + cbtr_test: "crossbrowsertesting-platform-job-win" - nodejs_version: "4" - cbtr_test: "saucelabs-scriptjob-win" + cbtr_test: "saucelabs-platform-scriptjob-win" - nodejs_version: "4" - cbtr_test: "crossbrowsertesting-scriptjob-win" + cbtr_test: "browserstack-platform-scriptjob-win" - nodejs_version: "4" - cbtr_test: "browserstack-job-win" + cbtr_test: "crossbrowsertesting-platform-scriptjob-win" - nodejs_version: "4" - cbtr_test: "saucelabs-job-win" + cbtr_test: "saucelabs-platform-status-win" - nodejs_version: "4" - cbtr_test: "crossbrowsertesting-job-win" + cbtr_test: "browserstack-platform-status-win" + - nodejs_version: "4" + cbtr_test: "crossbrowsertesting-platform-status-win" + - nodejs_version: "4" + cbtr_test: "saucelabs-platform-stop-win" + - nodejs_version: "4" + cbtr_test: "browserstack-platform-stop-win" + - nodejs_version: "4" + cbtr_test: "crossbrowsertesting-platform-stop-win" + - nodejs_version: "4" + cbtr_test: "saucelabs-platform-close-win" + - nodejs_version: "4" + cbtr_test: "browserstack-platform-close-win" + - nodejs_version: "4" + cbtr_test: "crossbrowsertesting-platform-close-win" + - nodejs_version: "4" + cbtr_test: "utils-saucelabs-tests-win" + - nodejs_version: "4" + cbtr_test: "utils-browserstack-tests-win" - nodejs_version: "4" - cbtr_test: "browserstack-platform-win" + cbtr_test: "utils-crossbrowsertesting-tests-win" - nodejs_version: "4" - cbtr_test: "saucelabs-platform-win" + cbtr_test: "testem-saucelabs-win" - nodejs_version: "4" - cbtr_test: "crossbrowsertesting-platform-win" + cbtr_test: "testem-browserstack-win" - nodejs_version: "4" - cbtr_test: "integration-tests-win" + cbtr_test: "testem-crossbrowsertesting-win" - nodejs_version: "4" - cbtr_test: "utils-tests-win" + cbtr_test: "native-runner-cases-win" - nodejs_version: "4" - cbtr_test: "testem-win" + cbtr_test: "native-runner-retries-win" - nodejs_version: "4" - cbtr_test: "native-runner-win" + cbtr_test: "native-runner-working-win" branches: only: diff --git a/bin/server/defaults.js b/bin/server/defaults.js index 445eab0..b4e486f 100644 --- a/bin/server/defaults.js +++ b/bin/server/defaults.js @@ -23,8 +23,8 @@ const }, parallel: { BrowserStack: 2, - SauceLabs: 5, - CrossBrowserTesting: 5 + SauceLabs: 2, + CrossBrowserTesting: 2 }, server: { port: 7982, diff --git a/conf/crossbrowsertesting-conf.json b/conf/crossbrowsertesting-conf.json index 084e6ee..48f304f 100644 --- a/conf/crossbrowsertesting-conf.json +++ b/conf/crossbrowsertesting-conf.json @@ -3,12 +3,13 @@ "browser": { "Chrome Mobile": { "@key": "browserVersion", - "59.0": "MblChrome59", "61.0": "MblChrome61", "58.0": "MblChrome58", + "59.0": "MblChrome59", "33.0": "MblChrome33", "60.0": "MblChrome60", "57.0": "MblChrome57", + "62.0": "MblChrome62", "51.0": "MblChrome51", "43.0": "MblChrome43", "47.0": "MblChrome47", @@ -21,12 +22,25 @@ "7.0": "MblSafari7.0", "6.0": "MblSafari6.0", "10.0": "MblSafari10.0", + "11.0": "MblSafari11.0", "5.1": "MblSafari5.1", "5.0.2": "MblSafari5.02", - "4.0.4": "MblSafari4.0.4", - "11.0": "MblSafari11.0", "4.0.5": "MblSafari4.0.5" }, + "Safari": { + "@key": "browserVersion", + "11.0": "Safari11", + "10.0": "Safari10", + "9.0": "Safari9", + "8.0": "Safari8", + "7.0": "Safari7", + "6.2": "Safari6.2", + "6.0": "Safari6", + "5.1": "Safari5.1", + "5.0": "Safari5", + "3.1.2": "Safari3.1.2", + "4.0": "Safari4" + }, "Chrome x64": { "@key": "browserVersion", "52.0": "Chrome52x64", @@ -112,24 +126,10 @@ "9.0": "FF9", "39.0": "FF39", "56.0": "FF56", + "57.0": "FF57", "3.5": "FF3.5", "2.0.0.12": "FF2", - "3.0.11": "FF3.0.11", - "57.0": "FF57" - }, - "Safari": { - "@key": "browserVersion", - "10.0": "Safari10", - "9.0": "Safari9", - "8.0": "Safari8", - "7.0": "Safari7", - "6.2": "Safari6.2", - "11.0": "Safari11", - "6.0": "Safari6", - "5.1": "Safari5.1", - "5.0": "Safari5", - "3.1.2": "Safari3.1.2", - "4.0": "Safari4" + "3.0.11": "FF3.0.11" }, "Chrome": { "@key": "browserVersion", @@ -230,8 +230,8 @@ "@key": "browserVersion", "54.0": "MblFF54", "53.0": "MblFF53", + "57.0": "MblFF57", "55.0": "MblFF55", - "52.0": "MblFF52", "56.0": "MblFF56", "28.0": "MblFF28", "47.0": "MblFF47" @@ -249,6 +249,7 @@ "@key": "browserVersion", "27.0": "OperaMini27", "24.0": "OperaMini24", + "31.0": "OperaMini31", "30.0": "OperaMini30", "26.0": "OperaMini26", "28.0": "OperaMini28", @@ -277,13 +278,16 @@ "Android Browser": { "@key": "browserVersion", "4.4": "Android4.4", - "5.0": "Android5.0", "4.2": "Android4.2", "4.1": "Android4.1", "4.0": "Android4.0", "2.3": "Android2.3", "2.2": "Android2.2" }, + "Samsung Browser": { + "@key": "browserVersion", + "5.4": "MblSamsung5.4" + }, "Maxthon Mobile HD": { "@key": "browserVersion", "4.3": "MblMaxthonHD4.3" @@ -312,6 +316,7 @@ "Opera": { "@key": "browserVersion", "48.0": "Opera48", + "49.0": "Opera49", "38.0": "Opera38", "39.0": "Opera39", "40.0": "Opera40", @@ -359,8 +364,7 @@ "9.25": "Opera9.25", "9.50": "Opera9.50", "9.64": "Opera9.64", - "8.02": "Opera8", - "49.0": "Opera49" + "8.02": "Opera8" }, "Camino": { "@key": "browserVersion", @@ -390,24 +394,11 @@ "Mozilla": { "@key": "browserVersion", "1.7.13": "Mozilla1.7" - }, - "Samsung Browser": { - "@key": "browserVersion", - "5.4": "MblSamsung5.4" } }, "os": { "Android": { "@key": "osVersion", - "6.0": { - "@key": "device", - "Android Nexus 9": "Nexus9-And60", - "Android Nexus 6P": "Nexus6P-And60" - }, - "7.0": { - "@key": "device", - "Android Nexus 6P": "Nexus6P-And70" - }, "5.0": { "@key": "device", "Android Nexus 6": "Nexus6-And50", @@ -432,6 +423,15 @@ "Android Galaxy Tab 2": "GalaxyTab2-And41", "Android Galaxy S3": "GalaxyS3-And41" }, + "6.0": { + "@key": "device", + "Android Nexus 9": "Nexus9-And60", + "Android Nexus 6P": "Nexus6P-And60" + }, + "7.0": { + "@key": "device", + "Android Nexus 6P": "Nexus6P-And70" + }, "4.0": { "@key": "device", "Android 4.0 Simulator": "Android4.0" @@ -487,6 +487,12 @@ "iPad Pro Simulator": "iPadPro-iOS102Sim", "iPhone 7 Simulator": "iPhone7-iOS102Sim" }, + "11.0": { + "@key": "device", + "iPad Pro Simulator": "iPadPro-iOS11", + "iPhone X Simulator": "iPhoneX-iOS11", + "iPhone 8 Simulator": "iPhone8-iOS11" + }, "9.0": { "@key": "device", "iPad Air 2": "iPadAir2-iOS9", @@ -503,10 +509,6 @@ "iPad 4": "iPad4-iOS6", "iPhone 5": "iPhone5-iOS6" }, - "5.1": { - "@key": "device", - "iPad 3": "iPad3-iOS5" - }, "5.0": { "@key": "device", "iPad 2 Simulator": "iPad2-iOS5sim", @@ -518,31 +520,24 @@ "@key": "device", "iPad 2": "iPad2-iOS4" }, + "8.3": { + "@key": "device", + "iPhone 6 Plus": "iPhone6Plus-iOS8" + }, "4.1": { "@key": "device", - "iPad 1": "iPad1-iOS3", "iPhone 4": "iPhone4-iOS4", "iPhone 3GS": "iPhone3GS-iOS4" - }, - "11.0": { - "@key": "device", - "iPhone 8 Simulator": "iPhone8-iOS11", - "iPad Pro Simulator": "iPadPro-iOS11", - "iPhone X Simulator": "iPhoneX-iOS11" - }, - "8.3": { - "@key": "device", - "iPhone 6 Plus": "iPhone6Plus-iOS8" } }, "OS X": { "@key": "osVersion", + "High Sierra": "Mac10.13", "Sierra": "Mac10.12", "El Capitan": "Mac10.11", "Yosemite": "Mac10.10", "Mavericks": "Mac10.9", "Mountain Lion": "Mac10.8", - "High Sierra": "Mac10.13", "Lion": "Mac10.7" }, "Windows": { @@ -595,21 +590,6 @@ "@key": "os", "Android": { "@key": "osVersion", - "6.0": { - "@key": "device", - "Android Nexus 9": [ - "1536x2048" - ], - "Android Nexus 6P": [ - "1440x2560" - ] - }, - "7.0": { - "@key": "device", - "Android Nexus 6P": [ - "1440x2560" - ] - }, "5.0": { "@key": "device", "Android Nexus 6": [ @@ -669,6 +649,21 @@ "720x1280" ] }, + "6.0": { + "@key": "device", + "Android Nexus 9": [ + "1536x2048" + ], + "Android Nexus 6P": [ + "1440x2560" + ] + }, + "7.0": { + "@key": "device", + "Android Nexus 6P": [ + "1440x2560" + ] + }, "4.0": { "@key": "device", "Android 4.0 Simulator": [ @@ -787,6 +782,21 @@ "750x1334" ] }, + "11.0": { + "@key": "device", + "iPad Pro Simulator": [ + "2048x2732", + "2732x2048" + ], + "iPhone X Simulator": [ + "1125x2436", + "2436x1125" + ], + "iPhone 8 Simulator": [ + "1334x750", + "750x1334" + ] + }, "9.0": { "@key": "device", "iPad Air 2": [ @@ -824,13 +834,6 @@ "640x1136" ] }, - "5.1": { - "@key": "device", - "iPad 3": [ - "1536x2048", - "2048x1536" - ] - }, "5.0": { "@key": "device", "iPad 2 Simulator": [ @@ -856,44 +859,26 @@ "1024x768" ] }, + "8.3": { + "@key": "device", + "iPhone 6 Plus": [ + "1080x1920", + "1920x1080" + ] + }, "4.1": { "@key": "device", - "iPad 1": [ - "1024x768" - ], "iPhone 4": [ "640x960" ], "iPhone 3GS": [ "320x480" ] - }, - "11.0": { - "@key": "device", - "iPhone 8 Simulator": [ - "1334x750", - "750x1334" - ], - "iPad Pro Simulator": [ - "2048x2732", - "2732x2048" - ], - "iPhone X Simulator": [ - "1125x2436", - "2436x1125" - ] - }, - "8.3": { - "@key": "device", - "iPhone 6 Plus": [ - "1080x1920", - "1920x1080" - ] } }, "OS X": { "@key": "osVersion", - "Sierra": [ + "High Sierra": [ "1024x768", "1152x864", "1152x900", @@ -904,21 +889,18 @@ "1920x1200", "2560x1600" ], - "El Capitan": [ + "Sierra": [ "1024x768", "1152x864", "1152x900", "1280x1024", "1280x800", "1366x768", - "1400x1050", "1400x900", - "1600x1200", "1920x1200", - "2560x1440", "2560x1600" ], - "Yosemite": [ + "El Capitan": [ "1024x768", "1152x864", "1152x900", @@ -932,7 +914,7 @@ "2560x1440", "2560x1600" ], - "Mavericks": [ + "Yosemite": [ "1024x768", "1152x864", "1152x900", @@ -946,26 +928,29 @@ "2560x1440", "2560x1600" ], - "Mountain Lion": [ + "Mavericks": [ "1024x768", "1152x864", "1152x900", "1280x1024", "1280x800", + "1366x768", "1400x1050", "1400x900", "1600x1200", "1920x1200", + "2560x1440", "2560x1600" ], - "High Sierra": [ + "Mountain Lion": [ "1024x768", "1152x864", "1152x900", "1280x1024", "1280x800", - "1366x768", + "1400x1050", "1400x900", + "1600x1200", "1920x1200", "2560x1600" ], @@ -1160,24 +1145,6 @@ "@key": "os", "Android": { "@key": "osVersion", - "6.0": { - "@key": "device", - "Android Nexus 9": { - "@key": "resolution", - "1536x2048": "portrait" - }, - "Android Nexus 6P": { - "@key": "resolution", - "1440x2560": "portrait" - } - }, - "7.0": { - "@key": "device", - "Android Nexus 6P": { - "@key": "resolution", - "1440x2560": "portrait" - } - }, "5.0": { "@key": "device", "Android Nexus 6": { @@ -1249,6 +1216,24 @@ "1280x720": "landscape" } }, + "6.0": { + "@key": "device", + "Android Nexus 9": { + "@key": "resolution", + "1536x2048": "portrait" + }, + "Android Nexus 6P": { + "@key": "resolution", + "1440x2560": "portrait" + } + }, + "7.0": { + "@key": "device", + "Android Nexus 6P": { + "@key": "resolution", + "1440x2560": "portrait" + } + }, "4.0": { "@key": "device", "Android 4.0 Simulator": { @@ -1389,6 +1374,24 @@ "1334x750": "landscape" } }, + "11.0": { + "@key": "device", + "iPad Pro Simulator": { + "@key": "resolution", + "2048x2732": "portrait", + "2732x2048": "landscape" + }, + "iPhone X Simulator": { + "@key": "resolution", + "1125x2436": "portrait", + "2436x1125": "landscape" + }, + "iPhone 8 Simulator": { + "@key": "resolution", + "750x1334": "portrait", + "1334x750": "landscape" + } + }, "9.0": { "@key": "device", "iPad Air 2": { @@ -1433,14 +1436,6 @@ "1136x640": "landscape" } }, - "5.1": { - "@key": "device", - "iPad 3": { - "@key": "resolution", - "1536x2048": "portrait", - "2048x1536": "landscape" - } - }, "5.0": { "@key": "device", "iPad 2 Simulator": { @@ -1471,12 +1466,16 @@ "1024x768": "landscape" } }, - "4.1": { + "8.3": { "@key": "device", - "iPad 1": { + "iPhone 6 Plus": { "@key": "resolution", - "1024x768": "landscape" - }, + "1080x1920": "portrait", + "1920x1080": "landscape" + } + }, + "4.1": { + "@key": "device", "iPhone 4": { "@key": "resolution", "640x960": "portrait" @@ -1485,32 +1484,6 @@ "@key": "resolution", "320x480": "portrait" } - }, - "11.0": { - "@key": "device", - "iPhone 8 Simulator": { - "@key": "resolution", - "750x1334": "portrait", - "1334x750": "landscape" - }, - "iPad Pro Simulator": { - "@key": "resolution", - "2048x2732": "portrait", - "2732x2048": "landscape" - }, - "iPhone X Simulator": { - "@key": "resolution", - "1125x2436": "portrait", - "2436x1125": "landscape" - } - }, - "8.3": { - "@key": "device", - "iPhone 6 Plus": { - "@key": "resolution", - "1080x1920": "portrait", - "1920x1080": "landscape" - } } }, "Blackberry": { @@ -1757,7 +1730,7 @@ }, "7.0": { "Chrome Mobile": { - "61.0": [ + "62.0": [ "Android Nexus 6P" ] }, @@ -1767,7 +1740,7 @@ ] }, "Firefox Mobile": { - "55.0": [ + "57.0": [ "Android Nexus 6P" ] }, @@ -1777,7 +1750,7 @@ ] }, "Opera Mini": { - "30.0": [ + "31.0": [ "Android Nexus 6P" ] }, @@ -4232,20 +4205,6 @@ }, "Selenium": { "Android": { - "6.0": { - "Chrome Mobile": { - "59.0": [ - "Android Nexus 9" - ] - } - }, - "7.0": { - "Chrome Mobile": { - "61.0": [ - "Android Nexus 6P" - ] - } - }, "5.0": { "Chrome Mobile": { "61.0": [ diff --git a/lib/platforms/crossbrowsertesting/tunnel/binary.js b/lib/platforms/crossbrowsertesting/tunnel/binary.js index db06253..ce935d0 100644 --- a/lib/platforms/crossbrowsertesting/tunnel/binary.js +++ b/lib/platforms/crossbrowsertesting/tunnel/binary.js @@ -9,7 +9,7 @@ const cbtPlatformMap = { windows: 'win64', osx: 'macos', - linux: 'linux' + linux: 'linux64' }, url = 'https://github.com/crossbrowsertesting/cbt-tunnel-nodejs/releases/download/v0.2.8/cbt-tunnels-' + cbtPlatformMap[Env.platform] + (Env.isWindows ? '.exe' : '') diff --git a/package.json b/package.json index e521b44..34c1425 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "selenium testing", "browserstack", "saucelabs", - "crossbrowserstesting", + "crossbrowsertesting", "testem", "jasmine" ], @@ -34,7 +34,7 @@ "cbtr-quick-start": "./bin/utils/quick-start.js", "cbtr-browserstack-update": "./bin/utils/conf/browsers/browserstack.js", "cbtr-saucelabs-update": "./bin/utils/conf/browsers/saucelabs.js", - "cbtr-crossbrowserstesting-update": "./bin/utils/conf/browsers/crossbrowsertesting.js", + "cbtr-crossbrowsertesting-update": "./bin/utils/conf/browsers/crossbrowsertesting.js", "cbtr-init": "./bin/utils/settings/cbtr.js", "cbtr-testem-browserstack-init": "./bin/utils/settings/testem/browserstack.js", "cbtr-testem-browserstack-open": "./bin/hooks/testem/browserstack/open.js", @@ -51,48 +51,137 @@ }, "scripts": { "eslint": "./node_modules/.bin/eslint bin/ lib/", + "unx-test-command": "LOG_LEVEL=WARN ./node_modules/.bin/istanbul cover --handle-sigint --include-pid ./node_modules/mocha/bin/_mocha -- --exit --reporter lcovonly --ui bdd -R spec -t 5000 $TEST_PATH", + "unit-tests": "TEST_PATH=tests/unit/tests.js npm run unx-test-command", + "non-3rd-party": "TEST_PATH=tests/unit/non-3rd-party.js npm run unx-test-command", + "eslint-non-3rd-party": "npm run eslint && npm run non-3rd-party", + "browserstack-tunnel": "TEST_PATH=tests/unit/browserstack-tunnel.js npm run unx-test-command", "saucelabs-tunnel": "TEST_PATH=tests/unit/saucelabs-tunnel.js npm run unx-test-command", "crossbrowsertesting-tunnel": "TEST_PATH=tests/unit/crossbrowsertesting-tunnel.js npm run unx-test-command", + "core-scriptjob": "TEST_PATH=tests/unit/core-scriptjob.js npm run unx-test-command", "browserstack-scriptjob": "TEST_PATH=tests/unit/browserstack-scriptjob.js npm run unx-test-command", "saucelabs-scriptjob": "TEST_PATH=tests/unit/saucelabs-scriptjob.js npm run unx-test-command", "crossbrowsertesting-scriptjob": "TEST_PATH=tests/unit/crossbrowsertesting-scriptjob.js npm run unx-test-command", + "browserstack-job": "TEST_PATH=tests/unit/browserstack-job.js npm run unx-test-command", "saucelabs-job": "TEST_PATH=tests/unit/saucelabs-job.js npm run unx-test-command", "crossbrowsertesting-job": "TEST_PATH=tests/unit/crossbrowsertesting-job.js npm run unx-test-command", + + "browserstack-platform-open": "TEST_PATH=tests/unit/browserstack-platform-open.js npm run unx-test-command", + "browserstack-platform-job": "TEST_PATH=tests/unit/browserstack-platform-job.js npm run unx-test-command", + "browserstack-platform-scriptjob": "TEST_PATH=tests/unit/browserstack-platform-scriptjob.js npm run unx-test-command", + "browserstack-platform-status": "TEST_PATH=tests/unit/browserstack-platform-status.js npm run unx-test-command", + "browserstack-platform-stop": "TEST_PATH=tests/unit/browserstack-platform-stop.js npm run unx-test-command", + "browserstack-platform-close": "TEST_PATH=tests/unit/browserstack-platform-close.js npm run unx-test-command", + + "saucelabs-platform-open": "TEST_PATH=tests/unit/saucelabs-platform-open.js npm run unx-test-command", + "saucelabs-platform-job": "TEST_PATH=tests/unit/saucelabs-platform-job.js npm run unx-test-command", + "saucelabs-platform-scriptjob": "TEST_PATH=tests/unit/saucelabs-platform-scriptjob.js npm run unx-test-command", + "saucelabs-platform-status": "TEST_PATH=tests/unit/saucelabs-platform-status.js npm run unx-test-command", + "saucelabs-platform-stop": "TEST_PATH=tests/unit/saucelabs-platform-stop.js npm run unx-test-command", + "saucelabs-platform-close": "TEST_PATH=tests/unit/saucelabs-platform-close.js npm run unx-test-command", + + "crossbrowsertesting-platform-open": "TEST_PATH=tests/unit/crossbrowsertesting-platform-open.js npm run unx-test-command", + "crossbrowsertesting-platform-job": "TEST_PATH=tests/unit/crossbrowsertesting-platform-job.js npm run unx-test-command", + "crossbrowsertesting-platform-scriptjob": "TEST_PATH=tests/unit/crossbrowsertesting-platform-scriptjob.js npm run unx-test-command", + "crossbrowsertesting-platform-status": "TEST_PATH=tests/unit/crossbrowsertesting-platform-status.js npm run unx-test-command", + "crossbrowsertesting-platform-stop": "TEST_PATH=tests/unit/crossbrowsertesting-platform-stop.js npm run unx-test-command", + "crossbrowsertesting-platform-close": "TEST_PATH=tests/unit/crossbrowsertesting-platform-close.js npm run unx-test-command", + + "core-integration-tests": "TEST_PATH=tests/integration/core.js npm run unx-test-command", + "browserstack-integration-tests": "TEST_PATH=tests/integration/browserstack.js npm run unx-test-command", + "saucelabs-integration-tests": "TEST_PATH=tests/integration/saucelabs.js npm run unx-test-command", + "crossbrowsertesting-integration-tests": "TEST_PATH=tests/integration/crossbrowsertesting.js npm run unx-test-command", + + "core-functional-tests": "TEST_PATH=tests/functional/core.js npm run unx-test-command", + + "utils-browserstack-tests": "TEST_PATH=tests/functional/utils-browserstack.js npm run unx-test-command", + "utils-saucelabs-tests": "TEST_PATH=tests/functional/utils-saucelabs.js npm run unx-test-command", + "utils-crossbrowsertesting-tests": "TEST_PATH=tests/functional/utils-crossbrowsertesting.js npm run unx-test-command", + + "testem-browserstack": "TEST_PATH=tests/functional/testem-browserstack.js npm run unx-test-command", + "testem-saucelabs": "TEST_PATH=tests/functional/testem-saucelabs.js npm run unx-test-command", + "testem-crossbrowsertesting": "TEST_PATH=tests/functional/testem-crossbrowsertesting.js npm run unx-test-command", + + "native-runner-cases": "TEST_PATH=tests/functional/native-cases.js npm run unx-test-command", + "native-runner-retries": "TEST_PATH=tests/functional/native-retries.js npm run unx-test-command", + "native-runner-working": "TEST_PATH=tests/functional/native-working.js npm run unx-test-command", + "browserstack-platform": "TEST_PATH=tests/unit/browserstack-platform.js npm run unx-test-command", "saucelabs-platform": "TEST_PATH=tests/unit/saucelabs-platform.js npm run unx-test-command", "crossbrowsertesting-platform": "TEST_PATH=tests/unit/crossbrowsertesting-platform.js npm run unx-test-command", - "eslint-non-3rd-party": "npm run eslint && npm run non-3rd-party", - "integration-tests": "TEST_PATH=tests/integration/tests.js npm run unx-test-command", - "utils-tests": "TEST_PATH=tests/functional/utils-tests.js npm run unx-test-command", - "testem": "TEST_PATH=tests/functional/testem.js npm run unx-test-command", "native-runner": "TEST_PATH=tests/functional/native-runner.js npm run unx-test-command", + "win-test-command": "./node_modules/.bin/istanbul cover --handle-sigint --include-pid ./node_modules/mocha/bin/_mocha -- --exit --reporter lcovonly --ui bdd -R spec -t 5000 %TEST_PATH%", + "unit-tests-win": "cmd /v /c \"set TEST_PATH=tests/unit/tests.js&& npm run win-test-command\"", + "non-3rd-party-win": "cmd /v /c \"set TEST_PATH=tests/unit/non-3rd-party.js&& npm run win-test-command\"", + "eslint-non-3rd-party-win": "npm run eslint && npm run non-3rd-party-win", + "browserstack-tunnel-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-tunnel.js&& npm run win-test-command\"", "saucelabs-tunnel-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-tunnel.js&& npm run win-test-command\"", "crossbrowsertesting-tunnel-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-tunnel.js&& npm run win-test-command\"", + "core-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/core-scriptjob.js&& npm run win-test-command\"", "browserstack-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-scriptjob.js&& npm run win-test-command\"", "saucelabs-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-scriptjob.js&& npm run win-test-command\"", "crossbrowsertesting-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-scriptjob.js&& npm run win-test-command\"", + "browserstack-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-job.js&& npm run win-test-command\"", "saucelabs-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-job.js&& npm run win-test-command\"", "crossbrowsertesting-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-job.js&& npm run win-test-command\"", + + "browserstack-platform-open-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-open.js&& npm run win-test-command\"", + "browserstack-platform-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-job.js&& npm run win-test-command\"", + "browserstack-platform-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-scriptjob.js&& npm run win-test-command\"", + "browserstack-platform-status-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-status.js&& npm run win-test-command\"", + "browserstack-platform-stop-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-stop.js&& npm run win-test-command\"", + "browserstack-platform-close-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform-close.js&& npm run win-test-command\"", + + "saucelabs-platform-open-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-open.js&& npm run win-test-command\"", + "saucelabs-platform-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-job.js&& npm run win-test-command\"", + "saucelabs-platform-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-scriptjob.js&& npm run win-test-command\"", + "saucelabs-platform-status-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-status.js&& npm run win-test-command\"", + "saucelabs-platform-stop-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-stop.js&& npm run win-test-command\"", + "saucelabs-platform-close-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform-close.js&& npm run win-test-command\"", + + "crossbrowsertesting-platform-open-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-open.js&& npm run win-test-command\"", + "crossbrowsertesting-platform-job-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-job.js&& npm run win-test-command\"", + "crossbrowsertesting-platform-scriptjob-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-scriptjob.js&& npm run win-test-command\"", + "crossbrowsertesting-platform-status-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-status.js&& npm run win-test-command\"", + "crossbrowsertesting-platform-stop-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-stop.js&& npm run win-test-command\"", + "crossbrowsertesting-platform-close-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform-close.js&& npm run win-test-command\"", + + "core-integration-tests-win": "cmd /v /c \"set TEST_PATH=tests/integration/core.js&& npm run win-test-command\"", + "browserstack-integration-tests-win": "cmd /v /c \"set TEST_PATH=tests/integration/browserstack.js&& npm run win-test-command\"", + "saucelabs-integration-tests-win": "cmd /v /c \"set TEST_PATH=tests/integration/saucelabs.js&& npm run win-test-command\"", + "crossbrowsertesting-integration-tests-win": "cmd /v /c \"set TEST_PATH=tests/integration/crossbrowsertesting.js&& npm run win-test-command\"", + + "core-functional-tests-win": "cmd /v /c \"set TEST_PATH=tests/functional/core.js&& npm run win-test-command\"", + + "utils-browserstack-tests-win": "cmd /v /c \"set TEST_PATH=tests/functional/utils-browserstack.js&& npm run win-test-command\"", + "utils-saucelabs-tests-win": "cmd /v /c \"set TEST_PATH=tests/functional/utils-saucelabs.js&& npm run win-test-command\"", + "utils-crossbrowsertesting-tests-win": "cmd /v /c \"set TEST_PATH=tests/functional/utils-crossbrowsertesting.js&& npm run win-test-command\"", + + "testem-browserstack-win": "cmd /v /c \"set TEST_PATH=tests/functional/testem-browserstack.js&& npm run win-test-command\"", + "testem-saucelabs-win": "cmd /v /c \"set TEST_PATH=tests/functional/testem-saucelabs.js&& npm run win-test-command\"", + "testem-crossbrowsertesting-win": "cmd /v /c \"set TEST_PATH=tests/functional/testem-crossbrowsertesting.js&& npm run win-test-command\"", + + "native-runner-cases-win": "cmd /v /c \"set TEST_PATH=tests/functional/native-cases.js&& npm run win-test-command\"", + "native-runner-retries-win": "cmd /v /c \"set TEST_PATH=tests/functional/native-retries.js&& npm run win-test-command\"", + "native-runner-working-win": "cmd /v /c \"set TEST_PATH=tests/functional/native-working.js&& npm run win-test-command\"", + "browserstack-platform-win": "cmd /v /c \"set TEST_PATH=tests/unit/browserstack-platform.js&& npm run win-test-command\"", "saucelabs-platform-win": "cmd /v /c \"set TEST_PATH=tests/unit/saucelabs-platform.js&& npm run win-test-command\"", "crossbrowsertesting-platform-win": "cmd /v /c \"set TEST_PATH=tests/unit/crossbrowsertesting-platform.js&& npm run win-test-command\"", - "eslint-non-3rd-party-win": "npm run eslint && npm run non-3rd-party-win", - "integration-tests-win": "cmd /v /c \"set TEST_PATH=tests/integration/tests.js&& npm run win-test-command\"", - "utils-tests-win": "cmd /v /c \"set TEST_PATH=tests/functional/utils-tests.js&& npm run win-test-command\"", - "testem-win": "cmd /v /c \"set TEST_PATH=tests/functional/testem.js&& npm run win-test-command\"", "native-runner-win": "cmd /v /c \"set TEST_PATH=tests/functional/native-runner.js&& npm run win-test-command\"", + "codecov-upload": "./node_modules/.bin/codecov", "coveralls-upload": "cat coverage/lcov.info | ./node_modules/.bin/coveralls", "coveralls-upload-win": "node node_modules\\coveralls\\bin\\coveralls-win.js coverage\\lcov.info" diff --git a/tests/functional/conf/native/jasmine-1/1.json b/tests/functional/conf/native/jasmine-1/1.json index 3749798..2779974 100644 --- a/tests/functional/conf/native/jasmine-1/1.json +++ b/tests/functional/conf/native/jasmine-1/1.json @@ -48,8 +48,8 @@ { "os": "Android", "osVersion": "6.0", - "browser": "Maxthon Mobile", - "browserVersion": "4.3", + "browser": "Firefox Mobile", + "browserVersion": "54.0", "device": "Android Nexus 9" } ] diff --git a/tests/functional/conf/native/selenium/1.json b/tests/functional/conf/native/selenium/1.json index db89ae8..e3e906e 100644 --- a/tests/functional/conf/native/selenium/1.json +++ b/tests/functional/conf/native/selenium/1.json @@ -51,11 +51,11 @@ "browserVersion": "10.0" }, { - "os": "Android", - "osVersion": "7.0", - "browser": "Chrome Mobile", - "browserVersion": "61.0", - "device": "Android Nexus 6P" + "os": "iOS", + "osVersion": "9.3", + "browser": "Mobile Safari", + "browserVersion": "9.0", + "device": "iPad Air 2 Simulator" } ] } diff --git a/tests/functional/conf/testem/jasmine-1/browserstack.json b/tests/functional/conf/testem/jasmine-1/browserstack.json index 525f7fc..41ec93a 100644 --- a/tests/functional/conf/testem/jasmine-1/browserstack.json +++ b/tests/functional/conf/testem/jasmine-1/browserstack.json @@ -1,5 +1,5 @@ { - "parallel": 4, + "parallel": 2, "browser_start_timeout" : 90, "framework": "jasmine", "on_start": { diff --git a/tests/functional/conf/testem/jasmine-1/crossbrowsertesting.json b/tests/functional/conf/testem/jasmine-1/crossbrowsertesting.json index 6c127de..7bd2c7b 100644 --- a/tests/functional/conf/testem/jasmine-1/crossbrowsertesting.json +++ b/tests/functional/conf/testem/jasmine-1/crossbrowsertesting.json @@ -1,5 +1,5 @@ { - "parallel": 4, + "parallel": 2, "browser_start_timeout" : 90, "framework": "jasmine", "on_start": { diff --git a/tests/functional/conf/testem/jasmine-1/saucelabs.json b/tests/functional/conf/testem/jasmine-1/saucelabs.json index 221be3a..0f0330d 100644 --- a/tests/functional/conf/testem/jasmine-1/saucelabs.json +++ b/tests/functional/conf/testem/jasmine-1/saucelabs.json @@ -1,5 +1,5 @@ { - "parallel": 4, + "parallel": 2, "browser_start_timeout" : 90, "framework": "jasmine", "on_start": { @@ -50,7 +50,7 @@ "--os", "OS X", "--osVersion", "Sierra", "--browser", "Safari", - "--browserVersion", "10.0", + "--browserVersion", "10.1", "--timeout", "90", "--build", "testem-build", "--project", "cross-browser-tests-runner/cross-browser-tests-runner", diff --git a/tests/functional/utils-tests.js b/tests/functional/core.js similarity index 69% rename from tests/functional/utils-tests.js rename to tests/functional/core.js index 3b44185..7baf360 100644 --- a/tests/functional/utils-tests.js +++ b/tests/functional/core.js @@ -1,4 +1,4 @@ describe('Functional Tests', function() { require('./tests/server') - require('./tests/utils') + require('./tests/utils-core') }) diff --git a/tests/functional/testem.js b/tests/functional/native-cases.js similarity index 56% rename from tests/functional/testem.js rename to tests/functional/native-cases.js index a4bbb8f..b704ebf 100644 --- a/tests/functional/testem.js +++ b/tests/functional/native-cases.js @@ -1,3 +1,3 @@ describe('Functional Tests', function() { - require('./tests/testem') + require('./tests/native-cases') }) diff --git a/tests/functional/native-retries.js b/tests/functional/native-retries.js new file mode 100644 index 0000000..e1fbd72 --- /dev/null +++ b/tests/functional/native-retries.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/native-retries') +}) diff --git a/tests/functional/native-working.js b/tests/functional/native-working.js new file mode 100644 index 0000000..0b00c67 --- /dev/null +++ b/tests/functional/native-working.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/native-working') +}) diff --git a/tests/functional/samples/browsers/bad/crossbrowsertesting/selenium/unsup-standard-property.yml b/tests/functional/samples/browsers/bad/crossbrowsertesting/selenium/unsup-standard-property.yml index 85866b1..7c15fd4 100644 --- a/tests/functional/samples/browsers/bad/crossbrowsertesting/selenium/unsup-standard-property.yml +++ b/tests/functional/samples/browsers/bad/crossbrowsertesting/selenium/unsup-standard-property.yml @@ -1,6 +1,6 @@ CrossBrowserTesting: Selenium: Android: - "6.0": - Android Nexus 9: + "4.2": + Android Galaxy S4: osVersion: abc diff --git a/tests/functional/samples/browsers/crossbrowsertesting/selenium/mobile-1.yml b/tests/functional/samples/browsers/crossbrowsertesting/selenium/mobile-1.yml index 96ecdc5..69bc92a 100644 --- a/tests/functional/samples/browsers/crossbrowsertesting/selenium/mobile-1.yml +++ b/tests/functional/samples/browsers/crossbrowsertesting/selenium/mobile-1.yml @@ -1,7 +1,9 @@ CrossBrowserTesting: Selenium: Android: - "7.0": - Android Nexus 6P: - resolution: 1440x2560 - orientation: portrait + "4.4": + Chrome Mobile: + "58.0": + Android Galaxy Note 3: + resolution: 1080x1920 + orientation: portrait diff --git a/tests/functional/testem-browserstack.js b/tests/functional/testem-browserstack.js new file mode 100644 index 0000000..160c362 --- /dev/null +++ b/tests/functional/testem-browserstack.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/testem-browserstack') +}) diff --git a/tests/functional/testem-crossbrowsertesting.js b/tests/functional/testem-crossbrowsertesting.js new file mode 100644 index 0000000..f153a2a --- /dev/null +++ b/tests/functional/testem-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/testem-crossbrowsertesting') +}) diff --git a/tests/functional/testem-saucelabs.js b/tests/functional/testem-saucelabs.js new file mode 100644 index 0000000..d4a818c --- /dev/null +++ b/tests/functional/testem-saucelabs.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/testem-saucelabs') +}) diff --git a/tests/functional/tests/native-cases.js b/tests/functional/tests/native-cases.js new file mode 100644 index 0000000..e488730 --- /dev/null +++ b/tests/functional/tests/native-cases.js @@ -0,0 +1,3 @@ +describe('Native Runner', function() { + require('./native/cases') +}) diff --git a/tests/functional/tests/native-retries.js b/tests/functional/tests/native-retries.js new file mode 100644 index 0000000..17bd2b8 --- /dev/null +++ b/tests/functional/tests/native-retries.js @@ -0,0 +1,3 @@ +describe('Native Runner', function() { + require('./native/retries') +}) diff --git a/tests/functional/tests/native-working.js b/tests/functional/tests/native-working.js new file mode 100644 index 0000000..3eed582 --- /dev/null +++ b/tests/functional/tests/native-working.js @@ -0,0 +1,3 @@ +describe('Native Runner', function() { + require('./native/working') +}) diff --git a/tests/functional/tests/native.js b/tests/functional/tests/native.js index ead39ce..a3ef124 100644 --- a/tests/functional/tests/native.js +++ b/tests/functional/tests/native.js @@ -1,695 +1,5 @@ -var - path = require('path'), - chai = require('chai'), - chaiHttp = require('chai-http'), - chaiAsPromised = require('chai-as-promised'), - Env = require('./../../../lib/core/env').Env, - Process = require('./../../../lib/core/process').Process, - BinaryVars = require('./../../../lib/platforms/browserstack/tunnel/binary').BinaryVars, - bsUtils = require('./../../unit/tests/platforms/browserstack/utils'), - utils = require('./testutils') - -chai.use(chaiAsPromised) -chai.use(chaiHttp) - -var - expect = chai.expect, - should = chai.should(), - request = chai.request - -const TestDataWithErrors = { - "suites": [ - { - "description": "sum", - "specs": [], - "suites": [ - { - "description": "suite 1", - "specs": [ - { - "description": "should return the sum of two numbers", - "duration": 87, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 87 - }, - { - "description": "suite 2", - "specs": [ - { - "description": "should treat 0 as 1", - "duration": 5, - "passed": false, - "skipped": false, - "failures": [ - { - "type": "expect", - "matcherName": "toEqual", - "expected": 3, - "actual": 2, - "message": "Expected 2 to equal 3.", - "trace": { - "stack": "Error: Expected 2 to equal 3.\n at new jasmine.ExpectationResult (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:114:32)\n at matchersClass.toEqual (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1235:29)\n at jasmine.Spec. (http://127.0.0.1:7982/tests/functional/code/tests/jasmine/js/test.js:9:25)\n at jasmine.Block.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1064:17)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Spec.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2376:14)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Suite.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2521:14)", - "message": "Expected 2 to equal 3." - } - } - ] - } - ], - "suites": [], - "passed": 0, - "failed": 1, - "skipped": 0, - "total": 1, - "duration": 5 - } - ], - "passed": 1, - "failed": 1, - "skipped": 0, - "total": 2, - "duration": 92 - }, - { - "description": "mult", - "specs": [], - "suites": [ - { - "description": "suite 1", - "specs": [ - { - "description": "should return the product of two numbers", - "duration": 0, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 0 - }, - { - "description": "suite 2", - "specs": [ - { - "description": "should treat 1 as 0", - "duration": 0, - "passed": false, - "skipped": false, - "failures": [ - { - "type": "expect", - "matcherName": "toEqual", - "expected": 0, - "actual": 2, - "message": "Expected 2 to equal 0.", - "trace": { - "stack": "Error: Expected 2 to equal 0.\n at new jasmine.ExpectationResult (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:114:32)\n at matchersClass.toEqual (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1235:29)\n at jasmine.Spec. (http://127.0.0.1:7982/tests/functional/code/tests/jasmine/js/test.js:22:26)\n at jasmine.Block.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1064:17)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Spec.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2376:14)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Suite.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2521:14)", - "message": "Expected 2 to equal 0." - } - } - ] - } - ], - "suites": [], - "passed": 0, - "failed": 1, - "skipped": 0, - "total": 1, - "duration": 0 - } - ], - "passed": 1, - "failed": 1, - "skipped": 0, - "total": 2, - "duration": 0 - }, - { - "description": "always true", - "specs": [], - "suites": [ - { - "description": "suite 1", - "specs": [ - { - "description": "should say 1 is 1", - "duration": 0, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 0 - }, - { - "description": "suite 2", - "specs": [ - { - "description": "should say 1 is not 0", - "duration": 0, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 0 - } - ], - "passed": 2, - "failed": 0, - "skipped": 0, - "total": 2, - "duration": 0 - } - ], - "passed": 4, - "failed": 2, - "skipped": 0, - "total": 6, - "duration": 92 -}, -TestDataWithoutErrors = { - "suites": [ - { - "description": "sum", - "specs": [ - { - "description": "should return the sum of two numbers", - "duration": 7, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 7 - }, - { - "description": "mult", - "specs": [ - { - "description": "should return the product of two numbers", - "duration": 0, - "passed": true, - "skipped": false, - "failures": [] - } - ], - "suites": [], - "passed": 1, - "failed": 0, - "skipped": 0, - "total": 1, - "duration": 0 - } - ], - "passed": 2, - "failed": 0, - "skipped": 0, - "total": 2, - "duration": 7 -} - - describe('Native Runner', function() { - - this.timeout(0) - - if(!Env.isWindows) { - it('should handle failures in closing the platforms (simulated by removing execute permissions from tunnel binary executable)', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/tiny.json', - ]), { - onstdout: function(stdout) { - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - if(stdout.match(/Chrome 40.0 Windows 7/)) { - utils.safeChmod(BinaryVars.path, '0400').then(() => { - utils.log.debug('Changed mode to read-only') - }) - } - }, - onstderr: function(stderr) { - out += stderr - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - return utils.safeChmod(BinaryVars.path, '0755') - }) - .then(() => { - expect(out).to.contain('failed closing platforms') - return bsUtils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should ignore bad POST requests to /cbtr/run endpoint', function() { - var proc = new Process(), out = '', host = 'http://build.cross-browser-tests-runner.org:8000', began = false - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/tiny.json', - ]), { - onstdout: function(stdout) { - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - if(stdout.match(/Chrome 40.0 Windows 7/) && !began) { - began = true - var run, test - request(host) - .get('/cbtr/status') - .then(res => { - expect(res).to.have.status(200) - run = Object.keys(res.body)[0] - test = res.body[run][0] - utils.log.debug('Found run %s, test %s from native runner', run, test) - return request(host) - .post('/cbtr/run?a=b') - .send(TestDataWithoutErrors) - }) - .catch(err => { - expect(err).to.have.status(400) - return request(host) - .post('/cbtr/run?cbtr_run=&cbtr_test=') - .send(TestDataWithoutErrors) - }) - .catch(err => { - expect(err).to.have.status(400) - return request(host) - .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=') - .send(TestDataWithoutErrors) - }) - .catch(err => { - expect(err).to.have.status(400) - return request(host) - .post('/cbtr/run?cbtr_run=some-run&cbtr_test=' + test) - .send(TestDataWithoutErrors) - }) - .catch(err => { - expect(err).to.have.status(404) - return request(host) - .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=some-test') - .send(TestDataWithoutErrors) - }) - .catch(err => { - expect(err).to.have.status(404) - return request(host) - .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=' + test) - .send(TestDataWithoutErrors) - }) - .then(res => { - expect(res.statusCode).to.be.oneOf([200, 404]) - }) - } - }, - onstderr: function(stderr) { - out += stderr - utils.errorWithoutCovLines(stderr) - } - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should do nothing if no browsers are provided in a Jasmine 1.x test configuration', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/no-browsers.json' - ]), { - onstdout: function(stdout) { - utils.log.debug(stdout) - out += stdout - if(stdout.match(/no tests found in settings/)) { - proc.stop() - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('no tests found in settings') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should bail out if bad browsers are provided in a Jasmine 1.x test configuration', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/bad-browsers.json' - ]), { - onstdout: function(stdout) { - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - out += stderr - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('could not start tests cleanly, exiting...') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should retry a job that failed due to platform errors for a supported browser/platform configuration', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/error-from-platform.json' - ]), { - onstdout: function(stdout) { - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - out += stdout - } - }, - onstderr: function(stderr) { - out += stderr - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('UnsupportedOperationError: The requested combination of browser, version and OS is currently unsupported in this version of Selenium (WebDriver): "Browser 7.0."') - expect(out).to.contain('run of tests was unsuccessful') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should cause the "unknown run" race condition and handle it successfully and not report with "did not respond"', function() { - var proc = new Process(), out = '', err = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--errors-only', - '--config', - 'tests/functional/conf/native/jasmine-1/fast-and-slow.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - err += stderr - } - }) - .then(() => { - expect(err).to.not.match(/Chrome 60\.0 Windows 10.*did not respond/) - expect(out).to.not.match(/Chrome 60\.0 Windows 10.*did not respond/) - expect(err).to.match(/Manager unknown run/) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should work successfully for a valid Jasmine 1.x test configuration and print failed test cases only, if "--errors-only" command line option is provided', function() { - var proc = new Process(), out = '', confName = (process.version > 'v6' ? '1.json' : '1-no-sauce.json') - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--errors-only', - '--config', - 'tests/functional/conf/native/jasmine-1/' + confName - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should ignore a cross-browser testing platform in a Jasmine 1.x test configuration if it does not have JS browsers defined; but run the tests for other valid platform in the same configuration, and print only error cases without stack trace, if "--errors-only" and "--omit-traces" command line options are provided', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--errors-only', - '--omit-traces', - '--config', - 'tests/functional/conf/native/jasmine-1/bad-platform.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should perform as many retries as mentioned in a Jasmine 1.x test configuration to attempt completing tests across all browsers specified in the configuration', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/retries.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - if(!out.match(/✓.*should return the sum of two numbers/)) { - utils.log.warn('no sum tests were run') - } - if(!out.match(/✓.*should return the product of two numbers/)) { - utils.log.warn('no product tests were run') - } - if(!out.match(/browser Android Browser Amazon Kindle Fire HD 8.9 Android 4.0 for url http:\/\/build\.cross\-browser\-tests\-runner\.org:8000\/tests\/functional\/code\/tests\/jasmine\/html\/tests.html did not respond with results/)) { - utils.log.warn('expected Android device to not respond and time out') - } - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should not perform any retries for failed tests if the Jasmine 1.x test configuration specifies 0 retries, and complete the test run with just one try of each test whether it works or not', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/jasmine-1/0-retries.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - if(!out.match(/✓.*should return the sum of two numbers/)) { - utils.log.warn('no sum tests were run') - } - if(!out.match(/✓.*should return the product of two numbers/)) { - utils.log.warn('no product tests were run') - } - if(!out.match(/browser Android Browser Amazon Kindle Fire HD 8.9 Android 4.0 for url http:\/\/build\.cross\-browser\-tests\-runner\.org:8000\/tests\/functional\/code\/tests\/jasmine\/html\/tests-ok.html did not respond with results/)) { - utils.log.warn('expected Android device to not respond and time out') - } - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - - it('should complete all tests specified in a Selenium test configuration', function() { - var proc = new Process(), out = '', host = 'http://build.cross-browser-tests-runner.org:8000', askedStatus = false - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/selenium/1.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - if(!askedStatus) { - askedStatus = true - request(host) - .get('/cbtr/status') - .then(res => { - expect(res).to.have.status(200) - expect(res.body).to.deep.equal({ }) - }) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - if(!out.match(/Selenium Test Script: text of #test-message Hi, this is a test page for functional testing of selenium testing with cross\-browser\-tests\-runner native runner/)) { - utils.log.warn('Selenium test did not run') - } - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should ignore a cross-browser testing platform in a Selenium test configuration if it does not have browsers specified; but should complete the tests for the other platform with valid browsers specified', function() { - var proc = new Process(), out = '' - return proc.create( - 'node', - utils.nodeProcCoverageArgs('bin/server/server.js', [ - '--native-runner', - '--config', - 'tests/functional/conf/native/selenium/bad-platform.json' - ]), { - onstdout: function(stdout) { - out += stdout - if(!stdout.match(/=============== Coverage summary ==========/)) { - console.log(stdout.trim()) - } - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - if(!out.match(/Selenium Test Script: text of #test-message Hi, this is a test page for functional testing of selenium testing with cross\-browser\-tests\-runner native runner/)) { - utils.log.warn('Selenium test did not run') - } - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - } - + require('./native/cases') + require('./native/retries') + require('./native/working') }) diff --git a/tests/functional/tests/native/cases.js b/tests/functional/tests/native/cases.js new file mode 100644 index 0000000..2fb2e53 --- /dev/null +++ b/tests/functional/tests/native/cases.js @@ -0,0 +1,301 @@ +var + path = require('path'), + chai = require('chai'), + chaiHttp = require('chai-http'), + chaiAsPromised = require('chai-as-promised'), + Env = require('./../../../../lib/core/env').Env, + Process = require('./../../../../lib/core/process').Process, + BinaryVars = require('./../../../../lib/platforms/browserstack/tunnel/binary').BinaryVars, + bsUtils = require('./../../../unit/tests/platforms/browserstack/utils'), + utils = require('./../testutils') + +chai.use(chaiAsPromised) +chai.use(chaiHttp) + +var + expect = chai.expect, + should = chai.should(), + request = chai.request + +const + TestDataWithoutErrors = require('./test-data-without-errors.json') + +describe('cases', function() { + + this.timeout(0) + + if(!Env.isWindows) { + it('should handle failures in closing the platforms (simulated by removing execute permissions from tunnel binary executable)', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/tiny.json', + ]), { + onstdout: function(stdout) { + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + if(stdout.match(/Chrome 40.0 Windows 7/)) { + utils.safeChmod(BinaryVars.path, '0400').then(() => { + utils.log.debug('Changed mode to read-only') + }) + } + }, + onstderr: function(stderr) { + out += stderr + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + return utils.safeChmod(BinaryVars.path, '0755') + }) + .then(() => { + expect(out).to.contain('failed closing platforms') + return bsUtils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should ignore bad POST requests to /cbtr/run endpoint', function() { + var proc = new Process(), out = '', host = 'http://build.cross-browser-tests-runner.org:8000', began = false + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/tiny.json', + ]), { + onstdout: function(stdout) { + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + if(stdout.match(/Chrome 40.0 Windows 7/) && !began) { + began = true + var run, test + request(host) + .get('/cbtr/status') + .then(res => { + expect(res).to.have.status(200) + run = Object.keys(res.body)[0] + test = res.body[run][0] + utils.log.debug('Found run %s, test %s from native runner', run, test) + return request(host) + .post('/cbtr/run?a=b') + .send(TestDataWithoutErrors) + }) + .catch(err => { + expect(err).to.have.status(400) + return request(host) + .post('/cbtr/run?cbtr_run=&cbtr_test=') + .send(TestDataWithoutErrors) + }) + .catch(err => { + expect(err).to.have.status(400) + return request(host) + .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=') + .send(TestDataWithoutErrors) + }) + .catch(err => { + expect(err).to.have.status(400) + return request(host) + .post('/cbtr/run?cbtr_run=some-run&cbtr_test=' + test) + .send(TestDataWithoutErrors) + }) + .catch(err => { + expect(err).to.have.status(404) + return request(host) + .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=some-test') + .send(TestDataWithoutErrors) + }) + .catch(err => { + expect(err).to.have.status(404) + return request(host) + .post('/cbtr/run?cbtr_run=' + run + '&cbtr_test=' + test) + .send(TestDataWithoutErrors) + }) + .then(res => { + expect(res.statusCode).to.be.oneOf([200, 404]) + }) + } + }, + onstderr: function(stderr) { + out += stderr + utils.errorWithoutCovLines(stderr) + } + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should do nothing if no browsers are provided in a Jasmine 1.x test configuration', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/no-browsers.json' + ]), { + onstdout: function(stdout) { + utils.log.debug(stdout) + out += stdout + if(stdout.match(/no tests found in settings/)) { + proc.stop() + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('no tests found in settings') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should bail out if bad browsers are provided in a Jasmine 1.x test configuration', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/bad-browsers.json' + ]), { + onstdout: function(stdout) { + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + out += stderr + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('could not start tests cleanly, exiting...') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should cause the "unknown run" race condition and handle it successfully and not report with "did not respond"', function() { + var proc = new Process(), out = '', err = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--errors-only', + '--config', + 'tests/functional/conf/native/jasmine-1/fast-and-slow.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + err += stderr + } + }) + .then(() => { + expect(err).to.not.match(/Chrome 60\.0 Windows 10.*did not respond/) + expect(out).to.not.match(/Chrome 60\.0 Windows 10.*did not respond/) + expect(err).to.match(/Manager unknown run/) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should ignore a cross-browser testing platform in a Jasmine 1.x test configuration if it does not have JS browsers defined; but run the tests for other valid platform in the same configuration, and print only error cases without stack trace, if "--errors-only" and "--omit-traces" command line options are provided', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--errors-only', + '--omit-traces', + '--config', + 'tests/functional/conf/native/jasmine-1/bad-platform.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + + it('should ignore a cross-browser testing platform in a Selenium test configuration if it does not have browsers specified; but should complete the tests for the other platform with valid browsers specified', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/selenium/bad-platform.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + if(!out.match(/Selenium Test Script: text of #test-message Hi, this is a test page for functional testing of selenium testing with cross\-browser\-tests\-runner native runner/)) { + utils.log.warn('Selenium test did not run') + } + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + } + +}) diff --git a/tests/functional/tests/native/retries.js b/tests/functional/tests/native/retries.js new file mode 100644 index 0000000..544a871 --- /dev/null +++ b/tests/functional/tests/native/retries.js @@ -0,0 +1,128 @@ +var + chai = require('chai'), + chaiHttp = require('chai-http'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../lib/core/process').Process, + utils = require('./../testutils') + +chai.use(chaiAsPromised) +chai.use(chaiHttp) + +var + expect = chai.expect, + should = chai.should(), + request = chai.request + +describe('retries', function() { + + this.timeout(0) + + it('should retry a job that failed due to platform errors for a supported browser/platform configuration', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/error-from-platform.json' + ]), { + onstdout: function(stdout) { + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + out += stdout + } + }, + onstderr: function(stderr) { + out += stderr + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('UnsupportedOperationError: The requested combination of browser, version and OS is currently unsupported in this version of Selenium (WebDriver): "Browser 7.0."') + expect(out).to.contain('run of tests was unsuccessful') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should perform as many retries as mentioned in a Jasmine 1.x test configuration to attempt completing tests across all browsers specified in the configuration', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/retries.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + if(!out.match(/✓.*should return the sum of two numbers/)) { + utils.log.warn('no sum tests were run') + } + if(!out.match(/✓.*should return the product of two numbers/)) { + utils.log.warn('no product tests were run') + } + if(!out.match(/browser Android Browser Amazon Kindle Fire HD 8.9 Android 4.0 for url http:\/\/build\.cross\-browser\-tests\-runner\.org:8000\/tests\/functional\/code\/tests\/jasmine\/html\/tests.html did not respond with results/)) { + utils.log.warn('expected Android device to not respond and time out') + } + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should not perform any retries for failed tests if the Jasmine 1.x test configuration specifies 0 retries, and complete the test run with just one try of each test whether it works or not', function() { + var proc = new Process(), out = '' + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/jasmine-1/0-retries.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + if(!out.match(/✓.*should return the sum of two numbers/)) { + utils.log.warn('no sum tests were run') + } + if(!out.match(/✓.*should return the product of two numbers/)) { + utils.log.warn('no product tests were run') + } + if(!out.match(/browser Android Browser Amazon Kindle Fire HD 8.9 Android 4.0 for url http:\/\/build\.cross\-browser\-tests\-runner\.org:8000\/tests\/functional\/code\/tests\/jasmine\/html\/tests-ok.html did not respond with results/)) { + utils.log.warn('expected Android device to not respond and time out') + } + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/functional/tests/native/test-data-with-errors.json b/tests/functional/tests/native/test-data-with-errors.json new file mode 100644 index 0000000..4d547ea --- /dev/null +++ b/tests/functional/tests/native/test-data-with-errors.json @@ -0,0 +1,174 @@ +{ + "suites": [ + { + "description": "sum", + "specs": [], + "suites": [ + { + "description": "suite 1", + "specs": [ + { + "description": "should return the sum of two numbers", + "duration": 87, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 87 + }, + { + "description": "suite 2", + "specs": [ + { + "description": "should treat 0 as 1", + "duration": 5, + "passed": false, + "skipped": false, + "failures": [ + { + "type": "expect", + "matcherName": "toEqual", + "expected": 3, + "actual": 2, + "message": "Expected 2 to equal 3.", + "trace": { + "stack": "Error: Expected 2 to equal 3.\n at new jasmine.ExpectationResult (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:114:32)\n at matchersClass.toEqual (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1235:29)\n at jasmine.Spec. (http://127.0.0.1:7982/tests/functional/code/tests/jasmine/js/test.js:9:25)\n at jasmine.Block.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1064:17)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Spec.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2376:14)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Suite.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2521:14)", + "message": "Expected 2 to equal 3." + } + } + ] + } + ], + "suites": [], + "passed": 0, + "failed": 1, + "skipped": 0, + "total": 1, + "duration": 5 + } + ], + "passed": 1, + "failed": 1, + "skipped": 0, + "total": 2, + "duration": 92 + }, + { + "description": "mult", + "specs": [], + "suites": [ + { + "description": "suite 1", + "specs": [ + { + "description": "should return the product of two numbers", + "duration": 0, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 0 + }, + { + "description": "suite 2", + "specs": [ + { + "description": "should treat 1 as 0", + "duration": 0, + "passed": false, + "skipped": false, + "failures": [ + { + "type": "expect", + "matcherName": "toEqual", + "expected": 0, + "actual": 2, + "message": "Expected 2 to equal 0.", + "trace": { + "stack": "Error: Expected 2 to equal 0.\n at new jasmine.ExpectationResult (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:114:32)\n at matchersClass.toEqual (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1235:29)\n at jasmine.Spec. (http://127.0.0.1:7982/tests/functional/code/tests/jasmine/js/test.js:22:26)\n at jasmine.Block.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:1064:17)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Spec.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2376:14)\n at jasmine.Queue.next_ (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2096:31)\n at jasmine.Queue.start (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2049:8)\n at jasmine.Suite.execute (https://cdnjs.cloudflare.com/ajax/libs/jasmine/1.3.1/jasmine.js:2521:14)", + "message": "Expected 2 to equal 0." + } + } + ] + } + ], + "suites": [], + "passed": 0, + "failed": 1, + "skipped": 0, + "total": 1, + "duration": 0 + } + ], + "passed": 1, + "failed": 1, + "skipped": 0, + "total": 2, + "duration": 0 + }, + { + "description": "always true", + "specs": [], + "suites": [ + { + "description": "suite 1", + "specs": [ + { + "description": "should say 1 is 1", + "duration": 0, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 0 + }, + { + "description": "suite 2", + "specs": [ + { + "description": "should say 1 is not 0", + "duration": 0, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 0 + } + ], + "passed": 2, + "failed": 0, + "skipped": 0, + "total": 2, + "duration": 0 + } + ], + "passed": 4, + "failed": 2, + "skipped": 0, + "total": 6, + "duration": 92 +} diff --git a/tests/functional/tests/native/test-data-without-errors.json b/tests/functional/tests/native/test-data-without-errors.json new file mode 100644 index 0000000..9f71843 --- /dev/null +++ b/tests/functional/tests/native/test-data-without-errors.json @@ -0,0 +1,45 @@ +{ + "suites": [ + { + "description": "sum", + "specs": [ + { + "description": "should return the sum of two numbers", + "duration": 7, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 7 + }, + { + "description": "mult", + "specs": [ + { + "description": "should return the product of two numbers", + "duration": 0, + "passed": true, + "skipped": false, + "failures": [] + } + ], + "suites": [], + "passed": 1, + "failed": 0, + "skipped": 0, + "total": 1, + "duration": 0 + } + ], + "passed": 2, + "failed": 0, + "skipped": 0, + "total": 2, + "duration": 7 +} diff --git a/tests/functional/tests/native/working.js b/tests/functional/tests/native/working.js new file mode 100644 index 0000000..8885f90 --- /dev/null +++ b/tests/functional/tests/native/working.js @@ -0,0 +1,92 @@ +var + chai = require('chai'), + chaiHttp = require('chai-http'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../lib/core/process').Process, + utils = require('./../testutils') + +chai.use(chaiAsPromised) +chai.use(chaiHttp) + +var + expect = chai.expect, + should = chai.should(), + request = chai.request + +describe('working', function() { + + this.timeout(0) + + it('should work successfully for a valid Jasmine 1.x test configuration and print failed test cases only, if "--errors-only" command line option is provided', function() { + var proc = new Process(), out = '', confName = (process.version > 'v6' ? '1.json' : '1-no-sauce.json') + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--errors-only', + '--config', + 'tests/functional/conf/native/jasmine-1/' + confName + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + + it('should complete all tests specified in a Selenium test configuration', function() { + var proc = new Process(), out = '', host = 'http://build.cross-browser-tests-runner.org:8000', askedStatus = false + return proc.create( + 'node', + utils.nodeProcCoverageArgs('bin/server/server.js', [ + '--native-runner', + '--config', + 'tests/functional/conf/native/selenium/1.json' + ]), { + onstdout: function(stdout) { + out += stdout + if(!stdout.match(/=============== Coverage summary ==========/)) { + console.log(stdout.trim()) + } + if(!askedStatus) { + askedStatus = true + request(host) + .get('/cbtr/status') + .then(res => { + expect(res).to.have.status(200) + expect(res.body).to.deep.equal({ }) + }) + } + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + if(!out.match(/Selenium Test Script: text of #test-message Hi, this is a test page for functional testing of selenium testing with cross\-browser\-tests\-runner native runner/)) { + utils.log.warn('Selenium test did not run') + } + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + } + +}) diff --git a/tests/functional/tests/testem-browserstack.js b/tests/functional/tests/testem-browserstack.js new file mode 100644 index 0000000..95f827d --- /dev/null +++ b/tests/functional/tests/testem-browserstack.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/browserstack') +}) diff --git a/tests/functional/tests/testem-crossbrowsertesting.js b/tests/functional/tests/testem-crossbrowsertesting.js new file mode 100644 index 0000000..e74a1ac --- /dev/null +++ b/tests/functional/tests/testem-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/crossbrowsertesting') +}) diff --git a/tests/functional/tests/testem-saucelabs.js b/tests/functional/tests/testem-saucelabs.js new file mode 100644 index 0000000..0b0d30f --- /dev/null +++ b/tests/functional/tests/testem-saucelabs.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/saucelabs') +}) diff --git a/tests/functional/tests/testem/saucelabs.js b/tests/functional/tests/testem/saucelabs.js index f87f2f0..2ce7b39 100644 --- a/tests/functional/tests/testem/saucelabs.js +++ b/tests/functional/tests/testem/saucelabs.js @@ -37,11 +37,11 @@ describe('SauceLabs', function() { } }) .then(() => { - if(!out.match(/Safari 10.0 \- sum should return the sum of two numbers./)) { - utils.log.warn('Safari 10.0 sum test failed') + if(!out.match(/Safari 10.1 \- sum should return the sum of two numbers./)) { + utils.log.warn('Safari 10.1 sum test failed') } - if(!out.match(/Safari 10.0 \- mult should return the product of two numbers./)) { - utils.log.warn('Safari 10.0 mult test failed') + if(!out.match(/Safari 10.1 \- mult should return the product of two numbers./)) { + utils.log.warn('Safari 10.1 mult test failed') } if(!out.match(/Firefox 43.0 \- sum should return the sum of two numbers./)) { utils.log.warn('Firefox 43.0 sum test failed') diff --git a/tests/functional/tests/utils-browserstack.js b/tests/functional/tests/utils-browserstack.js new file mode 100644 index 0000000..6fab56c --- /dev/null +++ b/tests/functional/tests/utils-browserstack.js @@ -0,0 +1,5 @@ +describe('utils', function() { + require('./utils/conf-browserstack') + require('./utils/settings-browserstack') + require('./utils/quick-start-browserstack') +}) diff --git a/tests/functional/tests/utils-core.js b/tests/functional/tests/utils-core.js new file mode 100644 index 0000000..a28fcd8 --- /dev/null +++ b/tests/functional/tests/utils-core.js @@ -0,0 +1,4 @@ +describe('utils', function() { + require('./utils/settings-core') + require('./utils/quick-start-core') +}) diff --git a/tests/functional/tests/utils-crossbrowsertesting.js b/tests/functional/tests/utils-crossbrowsertesting.js new file mode 100644 index 0000000..b62df63 --- /dev/null +++ b/tests/functional/tests/utils-crossbrowsertesting.js @@ -0,0 +1,5 @@ +describe('utils', function() { + require('./utils/conf-crossbrowsertesting') + require('./utils/settings-crossbrowsertesting') + require('./utils/quick-start-crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils-saucelabs.js b/tests/functional/tests/utils-saucelabs.js new file mode 100644 index 0000000..6715a63 --- /dev/null +++ b/tests/functional/tests/utils-saucelabs.js @@ -0,0 +1,5 @@ +describe('utils', function() { + require('./utils/conf-saucelabs') + require('./utils/settings-saucelabs') + require('./utils/quick-start-saucelabs') +}) diff --git a/tests/functional/tests/utils/conf-browserstack.js b/tests/functional/tests/utils/conf-browserstack.js new file mode 100644 index 0000000..2f62e62 --- /dev/null +++ b/tests/functional/tests/utils/conf-browserstack.js @@ -0,0 +1,3 @@ +describe('conf', function() { + require('./conf/browsers-browserstack') +}) diff --git a/tests/functional/tests/utils/conf-crossbrowsertesting.js b/tests/functional/tests/utils/conf-crossbrowsertesting.js new file mode 100644 index 0000000..beac5f9 --- /dev/null +++ b/tests/functional/tests/utils/conf-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('conf', function() { + require('./conf/browsers-crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils/conf-saucelabs.js b/tests/functional/tests/utils/conf-saucelabs.js new file mode 100644 index 0000000..7f63bd7 --- /dev/null +++ b/tests/functional/tests/utils/conf-saucelabs.js @@ -0,0 +1,3 @@ +describe('conf', function() { + require('./conf/browsers-saucelabs') +}) diff --git a/tests/functional/tests/utils/conf/browsers-browserstack.js b/tests/functional/tests/utils/conf/browsers-browserstack.js new file mode 100644 index 0000000..c42ef11 --- /dev/null +++ b/tests/functional/tests/utils/conf/browsers-browserstack.js @@ -0,0 +1,3 @@ +describe('browsers', function() { + require('./browsers/browserstack') +}) diff --git a/tests/functional/tests/utils/conf/browsers-crossbrowsertesting.js b/tests/functional/tests/utils/conf/browsers-crossbrowsertesting.js new file mode 100644 index 0000000..0325cb6 --- /dev/null +++ b/tests/functional/tests/utils/conf/browsers-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('browsers', function() { + require('./browsers/crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils/conf/browsers-saucelabs.js b/tests/functional/tests/utils/conf/browsers-saucelabs.js new file mode 100644 index 0000000..9ed5e5b --- /dev/null +++ b/tests/functional/tests/utils/conf/browsers-saucelabs.js @@ -0,0 +1,3 @@ +describe('browsers', function() { + require('./browsers/saucelabs') +}) diff --git a/tests/functional/tests/utils/quick-start-browserstack.js b/tests/functional/tests/utils/quick-start-browserstack.js new file mode 100644 index 0000000..b65bee3 --- /dev/null +++ b/tests/functional/tests/utils/quick-start-browserstack.js @@ -0,0 +1,3 @@ +describe('quick-start.js', function() { + require('./quick-start/browserstack.js') +}) diff --git a/tests/functional/tests/utils/quick-start-core.js b/tests/functional/tests/utils/quick-start-core.js new file mode 100644 index 0000000..b0f3e5d --- /dev/null +++ b/tests/functional/tests/utils/quick-start-core.js @@ -0,0 +1,3 @@ +describe('quick-start.js', function() { + require('./quick-start/generic.js') +}) diff --git a/tests/functional/tests/utils/quick-start-crossbrowsertesting.js b/tests/functional/tests/utils/quick-start-crossbrowsertesting.js new file mode 100644 index 0000000..4a60a30 --- /dev/null +++ b/tests/functional/tests/utils/quick-start-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('quick-start.js', function() { + require('./quick-start/crossbrowsertesting.js') +}) diff --git a/tests/functional/tests/utils/quick-start-saucelabs.js b/tests/functional/tests/utils/quick-start-saucelabs.js new file mode 100644 index 0000000..2ce1ccf --- /dev/null +++ b/tests/functional/tests/utils/quick-start-saucelabs.js @@ -0,0 +1,3 @@ +describe('quick-start.js', function() { + require('./quick-start/saucelabs.js') +}) diff --git a/tests/functional/tests/utils/quick-start.js b/tests/functional/tests/utils/quick-start.js index 5f8d12a..de9a507 100644 --- a/tests/functional/tests/utils/quick-start.js +++ b/tests/functional/tests/utils/quick-start.js @@ -1,199 +1,6 @@ -var - path = require('path'), - Bluebird = require('bluebird'), - fs = Bluebird.promisifyAll(require('fs')), - chai = require('chai'), - chaiAsPromised = require('chai-as-promised'), - Process = require('./../../../../lib/core/process').Process, - utils = require('./../testutils') - -chai.use(chaiAsPromised) - -var - expect = chai.expect, - should = chai.should() - describe('quick-start.js', function() { - - this.timeout(0) - - it('should fail if an unsupported command line option is provided', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', ['--unknown']), { - onstderr: function(data) { - out += data - } - }) - .then(() => { - expect(out).to.contain('Unknown option: --unknown') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should fail if any of "--platform" and "--runner" command line options are not provided', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js'), { - onstderr: function(stderr) { - out += stderr - } - }) - .then(() => { - expect(out).to.contain('No platform specified') - expect(out).to.contain('No runner specified') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should fail if an unsupported "--platform" and an unsupported "--runner" command line options are provided', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ - '--platform', 'abc', '--runner', 'def' - ]), { - onstderr: function(stderr) { - out += stderr - } - }) - .then(() => { - expect(out).to.contain('Unknown platform: abc') - expect(out).to.contain('Unknown runner: def') - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should print help if "--help" command line option is provided', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', ['--help']), { - onstdout: function(stdout) { - out += stdout - } - }) - .then(() => { - expect(out).to.contain("\nquick-start.js [--help|-h] [--platform|-p ] [--runner|-r ]\n\nOptions:\n help print this help\n platform browserstack|saucelabs|crossbrowsertesting\n runner testem\n") - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully create cbtr.json and testem.json for BrowserStack platform', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ - '--platform', 'browserstack', '--runner', 'testem' - ]), { - onstdout: function(stdout) { - out += stdout - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('Updating browsers for platform: browserstack') - expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for browserstack') - expect(out).to.contain('Creating testem config for browserstack platform using cross-browser-tests-runner settings') - expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') - return true - }) - .then(() => { - return Bluebird.all([ - fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), - fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully create cbtr.json and testem.json for SauceLabs platform', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ - '--platform', 'saucelabs', '--runner', 'testem' - ]), { - onstdout: function(stdout) { - out += stdout - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('Updating browsers for platform: saucelabs') - expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for saucelabs') - expect(out).to.contain('Creating testem config for saucelabs platform using cross-browser-tests-runner settings') - expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') - return true - }) - .then(() => { - return Bluebird.all([ - fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), - fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully create cbtr.json and testem.json for CrossBrowserTesting platform', function() { - var proc = new Process(), out = '' - return proc.create('node', - utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ - '--platform', 'crossbrowsertesting', '--runner', 'testem' - ]), { - onstdout: function(stdout) { - out += stdout - }, - onstderr: function(stderr) { - utils.errorWithoutCovLines(stderr) - } - }) - .then(() => { - expect(out).to.contain('Updating browsers for platform: crossbrowsertesting') - expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for crossbrowsertesting') - expect(out).to.contain('Creating testem config for crossbrowsertesting platform using cross-browser-tests-runner settings') - expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') - return true - }) - .then(() => { - return Bluebird.all([ - fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), - fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - + require('./quick-start/generic.js') + require('./quick-start/browserstack.js') + require('./quick-start/saucelabs.js') + require('./quick-start/crossbrowsertesting.js') }) diff --git a/tests/functional/tests/utils/quick-start/browserstack.js b/tests/functional/tests/utils/quick-start/browserstack.js new file mode 100644 index 0000000..ba940e3 --- /dev/null +++ b/tests/functional/tests/utils/quick-start/browserstack.js @@ -0,0 +1,53 @@ +var + path = require('path'), + Bluebird = require('bluebird'), + fs = Bluebird.promisifyAll(require('fs')), + chai = require('chai'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../../lib/core/process').Process, + utils = require('./../../testutils') + +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('BrowserStack', function() { + + this.timeout(0) + + it('should successfully create cbtr.json and testem.json for BrowserStack platform', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ + '--platform', 'browserstack', '--runner', 'testem' + ]), { + onstdout: function(stdout) { + out += stdout + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('Updating browsers for platform: browserstack') + expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for browserstack') + expect(out).to.contain('Creating testem config for browserstack platform using cross-browser-tests-runner settings') + expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') + return true + }) + .then(() => { + return Bluebird.all([ + fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), + fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/functional/tests/utils/quick-start/crossbrowsertesting.js b/tests/functional/tests/utils/quick-start/crossbrowsertesting.js new file mode 100644 index 0000000..fab1758 --- /dev/null +++ b/tests/functional/tests/utils/quick-start/crossbrowsertesting.js @@ -0,0 +1,53 @@ +var + path = require('path'), + Bluebird = require('bluebird'), + fs = Bluebird.promisifyAll(require('fs')), + chai = require('chai'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../../lib/core/process').Process, + utils = require('./../../testutils') + +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('CrossBrowserTesting', function() { + + this.timeout(0) + + it('should successfully create cbtr.json and testem.json for CrossBrowserTesting platform', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ + '--platform', 'crossbrowsertesting', '--runner', 'testem' + ]), { + onstdout: function(stdout) { + out += stdout + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('Updating browsers for platform: crossbrowsertesting') + expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for crossbrowsertesting') + expect(out).to.contain('Creating testem config for crossbrowsertesting platform using cross-browser-tests-runner settings') + expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') + return true + }) + .then(() => { + return Bluebird.all([ + fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), + fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/functional/tests/utils/quick-start/generic.js b/tests/functional/tests/utils/quick-start/generic.js new file mode 100644 index 0000000..95357c5 --- /dev/null +++ b/tests/functional/tests/utils/quick-start/generic.js @@ -0,0 +1,97 @@ +var + chai = require('chai'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../../lib/core/process').Process, + utils = require('./../../testutils') + +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('generic', function() { + + this.timeout(0) + + it('should fail if an unsupported command line option is provided', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', ['--unknown']), { + onstderr: function(data) { + out += data + } + }) + .then(() => { + expect(out).to.contain('Unknown option: --unknown') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should fail if any of "--platform" and "--runner" command line options are not provided', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js'), { + onstderr: function(stderr) { + out += stderr + } + }) + .then(() => { + expect(out).to.contain('No platform specified') + expect(out).to.contain('No runner specified') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should fail if an unsupported "--platform" and an unsupported "--runner" command line options are provided', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ + '--platform', 'abc', '--runner', 'def' + ]), { + onstderr: function(stderr) { + out += stderr + } + }) + .then(() => { + expect(out).to.contain('Unknown platform: abc') + expect(out).to.contain('Unknown runner: def') + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should print help if "--help" command line option is provided', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', ['--help']), { + onstdout: function(stdout) { + out += stdout + } + }) + .then(() => { + expect(out).to.contain("\nquick-start.js [--help|-h] [--platform|-p ] [--runner|-r ]\n\nOptions:\n help print this help\n platform browserstack|saucelabs|crossbrowsertesting\n runner testem\n") + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/functional/tests/utils/quick-start/saucelabs.js b/tests/functional/tests/utils/quick-start/saucelabs.js new file mode 100644 index 0000000..2e6ce1b --- /dev/null +++ b/tests/functional/tests/utils/quick-start/saucelabs.js @@ -0,0 +1,53 @@ +var + path = require('path'), + Bluebird = require('bluebird'), + fs = Bluebird.promisifyAll(require('fs')), + chai = require('chai'), + chaiAsPromised = require('chai-as-promised'), + Process = require('./../../../../../lib/core/process').Process, + utils = require('./../../testutils') + +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('SauceLabs', function() { + + this.timeout(0) + + it('should successfully create cbtr.json and testem.json for SauceLabs platform', function() { + var proc = new Process(), out = '' + return proc.create('node', + utils.nodeProcCoverageArgs('bin/utils/quick-start.js', [ + '--platform', 'saucelabs', '--runner', 'testem' + ]), { + onstdout: function(stdout) { + out += stdout + }, + onstderr: function(stderr) { + utils.errorWithoutCovLines(stderr) + } + }) + .then(() => { + expect(out).to.contain('Updating browsers for platform: saucelabs') + expect(out).to.contain('Creating global cross-browser-tests-runner settings from sample browsers for saucelabs') + expect(out).to.contain('Creating testem config for saucelabs platform using cross-browser-tests-runner settings') + expect(out).to.contain('Done! Start the server (./node_modules/.bin/cbtr-server) and then execute your testem tests after specifying the test files and other required details in the runner config') + return true + }) + .then(() => { + return Bluebird.all([ + fs.unlinkAsync(path.resolve(process.cwd(), 'testem.json')), + fs.unlinkAsync(path.resolve(process.cwd(), 'cbtr.json')) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/functional/tests/utils/settings-browserstack.js b/tests/functional/tests/utils/settings-browserstack.js new file mode 100644 index 0000000..266c7e0 --- /dev/null +++ b/tests/functional/tests/utils/settings-browserstack.js @@ -0,0 +1,4 @@ +describe('settings', function() { + require('./settings/cbtr-browserstack') + require('./settings/testem-browserstack') +}) diff --git a/tests/functional/tests/utils/settings-core.js b/tests/functional/tests/utils/settings-core.js new file mode 100644 index 0000000..6f70537 --- /dev/null +++ b/tests/functional/tests/utils/settings-core.js @@ -0,0 +1,3 @@ +describe('settings', function() { + require('./settings/cbtr-core') +}) diff --git a/tests/functional/tests/utils/settings-crossbrowsertesting.js b/tests/functional/tests/utils/settings-crossbrowsertesting.js new file mode 100644 index 0000000..c49f326 --- /dev/null +++ b/tests/functional/tests/utils/settings-crossbrowsertesting.js @@ -0,0 +1,4 @@ +describe('settings', function() { + require('./settings/cbtr-crossbrowsertesting') + require('./settings/testem-crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils/settings-saucelabs.js b/tests/functional/tests/utils/settings-saucelabs.js new file mode 100644 index 0000000..469826f --- /dev/null +++ b/tests/functional/tests/utils/settings-saucelabs.js @@ -0,0 +1,4 @@ +describe('settings', function() { + require('./settings/cbtr-saucelabs') + require('./settings/testem-saucelabs') +}) diff --git a/tests/functional/tests/utils/settings.js b/tests/functional/tests/utils/settings.js index f1b5c3f..b75d971 100644 --- a/tests/functional/tests/utils/settings.js +++ b/tests/functional/tests/utils/settings.js @@ -1,6 +1,4 @@ describe('settings', function() { - describe('cbtr.js', function() { - require('./settings/cbtr') - }) + require('./settings/cbtr') require('./settings/testem') }) diff --git a/tests/functional/tests/utils/settings/cbtr-browserstack.js b/tests/functional/tests/utils/settings/cbtr-browserstack.js new file mode 100644 index 0000000..3e21013 --- /dev/null +++ b/tests/functional/tests/utils/settings/cbtr-browserstack.js @@ -0,0 +1,3 @@ +describe('cbtr.js', function() { + require('./cbtr/browserstack') +}) diff --git a/tests/functional/tests/utils/settings/cbtr-core.js b/tests/functional/tests/utils/settings/cbtr-core.js new file mode 100644 index 0000000..0a9620f --- /dev/null +++ b/tests/functional/tests/utils/settings/cbtr-core.js @@ -0,0 +1,3 @@ +describe('cbtr.js', function() { + require('./cbtr/generic') +}) diff --git a/tests/functional/tests/utils/settings/cbtr-crossbrowsertesting.js b/tests/functional/tests/utils/settings/cbtr-crossbrowsertesting.js new file mode 100644 index 0000000..985ee71 --- /dev/null +++ b/tests/functional/tests/utils/settings/cbtr-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('cbtr.js', function() { + require('./cbtr/crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils/settings/cbtr-saucelabs.js b/tests/functional/tests/utils/settings/cbtr-saucelabs.js new file mode 100644 index 0000000..1d2491d --- /dev/null +++ b/tests/functional/tests/utils/settings/cbtr-saucelabs.js @@ -0,0 +1,3 @@ +describe('cbtr.js', function() { + require('./cbtr/saucelabs') +}) diff --git a/tests/functional/tests/utils/settings/cbtr/crossbrowsertesting.js b/tests/functional/tests/utils/settings/cbtr/crossbrowsertesting.js index 95a92ca..34b2826 100644 --- a/tests/functional/tests/utils/settings/cbtr/crossbrowsertesting.js +++ b/tests/functional/tests/utils/settings/cbtr/crossbrowsertesting.js @@ -535,7 +535,7 @@ describe('CrossBrowserTesting', function() { } }) .then(() => { - expect(out).to.contain('Unsupported property "osVersion" with value "abc" for the browser/platform combination {"TestType":"Selenium","os":"Android","osVersion":"abc","browser":"Chrome Mobile","browserVersion":"59.0","device":"Android Nexus 9"}') + expect(out).to.contain('Unsupported property "osVersion" with value "abc" for the browser/platform combination {"TestType":"Selenium","os":"Android","osVersion":"abc","browser":"Chrome Mobile","browserVersion":"33.0","device":"Android Galaxy S4"}') return true }) .catch(err => { diff --git a/tests/functional/tests/utils/settings/testem-browserstack.js b/tests/functional/tests/utils/settings/testem-browserstack.js new file mode 100644 index 0000000..95f827d --- /dev/null +++ b/tests/functional/tests/utils/settings/testem-browserstack.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/browserstack') +}) diff --git a/tests/functional/tests/utils/settings/testem-crossbrowsertesting.js b/tests/functional/tests/utils/settings/testem-crossbrowsertesting.js new file mode 100644 index 0000000..e74a1ac --- /dev/null +++ b/tests/functional/tests/utils/settings/testem-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/crossbrowsertesting') +}) diff --git a/tests/functional/tests/utils/settings/testem-saucelabs.js b/tests/functional/tests/utils/settings/testem-saucelabs.js new file mode 100644 index 0000000..0b0d30f --- /dev/null +++ b/tests/functional/tests/utils/settings/testem-saucelabs.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/saucelabs') +}) diff --git a/tests/functional/utils-browserstack.js b/tests/functional/utils-browserstack.js new file mode 100644 index 0000000..8b1c9f1 --- /dev/null +++ b/tests/functional/utils-browserstack.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/utils-browserstack') +}) diff --git a/tests/functional/utils-crossbrowsertesting.js b/tests/functional/utils-crossbrowsertesting.js new file mode 100644 index 0000000..1b27245 --- /dev/null +++ b/tests/functional/utils-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/utils-crossbrowsertesting') +}) diff --git a/tests/functional/utils-saucelabs.js b/tests/functional/utils-saucelabs.js new file mode 100644 index 0000000..ab5c5eb --- /dev/null +++ b/tests/functional/utils-saucelabs.js @@ -0,0 +1,3 @@ +describe('Functional Tests', function() { + require('./tests/utils-saucelabs') +}) diff --git a/tests/integration/browserstack.js b/tests/integration/browserstack.js new file mode 100644 index 0000000..8c2a6b9 --- /dev/null +++ b/tests/integration/browserstack.js @@ -0,0 +1,4 @@ +describe('Integration Tests', function() { + require('./tests/server-browserstack') + require('./tests/hooks-browserstack') +}) diff --git a/tests/integration/core.js b/tests/integration/core.js new file mode 100644 index 0000000..cc7c2f6 --- /dev/null +++ b/tests/integration/core.js @@ -0,0 +1,3 @@ +describe('Integration Tests', function() { + require('./tests/server-core') +}) diff --git a/tests/integration/crossbrowsertesting.js b/tests/integration/crossbrowsertesting.js new file mode 100644 index 0000000..548b7b9 --- /dev/null +++ b/tests/integration/crossbrowsertesting.js @@ -0,0 +1,4 @@ +describe('Integration Tests', function() { + require('./tests/server-crossbrowsertesting') + require('./tests/hooks-crossbrowsertesting') +}) diff --git a/tests/integration/saucelabs.js b/tests/integration/saucelabs.js new file mode 100644 index 0000000..8bd1dae --- /dev/null +++ b/tests/integration/saucelabs.js @@ -0,0 +1,4 @@ +describe('Integration Tests', function() { + require('./tests/server-saucelabs') + require('./tests/hooks-saucelabs') +}) diff --git a/tests/integration/tests/hooks-browserstack.js b/tests/integration/tests/hooks-browserstack.js new file mode 100644 index 0000000..f776fe1 --- /dev/null +++ b/tests/integration/tests/hooks-browserstack.js @@ -0,0 +1,3 @@ +describe('Hooks', function() { + require('./hooks/testem-browserstack') +}) diff --git a/tests/integration/tests/hooks-crossbrowsertesting.js b/tests/integration/tests/hooks-crossbrowsertesting.js new file mode 100644 index 0000000..5ecf857 --- /dev/null +++ b/tests/integration/tests/hooks-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Hooks', function() { + require('./hooks/testem-crossbrowsertesting') +}) diff --git a/tests/integration/tests/hooks-saucelabs.js b/tests/integration/tests/hooks-saucelabs.js new file mode 100644 index 0000000..3a60a39 --- /dev/null +++ b/tests/integration/tests/hooks-saucelabs.js @@ -0,0 +1,3 @@ +describe('Hooks', function() { + require('./hooks/testem-saucelabs') +}) diff --git a/tests/integration/tests/hooks/testem-browserstack.js b/tests/integration/tests/hooks/testem-browserstack.js new file mode 100644 index 0000000..95f827d --- /dev/null +++ b/tests/integration/tests/hooks/testem-browserstack.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/browserstack') +}) diff --git a/tests/integration/tests/hooks/testem-crossbrowsertesting.js b/tests/integration/tests/hooks/testem-crossbrowsertesting.js new file mode 100644 index 0000000..e74a1ac --- /dev/null +++ b/tests/integration/tests/hooks/testem-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/crossbrowsertesting') +}) diff --git a/tests/integration/tests/hooks/testem-saucelabs.js b/tests/integration/tests/hooks/testem-saucelabs.js new file mode 100644 index 0000000..0b0d30f --- /dev/null +++ b/tests/integration/tests/hooks/testem-saucelabs.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/saucelabs') +}) diff --git a/tests/integration/tests/server-browserstack.js b/tests/integration/tests/server-browserstack.js new file mode 100644 index 0000000..1fba9bf --- /dev/null +++ b/tests/integration/tests/server-browserstack.js @@ -0,0 +1,3 @@ +describe('Server', function() { + require('./server/runners-browserstack') +}) diff --git a/tests/integration/tests/server-core.js b/tests/integration/tests/server-core.js new file mode 100644 index 0000000..05b0bfb --- /dev/null +++ b/tests/integration/tests/server-core.js @@ -0,0 +1,5 @@ +describe('Server', function() { + require('./server/main') + require('./server/runners-core') + require('./server/native') +}) diff --git a/tests/integration/tests/server-crossbrowsertesting.js b/tests/integration/tests/server-crossbrowsertesting.js new file mode 100644 index 0000000..4e0f94a --- /dev/null +++ b/tests/integration/tests/server-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Server', function() { + require('./server/runners-crossbrowsertesting') +}) diff --git a/tests/integration/tests/server-saucelabs.js b/tests/integration/tests/server-saucelabs.js new file mode 100644 index 0000000..009ef78 --- /dev/null +++ b/tests/integration/tests/server-saucelabs.js @@ -0,0 +1,3 @@ +describe('Server', function() { + require('./server/runners-saucelabs') +}) diff --git a/tests/integration/tests/server/runners-browserstack.js b/tests/integration/tests/server/runners-browserstack.js new file mode 100644 index 0000000..ee864fc --- /dev/null +++ b/tests/integration/tests/server/runners-browserstack.js @@ -0,0 +1,3 @@ +describe('/runs', function() { + require('./runners/testem-browserstack') +}) diff --git a/tests/integration/tests/server/runners-core.js b/tests/integration/tests/server/runners-core.js new file mode 100644 index 0000000..d9329d9 --- /dev/null +++ b/tests/integration/tests/server/runners-core.js @@ -0,0 +1,3 @@ +describe('/runs', function() { + require('./runners/testem-core') +}) diff --git a/tests/integration/tests/server/runners-crossbrowsertesting.js b/tests/integration/tests/server/runners-crossbrowsertesting.js new file mode 100644 index 0000000..d250134 --- /dev/null +++ b/tests/integration/tests/server/runners-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('/runs', function() { + require('./runners/testem-crossbrowsertesting') +}) diff --git a/tests/integration/tests/server/runners-saucelabs.js b/tests/integration/tests/server/runners-saucelabs.js new file mode 100644 index 0000000..33feccd --- /dev/null +++ b/tests/integration/tests/server/runners-saucelabs.js @@ -0,0 +1,3 @@ +describe('/runs', function() { + require('./runners/testem-saucelabs') +}) diff --git a/tests/integration/tests/server/runners/testem-browserstack.js b/tests/integration/tests/server/runners/testem-browserstack.js new file mode 100644 index 0000000..95f827d --- /dev/null +++ b/tests/integration/tests/server/runners/testem-browserstack.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/browserstack') +}) diff --git a/tests/integration/tests/server/runners/testem-core.js b/tests/integration/tests/server/runners/testem-core.js new file mode 100644 index 0000000..f1f4b77 --- /dev/null +++ b/tests/integration/tests/server/runners/testem-core.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/generic') +}) diff --git a/tests/integration/tests/server/runners/testem-crossbrowsertesting.js b/tests/integration/tests/server/runners/testem-crossbrowsertesting.js new file mode 100644 index 0000000..e74a1ac --- /dev/null +++ b/tests/integration/tests/server/runners/testem-crossbrowsertesting.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/crossbrowsertesting') +}) diff --git a/tests/integration/tests/server/runners/testem-saucelabs.js b/tests/integration/tests/server/runners/testem-saucelabs.js new file mode 100644 index 0000000..0b0d30f --- /dev/null +++ b/tests/integration/tests/server/runners/testem-saucelabs.js @@ -0,0 +1,3 @@ +describe('Testem', function() { + require('./testem/saucelabs') +}) diff --git a/tests/unit/browserstack-platform-close.js b/tests/unit/browserstack-platform-close.js new file mode 100644 index 0000000..215f341 --- /dev/null +++ b/tests/unit/browserstack-platform-close.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-close') +}) diff --git a/tests/unit/browserstack-platform-job.js b/tests/unit/browserstack-platform-job.js new file mode 100644 index 0000000..335ee0d --- /dev/null +++ b/tests/unit/browserstack-platform-job.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-job') +}) diff --git a/tests/unit/browserstack-platform-open.js b/tests/unit/browserstack-platform-open.js new file mode 100644 index 0000000..66765a2 --- /dev/null +++ b/tests/unit/browserstack-platform-open.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-open') +}) diff --git a/tests/unit/browserstack-platform-scriptjob.js b/tests/unit/browserstack-platform-scriptjob.js new file mode 100644 index 0000000..0aaaecf --- /dev/null +++ b/tests/unit/browserstack-platform-scriptjob.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-scriptjob') +}) diff --git a/tests/unit/browserstack-platform-status.js b/tests/unit/browserstack-platform-status.js new file mode 100644 index 0000000..d207fb0 --- /dev/null +++ b/tests/unit/browserstack-platform-status.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-status') +}) diff --git a/tests/unit/browserstack-platform-stop.js b/tests/unit/browserstack-platform-stop.js new file mode 100644 index 0000000..c86e6a7 --- /dev/null +++ b/tests/unit/browserstack-platform-stop.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/browserstack-platform-stop') +}) diff --git a/tests/unit/crossbrowsertesting-platform-close.js b/tests/unit/crossbrowsertesting-platform-close.js new file mode 100644 index 0000000..e326f41 --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-close.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-close') +}) diff --git a/tests/unit/crossbrowsertesting-platform-job.js b/tests/unit/crossbrowsertesting-platform-job.js new file mode 100644 index 0000000..07d8a85 --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-job.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-job') +}) diff --git a/tests/unit/crossbrowsertesting-platform-open.js b/tests/unit/crossbrowsertesting-platform-open.js new file mode 100644 index 0000000..56a82a8 --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-open.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-open') +}) diff --git a/tests/unit/crossbrowsertesting-platform-scriptjob.js b/tests/unit/crossbrowsertesting-platform-scriptjob.js new file mode 100644 index 0000000..1b1b742 --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-scriptjob.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-scriptjob') +}) diff --git a/tests/unit/crossbrowsertesting-platform-status.js b/tests/unit/crossbrowsertesting-platform-status.js new file mode 100644 index 0000000..616f318 --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-status.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-status') +}) diff --git a/tests/unit/crossbrowsertesting-platform-stop.js b/tests/unit/crossbrowsertesting-platform-stop.js new file mode 100644 index 0000000..33875cf --- /dev/null +++ b/tests/unit/crossbrowsertesting-platform-stop.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/crossbrowsertesting-platform-stop') +}) diff --git a/tests/unit/saucelabs-platform-close.js b/tests/unit/saucelabs-platform-close.js new file mode 100644 index 0000000..146be81 --- /dev/null +++ b/tests/unit/saucelabs-platform-close.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-close') +}) diff --git a/tests/unit/saucelabs-platform-job.js b/tests/unit/saucelabs-platform-job.js new file mode 100644 index 0000000..d31570d --- /dev/null +++ b/tests/unit/saucelabs-platform-job.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-job') +}) diff --git a/tests/unit/saucelabs-platform-open.js b/tests/unit/saucelabs-platform-open.js new file mode 100644 index 0000000..ba12d6f --- /dev/null +++ b/tests/unit/saucelabs-platform-open.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-open') +}) diff --git a/tests/unit/saucelabs-platform-scriptjob.js b/tests/unit/saucelabs-platform-scriptjob.js new file mode 100644 index 0000000..7ff0ffa --- /dev/null +++ b/tests/unit/saucelabs-platform-scriptjob.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-scriptjob') +}) diff --git a/tests/unit/saucelabs-platform-status.js b/tests/unit/saucelabs-platform-status.js new file mode 100644 index 0000000..e3f1da4 --- /dev/null +++ b/tests/unit/saucelabs-platform-status.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-status') +}) diff --git a/tests/unit/saucelabs-platform-stop.js b/tests/unit/saucelabs-platform-stop.js new file mode 100644 index 0000000..11d12bc --- /dev/null +++ b/tests/unit/saucelabs-platform-stop.js @@ -0,0 +1,5 @@ +'use strict' + +describe('Unit Tests', function() { + require('./tests/saucelabs-platform-stop') +}) diff --git a/tests/unit/tests/browserstack-platform-close.js b/tests/unit/tests/browserstack-platform-close.js new file mode 100644 index 0000000..5bd4410 --- /dev/null +++ b/tests/unit/tests/browserstack-platform-close.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-close') +}) diff --git a/tests/unit/tests/browserstack-platform-job.js b/tests/unit/tests/browserstack-platform-job.js new file mode 100644 index 0000000..22e223f --- /dev/null +++ b/tests/unit/tests/browserstack-platform-job.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-job') +}) diff --git a/tests/unit/tests/browserstack-platform-open.js b/tests/unit/tests/browserstack-platform-open.js new file mode 100644 index 0000000..2a5a484 --- /dev/null +++ b/tests/unit/tests/browserstack-platform-open.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-open') +}) diff --git a/tests/unit/tests/browserstack-platform-scriptjob.js b/tests/unit/tests/browserstack-platform-scriptjob.js new file mode 100644 index 0000000..c913b52 --- /dev/null +++ b/tests/unit/tests/browserstack-platform-scriptjob.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-scriptjob') +}) diff --git a/tests/unit/tests/browserstack-platform-status.js b/tests/unit/tests/browserstack-platform-status.js new file mode 100644 index 0000000..f170635 --- /dev/null +++ b/tests/unit/tests/browserstack-platform-status.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-status') +}) diff --git a/tests/unit/tests/browserstack-platform-stop.js b/tests/unit/tests/browserstack-platform-stop.js new file mode 100644 index 0000000..a4d616a --- /dev/null +++ b/tests/unit/tests/browserstack-platform-stop.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/browserstack-platform-stop') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-close.js b/tests/unit/tests/crossbrowsertesting-platform-close.js new file mode 100644 index 0000000..2e01c0b --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-close.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-close') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-job.js b/tests/unit/tests/crossbrowsertesting-platform-job.js new file mode 100644 index 0000000..73b66d7 --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-job.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-job') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-open.js b/tests/unit/tests/crossbrowsertesting-platform-open.js new file mode 100644 index 0000000..2165420 --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-open.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-open') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-scriptjob.js b/tests/unit/tests/crossbrowsertesting-platform-scriptjob.js new file mode 100644 index 0000000..010e38e --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-scriptjob.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-scriptjob') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-status.js b/tests/unit/tests/crossbrowsertesting-platform-status.js new file mode 100644 index 0000000..ac07eb1 --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-status.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-status') +}) diff --git a/tests/unit/tests/crossbrowsertesting-platform-stop.js b/tests/unit/tests/crossbrowsertesting-platform-stop.js new file mode 100644 index 0000000..548f8e2 --- /dev/null +++ b/tests/unit/tests/crossbrowsertesting-platform-stop.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/crossbrowsertesting-platform-stop') +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-close.js b/tests/unit/tests/platforms/browserstack-platform-close.js new file mode 100644 index 0000000..386f605 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-close.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/close') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-job.js b/tests/unit/tests/platforms/browserstack-platform-job.js new file mode 100644 index 0000000..2764278 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-job.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/job') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-open.js b/tests/unit/tests/platforms/browserstack-platform-open.js new file mode 100644 index 0000000..c27b9a2 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-open.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/open') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-scriptjob.js b/tests/unit/tests/platforms/browserstack-platform-scriptjob.js new file mode 100644 index 0000000..739575d --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-scriptjob.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/scriptjob') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-status.js b/tests/unit/tests/platforms/browserstack-platform-status.js new file mode 100644 index 0000000..b1504f6 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-status.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/status') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack-platform-stop.js b/tests/unit/tests/platforms/browserstack-platform-stop.js new file mode 100644 index 0000000..16b245c --- /dev/null +++ b/tests/unit/tests/platforms/browserstack-platform-stop.js @@ -0,0 +1,5 @@ +describe('BrowserStack', function() { + describe('Platform', function() { + require('./browserstack/platform/stop') + }) +}) diff --git a/tests/unit/tests/platforms/browserstack/platform.js b/tests/unit/tests/platforms/browserstack/platform.js index e974167..f1f981f 100644 --- a/tests/unit/tests/platforms/browserstack/platform.js +++ b/tests/unit/tests/platforms/browserstack/platform.js @@ -1,1981 +1,8 @@ -'use strict'; - -var - Bluebird = require('bluebird'), - retry = require('p-retry'), - fs = Bluebird.promisifyAll(require('fs')), - chai = require('chai'), - spies = require('chai-spies'), - chaiAsPromised = require('chai-as-promised'), - Env = require('./../../../../../lib/core/env').Env, - platform = require('./../../../../../lib/platforms/browserstack/platform'), - Platform = platform.Platform, - Tunnel = require('./../../../../../lib/platforms/browserstack/tunnel').Tunnel, - Manager = require('./../../../../../lib/platforms/browserstack/manager').Manager, - BinaryVars = require('./../../../../../lib/platforms/browserstack/tunnel/binary').BinaryVars, - utils = require('./utils') - -chai.use(spies) -chai.use(chaiAsPromised) - -var - expect = chai.expect, - should = chai.should() - -function checkRun(run) { - expect(run).to.not.be.undefined - expect(run.id).to.not.be.undefined - expect(run.id).to.be.a('string') -} - -const - script = (driver, webdriver) => { - return driver.getTitle() - .then(function(title) { - utils.log.debug(title) - return true - }) - }, - badScript = (driver, webdriver) => { - return driver.findElement({id : 'xyz'}) - } - describe('Platform', function() { - - describe('open', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete if no capabilities are provided', function() { - return platform.open() - .should.be.fulfilled - }) - - it('should fail in case capabilities input is not an array', function() { - function tester() { - platform.open({ local: true }) - } - expect(tester).to.throw('capabilitiesArr.forEach is not a function') - }) - - it('should fail if an invalid/unsupported capability key is provided', function() { - function tester() { - platform.open([{ - abc: 123 - }]) - } - expect(tester).to.throw('option abc is not allowed') - }) - - it('should open the platform by creating a tunnel without an identifier if "local" capability is provided', function() { - return platform.open([{ - local: true - }]) - .then(() => { - platform.stopMonitoring = true - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - function waitForTunnel() { - const check = () => { - return Manager.withoutId() - .then(procs => { - if(procs.length) { - utils.log.debug('Got a tunnel process') - return true - } - utils.log.debug('No tunnels running yet') - throw new Error('no tunnels yet') - }) - }, - minTimeout = 2000, factor = 1, max = 60 - return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) - } - - it('should open the platform by creating a tunnel process if "local" capability was provided, and then monitor the tunnel process availability and restart it if it dies', function() { - platform.stopMonitoring = false - platform.tunnels = [ ] - return platform.open([{ - local: true - }]) - .then(() => { - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - utils.stopProc(platform.tunnels[0].process.pid) - return true - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .then(() => { - return waitForTunnel() - }) - .then(() => { - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should open the platform by creating multiple tunnel processes with identifiers if multiple "local" and "localIdentifier" capabilities were provided', function() { - return platform.open([{ - local: true, - localIdentifier: 'my-id-1' - }, { - local: true, - localIdentifier: 'my-id-2' - }]) - .then(() => { - platform.stopMonitoring = true - return Manager.withId() - }) - .then(procs => { - if(2 !== procs.length) { - utils.log.warn('expected 2 tunnels to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('run', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.run(undefined, undefined, undefined) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if required browser keys are not provided', function() { - return platform.run('http://www.piaxis.tech', { }, { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if an unsupported browser key is provided', function() { - return platform.run('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '21.0' - }, { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a test job if an unsupported capabilities key is provided', function() { - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '21.0' - }, { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of a test job if a valid remote url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '52.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'platform-run-1', - screenshots: false, - video: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job for native runner case if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '41.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'platform-run-1', - screenshots: false, - video: true, - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job for native runner case if a valid local url ending in ?, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '33.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'platform-run-1', - screenshots: false, - video: true, - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.runMultiple(undefined, undefined, undefined) - .should.be.rejectedWith('no browsers specified for createMultiple') - }) - - it('should fail to create a run of test jobs if required keys are not provided in even one of the input browsers', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'Windows' - }], { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of test jobs if an unsupported key is provided in even one of the input browsers', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0' - }, { - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0', - abc: 123 - }], { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of tests jobs if an unsupported capabilities key is provided', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0' - }], { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of test jobs if a valid remote url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '31.0' - }, { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Chrome', - browserVersion: '45.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs if a valid local url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '41.0' - }, { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '52.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs for native runner case if a valid local url containing query parameters, and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Chrome', - browserVersion: '50.0' - }, { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '37.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - if(process.version > 'v6') { - - describe('runScript', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.runScript(undefined, undefined, undefined, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if required browser keys are not provided', function() { - return platform.runScript('http://www.piaxis.tech', { }, { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if unsupported browser key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0' - }, { }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if unsupported capabilities key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0' - }, { - abc: 123 - }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if script parameter is not a function', function() { - expect(()=>{platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - })}) - .to.throw('invalid script') - }) - - it('should create a run of a script session if a valid remote url and valid values for all mandatary parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '31.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session and tolerate the error thrown by the script if a valid remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8.1', - browser: 'Chrome', - browserVersion: '48.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session if a valid local url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '35.0' - }, { - timeout: 60, - build: build.build, - test: build.test, - project: build.project, - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - video: true - }, - script) - .then(run => { - checkRun(run) - return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message.match(/is set to true but local testing through BrowserStack is not connected/)) { - utils.log.warn('tunnel got disconnected in the midst of the script run') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runScriptMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) - .to.throw('no browsers specified for runScriptMultiple') - }) - - it('should fail to create a run of script sessions if required browser keys are not provided', function() { - return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of script sessions if script parameter provided is not of function type', function() { - expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }], { - })}) - .to.throw('invalid script') - }) - - it('should create a run of script sessions if a valid remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Chrome', - browserVersion: '50.0' - }, { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '41.0' - }], { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of script sessions and tolerate errors thrown by scripts run if a valid local url tests and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Firefox', - browserVersion: '30.0' - }, { - os: 'OS X', - osVersion: 'Snow Leopard', - browser: 'Chrome', - browserVersion: '32.0' - }], { - build: build.build, - test: build.test, - project: build.project - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - } - - describe('stop', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail for a non-existent run id', function() { - function tester() { - platform.stop('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - it('should successfully stop an ongoing run of test jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '32.0' - }, { - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '14.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Snow Leopard', - browser: 'Firefox', - browserVersion: '31.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully take screenshots and stop an ongoing run of test jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '39.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully take screenshots and stop an ongoing run of script jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '35.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully stop an ongoing run of test jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Sierra', - browser: 'Firefox', - browserVersion: '45.0' - }, { - os: 'Windows', - osVersion: '8.1', - browser: 'Chrome', - browserVersion: '39.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '35.0' - }, { - local: true, - localIdentifier: 'tunnel-x', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message.match(/is set to true but local testing through BrowserStack is not connected/)) { - utils.log.warn('tunnel got disconnected in the midst of the script run') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully stop remaining running test jobs of a run that access a local url after one test job from the run is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Firefox', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '38.0' - }], { - local: true, - localIdentifier: 'my-test-id', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('status', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail for a non-existent run id', function() { - function tester() { - platform.status('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '39.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Lion', - browser: 'Firefox', - browserVersion: '31.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "stopped" for a completed run of a test job that accessed a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '31.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "stopped" for a completed run of a script job that accessed a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '45.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script, - () => { - return Promise.resolve(false) - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "running" for an ongoing run of a test job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '41.0' - }, { - local: true, - localIdentifier: 'platform-run-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('running' !== results.status) { - utils.log.warn('expected status to be running, not %s', results.status) - } - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - utils.log.error('error: ', err) - throw err - } - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "running" for an ongoing run of a script job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Snow Leopard', - browser: 'Chrome', - browserVersion: '36.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('running' !== results.status) { - utils.log.warn('expected status to be running, not %s', results.status) - } - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message.match(/is set to true but local testing through BrowserStack is not connected/) || - err.message.match(/Process: already stopped/)) - { - utils.log.warn('tunnel got disconnected in the midst of the script run') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "stopped" for a completed run of a test job that accessed a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '52.0' - }, { - local: true, - localIdentifier: 'platform-run-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('stopped' !== results.status) { - utils.log.warn('expected test status to be stopped, not %s', results.status) - } - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "stopped" for a completed run of a script job that accessed a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '43.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome', - browserVersion: '42.0' - }, { - local: true, - localIdentifier: 'platform-run-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('messy') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "messy" for an ongoing run of a script job that access a local url after the tunnel is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Firefox', - browserVersion: '38.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('messy' !== results.status) { - utils.log.warn('expected results status to be messy') - } - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - }) - - describe('close', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete in case there are no ongoing runs', function() { - return platform.close() - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of test jobs that access a remote url and close the platform', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Opera', - browserVersion: '30.0' - }, { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome', - browserVersion: '41.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a remote url and close the platform', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Lion', - browser: 'Firefox', - browserVersion: '36.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should complete closing the platform if an ongoing run of test jobs that access a remote url was stopped by calling "stop" method explicitly', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Firefox', - browserVersion: '46.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should complete closing the platform if an ongoing run of script jobs that access a remote url was stopped by calling the "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '51.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should shutdown the tunnels and complete closing the platform if an ongoing run of test jobs that access a local url was stopped by calling "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '15.0' - }, { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '53.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should shutdown the tunnels and complete closing the platform if an ongoing run of script jobs that access a local url was stopped by calling "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '36.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should stop remaining test jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one test from the run of test jobs that access a local url was manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Snow Leopard', - browser: 'Firefox', - browserVersion: '32.0' - }], { - local: true, - localIdentifier: 'my-test-id', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should stop remaining script jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one of the script jobs from the run of script jobs that access a local url was manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '45.0' - }, { - local: true, - localIdentifier: 'my-test-id', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].scriptJobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should stop test jobs of an ongoing run of test jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '14.0' - }, { - os: 'Windows', - osVersion: 'XP', - browser: 'Firefox', - browserVersion: '34.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should stop scripts jobs of an ongoing run of script jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome', - browserVersion: '41.0' - }, { - local: true, - localIdentifier: 'my-test-id', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - if(!Env.isWindows) { - - it('should fail if there is a failure in stopping the tunnels associated with a run of test jobs that access a local url (simulated with removing execute permissions for the tunnel binary)', function() { - var build = utils.buildDetails(), error - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '41.0' - }, { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Firefox', - browserVersion: '42.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return fs.chmodAsync(BinaryVars.path, '0400') - }) - .then(() => { - return platform.close() - }) - .catch(err => { - error = err - return fs.chmodAsync(BinaryVars.path, '0755') - }) - .then(() => { - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .then(() => { - throw error - }) - .should.be.rejectedWith('spawn EACCES') - }) - - if(process.version > 'v6') { - it('should fail if there is a failure in stopping the tunnels associated with a run of script jobs that access a local url (simulated with removing execute permissions for the tunnel binary)', function() { - var build = utils.buildDetails(), error - return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: 'XP', - browser: 'Chrome', - browserVersion: '30.0' - }, { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Firefox', - browserVersion: '42.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return fs.chmodAsync(BinaryVars.path, '0400') - }) - .then(() => { - return platform.close() - }) - .catch(err => { - error = err - return fs.chmodAsync(BinaryVars.path, '0755') - }) - .then(() => { - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .then(() => { - throw error - }) - .should.be.rejectedWith('spawn EACCES') - }) - } - } - }) - + require('./platform/open') + require('./platform/job') + require('./platform/scriptjob') + require('./platform/status') + require('./platform/stop') + require('./platform/close') }) diff --git a/tests/unit/tests/platforms/browserstack/platform/close.js b/tests/unit/tests/platforms/browserstack/platform/close.js new file mode 100644 index 0000000..3481d7c --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/close.js @@ -0,0 +1,538 @@ +'use strict'; + +var + Bluebird = require('bluebird'), + fs = Bluebird.promisifyAll(require('fs')), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + Env = require('./../../../../../../lib/core/env').Env, + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + BinaryVars = require('./../../../../../../lib/platforms/browserstack/tunnel/binary').BinaryVars, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('close', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete in case there are no ongoing runs', function() { + return platform.close() + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of test jobs that access a remote url and close the platform', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Opera', + browserVersion: '30.0' + }, { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome', + browserVersion: '41.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a remote url and close the platform', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Lion', + browser: 'Firefox', + browserVersion: '36.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should complete closing the platform if an ongoing run of test jobs that access a remote url was stopped by calling "stop" method explicitly', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Firefox', + browserVersion: '46.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should complete closing the platform if an ongoing run of script jobs that access a remote url was stopped by calling the "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '51.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should shutdown the tunnels and complete closing the platform if an ongoing run of test jobs that access a local url was stopped by calling "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '15.0' + }, { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '53.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should shutdown the tunnels and complete closing the platform if an ongoing run of script jobs that access a local url was stopped by calling "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '36.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should stop remaining test jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one test from the run of test jobs that access a local url was manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Snow Leopard', + browser: 'Firefox', + browserVersion: '32.0' + }], { + local: true, + localIdentifier: 'my-test-id', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should stop remaining script jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one of the script jobs from the run of script jobs that access a local url was manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '45.0' + }, { + local: true, + localIdentifier: 'my-test-id', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].scriptJobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should stop test jobs of an ongoing run of test jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '14.0' + }, { + os: 'Windows', + osVersion: 'XP', + browser: 'Firefox', + browserVersion: '34.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should stop scripts jobs of an ongoing run of script jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome', + browserVersion: '41.0' + }, { + local: true, + localIdentifier: 'my-test-id', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + if(!Env.isWindows) { + + it('should fail if there is a failure in stopping the tunnels associated with a run of test jobs that access a local url (simulated with removing execute permissions for the tunnel binary)', function() { + var build = utils.buildDetails(), error + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '41.0' + }, { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Firefox', + browserVersion: '42.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return fs.chmodAsync(BinaryVars.path, '0400') + }) + .then(() => { + return platform.close() + }) + .catch(err => { + error = err + return fs.chmodAsync(BinaryVars.path, '0755') + }) + .then(() => { + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .then(() => { + throw error + }) + .should.be.rejectedWith('spawn EACCES') + }) + + if(process.version > 'v6') { + it('should fail if there is a failure in stopping the tunnels associated with a run of script jobs that access a local url (simulated with removing execute permissions for the tunnel binary)', function() { + var build = utils.buildDetails(), error + return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '30.0' + }, { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Firefox', + browserVersion: '42.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return fs.chmodAsync(BinaryVars.path, '0400') + }) + .then(() => { + return platform.close() + }) + .catch(err => { + error = err + return fs.chmodAsync(BinaryVars.path, '0755') + }) + .then(() => { + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .then(() => { + throw error + }) + .should.be.rejectedWith('spawn EACCES') + }) + } + } +}) diff --git a/tests/unit/tests/platforms/browserstack/platform/job.js b/tests/unit/tests/platforms/browserstack/platform/job.js new file mode 100644 index 0000000..5b85b9c --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/job.js @@ -0,0 +1,344 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +describe('run', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.run(undefined, undefined, undefined) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if required browser keys are not provided', function() { + return platform.run('http://www.piaxis.tech', { }, { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if an unsupported browser key is provided', function() { + return platform.run('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '21.0' + }, { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a test job if an unsupported capabilities key is provided', function() { + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '21.0' + }, { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of a test job if a valid remote url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '52.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'platform-run-1', + screenshots: false, + video: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job for native runner case if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '41.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'platform-run-1', + screenshots: false, + video: true, + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job for native runner case if a valid local url ending in ?, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '33.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'platform-run-1', + screenshots: false, + video: true, + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) + +describe('runMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.runMultiple(undefined, undefined, undefined) + .should.be.rejectedWith('no browsers specified for createMultiple') + }) + + it('should fail to create a run of test jobs if required keys are not provided in even one of the input browsers', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'Windows' + }], { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of test jobs if an unsupported key is provided in even one of the input browsers', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0' + }, { + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0', + abc: 123 + }], { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of tests jobs if an unsupported capabilities key is provided', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0' + }], { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of test jobs if a valid remote url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '31.0' + }, { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Chrome', + browserVersion: '45.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs if a valid local url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '41.0' + }, { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '52.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs for native runner case if a valid local url containing query parameters, and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Chrome', + browserVersion: '50.0' + }, { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '37.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/browserstack/platform/open.js b/tests/unit/tests/platforms/browserstack/platform/open.js new file mode 100644 index 0000000..7aba25d --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/open.js @@ -0,0 +1,150 @@ +'use strict'; + +var + retry = require('p-retry'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + Manager = require('./../../../../../../lib/platforms/browserstack/manager').Manager, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('open', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete if no capabilities are provided', function() { + return platform.open() + .should.be.fulfilled + }) + + it('should fail in case capabilities input is not an array', function() { + function tester() { + platform.open({ local: true }) + } + expect(tester).to.throw('capabilitiesArr.forEach is not a function') + }) + + it('should fail if an invalid/unsupported capability key is provided', function() { + function tester() { + platform.open([{ + abc: 123 + }]) + } + expect(tester).to.throw('option abc is not allowed') + }) + + it('should open the platform by creating a tunnel without an identifier if "local" capability is provided', function() { + return platform.open([{ + local: true + }]) + .then(() => { + platform.stopMonitoring = true + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + function waitForTunnel() { + const check = () => { + return Manager.withoutId() + .then(procs => { + if(procs.length) { + utils.log.debug('Got a tunnel process') + return true + } + utils.log.debug('No tunnels running yet') + throw new Error('no tunnels yet') + }) + }, + minTimeout = 2000, factor = 1, max = 60 + return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) + } + + it('should open the platform by creating a tunnel process if "local" capability was provided, and then monitor the tunnel process availability and restart it if it dies', function() { + platform.stopMonitoring = false + platform.tunnels = [ ] + return platform.open([{ + local: true + }]) + .then(() => { + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + utils.stopProc(platform.tunnels[0].process.pid) + return true + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .then(() => { + return waitForTunnel() + }) + .then(() => { + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should open the platform by creating multiple tunnel processes with identifiers if multiple "local" and "localIdentifier" capabilities were provided', function() { + return platform.open([{ + local: true, + localIdentifier: 'my-id-1' + }, { + local: true, + localIdentifier: 'my-id-2' + }]) + .then(() => { + platform.stopMonitoring = true + return Manager.withId() + }) + .then(procs => { + if(2 !== procs.length) { + utils.log.warn('expected 2 tunnels to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/browserstack/platform/scriptjob.js b/tests/unit/tests/platforms/browserstack/platform/scriptjob.js new file mode 100644 index 0000000..2d2816f --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/scriptjob.js @@ -0,0 +1,300 @@ +'use strict'; + +var + Bluebird = require('bluebird'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + }, + badScript = (driver, webdriver) => { + return driver.findElement({id : 'xyz'}) + } + +if(process.version > 'v6') { + + describe('runScript', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.runScript(undefined, undefined, undefined, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if required browser keys are not provided', function() { + return platform.runScript('http://www.piaxis.tech', { }, { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if unsupported browser key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0' + }, { }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if unsupported capabilities key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0' + }, { + abc: 123 + }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if script parameter is not a function', function() { + expect(()=>{platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + })}) + .to.throw('invalid script') + }) + + it('should create a run of a script session if a valid remote url and valid values for all mandatary parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '31.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session and tolerate the error thrown by the script if a valid remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8.1', + browser: 'Chrome', + browserVersion: '48.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session if a valid local url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '35.0' + }, { + timeout: 60, + build: build.build, + test: build.test, + project: build.project, + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + video: true + }, + script) + .then(run => { + checkRun(run) + return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message.match(/is set to true but local testing through BrowserStack is not connected/)) { + utils.log.warn('tunnel got disconnected in the midst of the script run') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + + describe('runScriptMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) + .to.throw('no browsers specified for runScriptMultiple') + }) + + it('should fail to create a run of script sessions if required browser keys are not provided', function() { + return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of script sessions if script parameter provided is not of function type', function() { + expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }], { + })}) + .to.throw('invalid script') + }) + + it('should create a run of script sessions if a valid remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Chrome', + browserVersion: '50.0' + }, { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '41.0' + }], { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of script sessions and tolerate errors thrown by scripts run if a valid local url tests and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Firefox', + browserVersion: '30.0' + }, { + os: 'OS X', + osVersion: 'Snow Leopard', + browser: 'Chrome', + browserVersion: '32.0' + }], { + build: build.build, + test: build.test, + project: build.project + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) +} diff --git a/tests/unit/tests/platforms/browserstack/platform/status.js b/tests/unit/tests/platforms/browserstack/platform/status.js new file mode 100644 index 0000000..4fd2922 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/status.js @@ -0,0 +1,513 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('status', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail for a non-existent run id', function() { + function tester() { + platform.status('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '39.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Lion', + browser: 'Firefox', + browserVersion: '31.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "stopped" for a completed run of a test job that accessed a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '31.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "stopped" for a completed run of a script job that accessed a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '45.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script, + () => { + return Promise.resolve(false) + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "running" for an ongoing run of a test job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '41.0' + }, { + local: true, + localIdentifier: 'platform-run-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('running' !== results.status) { + utils.log.warn('expected status to be running, not %s', results.status) + } + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + utils.log.error('error: ', err) + throw err + } + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "running" for an ongoing run of a script job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Snow Leopard', + browser: 'Chrome', + browserVersion: '36.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('running' !== results.status) { + utils.log.warn('expected status to be running, not %s', results.status) + } + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message.match(/is set to true but local testing through BrowserStack is not connected/) || + err.message.match(/Process: already stopped/)) + { + utils.log.warn('tunnel got disconnected in the midst of the script run') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "stopped" for a completed run of a test job that accessed a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '52.0' + }, { + local: true, + localIdentifier: 'platform-run-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('stopped' !== results.status) { + utils.log.warn('expected test status to be stopped, not %s', results.status) + } + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "stopped" for a completed run of a script job that accessed a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '43.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome', + browserVersion: '42.0' + }, { + local: true, + localIdentifier: 'platform-run-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('messy') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "messy" for an ongoing run of a script job that access a local url after the tunnel is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Firefox', + browserVersion: '38.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('messy' !== results.status) { + utils.log.warn('expected results status to be messy') + } + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + +}) diff --git a/tests/unit/tests/platforms/browserstack/platform/stop.js b/tests/unit/tests/platforms/browserstack/platform/stop.js new file mode 100644 index 0000000..f8522f8 --- /dev/null +++ b/tests/unit/tests/platforms/browserstack/platform/stop.js @@ -0,0 +1,263 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/browserstack/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('stop', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail for a non-existent run id', function() { + function tester() { + platform.stop('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + it('should successfully stop an ongoing run of test jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP', + browser: 'Chrome', + browserVersion: '32.0' + }, { + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '14.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Snow Leopard', + browser: 'Firefox', + browserVersion: '31.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully take screenshots and stop an ongoing run of test jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '39.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully take screenshots and stop an ongoing run of script jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '35.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully stop an ongoing run of test jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Sierra', + browser: 'Firefox', + browserVersion: '45.0' + }, { + os: 'Windows', + osVersion: '8.1', + browser: 'Chrome', + browserVersion: '39.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '35.0' + }, { + local: true, + localIdentifier: 'tunnel-x', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message.match(/is set to true but local testing through BrowserStack is not connected/)) { + utils.log.warn('tunnel got disconnected in the midst of the script run') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully stop remaining running test jobs of a run that access a local url after one test job from the run is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Firefox', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '38.0' + }], { + local: true, + localIdentifier: 'my-test-id', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-close.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-close.js new file mode 100644 index 0000000..fd2dfda --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-close.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/close') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-job.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-job.js new file mode 100644 index 0000000..b724820 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-job.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/job') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-open.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-open.js new file mode 100644 index 0000000..3d0a997 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-open.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/open') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-scriptjob.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-scriptjob.js new file mode 100644 index 0000000..81af04f --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-scriptjob.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/scriptjob') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-status.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-status.js new file mode 100644 index 0000000..256a782 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-status.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/status') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting-platform-stop.js b/tests/unit/tests/platforms/crossbrowsertesting-platform-stop.js new file mode 100644 index 0000000..2753da7 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting-platform-stop.js @@ -0,0 +1,5 @@ +describe('CrossBrowserTesting', function() { + describe('Platform', function() { + require('./crossbrowsertesting/platform/stop') + }) +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform.js b/tests/unit/tests/platforms/crossbrowsertesting/platform.js index 45aee5c..f1f981f 100644 --- a/tests/unit/tests/platforms/crossbrowsertesting/platform.js +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform.js @@ -1,1846 +1,8 @@ -'use strict'; - -var - Bluebird = require('bluebird'), - retry = require('p-retry'), - fs = Bluebird.promisifyAll(require('fs')), - chai = require('chai'), - spies = require('chai-spies'), - chaiAsPromised = require('chai-as-promised'), - Env = require('./../../../../../lib/core/env').Env, - platform = require('./../../../../../lib/platforms/crossbrowsertesting/platform'), - Platform = platform.Platform, - Tunnel = require('./../../../../../lib/platforms/crossbrowsertesting/tunnel').Tunnel, - Manager = require('./../../../../../lib/platforms/crossbrowsertesting/manager').Manager, - utils = require('./utils') - -chai.use(spies) -chai.use(chaiAsPromised) - -var - expect = chai.expect, - should = chai.should() - -function checkRun(run) { - expect(run).to.not.be.undefined - expect(run.id).to.not.be.undefined - expect(run.id).to.be.a('string') -} - -const - script = (driver, webdriver) => { - return driver.getTitle() - .then(function(title) { - utils.log.debug(title) - return true - }) - }, - badScript = (driver, webdriver) => { - return driver.findElement({id : 'xyz'}) - } - describe('Platform', function() { - - describe('open', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete if no capabilities are provided', function() { - return platform.open() - .should.be.fulfilled - }) - - it('should fail in case capabilities input is not an array', function() { - function tester() { - platform.open({ local: true }) - } - expect(tester).to.throw('capabilitiesArr.forEach is not a function') - }) - - it('should fail if an invalid/unsupported capability key is provided', function() { - function tester() { - platform.open([{ - abc: 123 - }]) - } - expect(tester).to.throw('option abc is not allowed') - }) - - it('should open the platform by creating a tunnel if "local" capability is provided', function() { - return platform.open([{ - local: true - }]) - .then(() => { - platform.stopMonitoring = true - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - function waitForTunnel() { - const check = () => { - return Manager.withoutId() - .then(procs => { - if(procs.length) { - utils.log.debug('Got a tunnel process') - return true - } - utils.log.debug('No tunnels running yet') - throw new Error('no tunnels yet') - }) - }, - minTimeout = 2000, factor = 1, max = 60 - return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) - } - - it('should open the platform by creating a tunnel process if "local" capability was provided, and then monitor the tunnel process availability and restart it if it dies', function() { - platform.stopMonitoring = false - platform.tunnels = [ ] - return platform.open([{ - local: true - }]) - .then(() => { - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - utils.stopProc(platform.tunnels[0].process.pid) - return true - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .then(() => { - return waitForTunnel() - }) - .then(() => { - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('run', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.run(undefined, undefined, undefined) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if required browser keys are not provided', function() { - return platform.run('http://www.piaxis.tech', { }, { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if an unsupported browser key is provided', function() { - return platform.run('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: 'XP Service Pack 3', - browser: 'Chrome', - browserVersion: '21.0' - }, { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a test job if an unsupported capabilities key is provided', function() { - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: 'XP Service Pack 2', - browser: 'Chrome', - browserVersion: '24.0' - }, { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of a test job if a valid remote url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '52.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Opera', - browserVersion: '47.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'my-tunnel', - video: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job for native runner case if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Ubuntu', - osVersion: 'Vivid', - browser: 'Chromium', - browserVersion: '48.0' - }, { - timeout: 60, - local: true, - video: true, - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job for native runner case if a valid local url ending in ?, valid values for all mandatory parameters, and few optional capabilities are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '34.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'my-tunnel-1', - video: true, - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.runMultiple(undefined, undefined, undefined) - .should.be.rejectedWith('no browsers specified for createMultiple') - }) - - it('should fail to create a run of test jobs if required keys are not provided in even one of the input browsers', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '55.0' - }, { - os: 'Windows' - }], { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of test jobs if an unsupported key is provided in even one of the input browsers', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP Service Pack 2', - browser: 'Chrome', - browserVersion: '31.0' - }, { - os: 'Windows', - osVersion: '7 64-bit', - browser: 'Chrome', - browserVersion: '31.0', - abc: 123 - }], { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of tests jobs if an unsupported capabilities key is provided', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: 'XP Service Pack 3', - browser: 'Chrome', - browserVersion: '35.0' - }], { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of test jobs if a valid remote url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '7 64-bit', - browser: 'Firefox', - browserVersion: '33.0' - }, { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Safari', - browserVersion: '8.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs if a valid local url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '8.1', - browser: 'Internet Explorer', - browserVersion: '11.0' - }, { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Opera', - browserVersion: '46.0' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs for native runner case if a valid local url containing query parameters, and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Camino', - browserVersion: '2.1' - }, { - os: 'Windows Phone', - osVersion: '8', - browser: 'IE Mobile', - browserVersion: '10.0', - device: 'Win Phone 8 Simulator' - }], { - local: true, - localIdentifier: 'my-mult-tunnel', - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - if(process.version > 'v6') { - - describe('runScript', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - return platform.runScript(undefined, undefined, undefined, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if required browser keys are not provided', function() { - return platform.runScript('http://www.piaxis.tech', { }, { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if unsupported browser key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: '7 64-bit', - browser: 'Chrome', - browserVersion: '31.0' - }, { }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if unsupported capabilities key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '31.0' - }, { - abc: 123 - }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if script parameter is not a function', function() { - expect(()=>{platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Opera', - browserVersion: '45.0' - }, { - })}) - .to.throw('invalid script') - }) - - it('should create a run of a script session if a valid remote url and valid values for all mandatary parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Android', - osVersion: '6.0', - browser: 'Chrome Mobile', - browserVersion: '59.0', - device: 'Android Nexus 9' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session and tolerate the error thrown by the script if a valid remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome x64', - browserVersion: '52.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session if a valid local url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '35.0' - }, { - timeout: 60, - build: build.build, - test: build.test, - project: build.project, - local: true, - video: true - }, - script) - .then(run => { - checkRun(run) - return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - //if(err.message.match(/is set to true but local testing through CrossBrowserTesting is not connected/)) { - //utils.log.warn('tunnel got disconnected in the midst of the script run') - //return true - //} - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runScriptMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if no input is provided', function() { - expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) - .to.throw('no browsers specified for runScriptMultiple') - }) - - it('should fail to create a run of script sessions if required browser keys are not provided', function() { - return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of script sessions if script parameter provided is not of function type', function() { - expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '59.0' - }], { - })}) - .to.throw('invalid script') - }) - - it('should create a run of script sessions if a valid remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Safari', - browserVersion: '9.0' - }, { - os: 'Windows', - osVersion: '8.1', - browser: 'Internet Explorer', - browserVersion: '11.0' - }], { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of script sessions and tolerate errors thrown by scripts run if a valid local url tests and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '7 64-bit', - browser: 'Firefox', - browserVersion: '30.0' - }, { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome x64', - browserVersion: '39.0' - }], { - build: build.build, - test: build.test, - project: build.project, - local: true, - localIdentifier: 'my-mult-script-tunnel' - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - } - - describe('stop', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail for a non-existent run id', function() { - function tester() { - platform.stop('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - it('should successfully stop an ongoing run of test jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '8 Preview', - browser: 'Chrome', - browserVersion: '24.0' - }, { - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '16.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Safari', - browserVersion: '10.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully take screenshots and stop an ongoing run of test jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'iOS', - osVersion: '9.3', - browser: 'Mobile Safari', - browserVersion: '9.0', - device: 'iPad Pro Simulator' - }, { - os: 'Android', - osVersion: '4.4', - browser: 'Chrome Mobile', - browserVersion: '61.0', - device: 'Android Galaxy Tab S' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - - it('should successfully take screenshots and stop an ongoing run of script jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8.1', - browser: 'Chrome', - browserVersion: '40.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully stop an ongoing run of test jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome x64', - browserVersion: '58.0' - }, { - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '14.0' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Firefox', - browserVersion: '47.0' - }, { - local: true, - localIdentifier: 'my-script-tunnel', - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - //if(err.message.match(/is set to true but local testing through CrossBrowserTesting is not connected/)) { - //utils.log.warn('tunnel got disconnected in the midst of the script run') - //return true - //} - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should successfully stop remaining running test jobs of a run that access a local url after one test job from the run is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Android', - osVersion: '5.0', - browser: 'Dolphin Mobile', - browserVersion: '11.5', - device: 'Android Nexus 9' - }, { - os: 'Android', - osVersion: '4.2', - browser: 'Sleipnir Mobile', - browserVersion: '3.5', - device: 'Android Nexus 7' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('status', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail for a non-existent run id', function() { - function tester() { - platform.status('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Opera', - browserVersion: '39.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.equal('running') - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome x64', - browserVersion: '43.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('running') - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "stopped" for a completed run of a test job that accessed a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Android', - osVersion: '6.0', - browser: 'UC Browser', - browserVersion: '11.3', - device: 'Android Nexus 9' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "stopped" for a completed run of a script job that accessed a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '7 64-bit', - browser: 'Chrome', - browserVersion: '30.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script, - () => { - return Promise.resolve(false) - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "running" for an ongoing run of a test job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: 'XP Service Pack 2', - browser: 'AOL Explorer', - browserVersion: '1.5' - }, { - local: true, - localIdentifier: 'my-run-tunnel', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.equal('running') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - utils.log.error('error: ', err) - throw err - } - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "running" for an ongoing run of a script job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome x64', - browserVersion: '41.0' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('running') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "stopped" for a completed run of a test job that accessed a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Blackberry', - osVersion: 'Blackberry Bold 9900', - browser: 'Blackberry Browser', - browserVersion: '9900', - device: 'BB Bold 9900 Simulator' - }, { - local: true, - localIdentifier: 'stop-test-tunnel', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.equal('stopped') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "stopped" for a completed run of a script job that accessed a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8.1', - browser: 'Internet Explorer', - browserVersion: '11.0' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'iOS', - osVersion: '10.2', - browser: 'Dolphin for iOS', - browserVersion: '9.0', - device: 'iPad Pro' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('messy' !== results.status) { - utils.log.warn('expected status to be "messy", not %s', results.status) - } - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should say "messy" for an ongoing run of a script job that access a local url after the tunnel is stopped manually', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Firefox', - browserVersion: '38.0' - }, { - local: true, - localIdentifier: 'messy-test-tunnel', - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('messy' !== results.status) { - utils.log.warn('expected status to be "messy", not %s', results.status) - } - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - }) - - describe('close', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete in case there are no ongoing runs', function() { - return platform.close() - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of test jobs that access a remote url and close the platform', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'iOS', - osVersion: '10.2', - browser: 'Chrome for iOS', - browserVersion: '57.0', - device: 'iPad Pro' - }, { - os: 'Android', - osVersion: '4.1', - browser: 'Maxthon Mobile HD', - browserVersion: '4.3', - device: 'Android Galaxy Tab 2' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should successfully stop an ongoing run of script jobs that access a remote url and close the platform', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '26.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should complete closing the platform if an ongoing run of test jobs that access a remote url was stopped by calling "stop" method explicitly', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Android', - osVersion: '5.0', - browser: 'Maxthon Mobile', - browserVersion: '4.3', - device: 'Android Nexus 9' - }, { - os: 'Windows', - osVersion: 'XP Service Pack 2', - browser: 'Mozilla', - browserVersion: '1.7.13' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should complete closing the platform if an ongoing run of script jobs that access a remote url was stopped by calling the "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8 Preview', - browser: 'Internet Explorer', - browserVersion: '10.0' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should shutdown the tunnels and complete closing the platform if an ongoing run of test jobs that access a local url was stopped by calling "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: 'Vista Home', - browser: 'Netscape', - browserVersion: '9.0.0.5' - }, { - os: 'iOS', - osVersion: '10.2', - browser: 'Opera Mini for iOS', - browserVersion: '14.0', - device: 'iPad Pro' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should shutdown the tunnels and complete closing the platform if an ongoing run of script jobs that access a local url was stopped by calling "stop" method manually', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Safari', - browserVersion: '10.0' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should stop remaining test jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one test from the run of test jobs that access a local url was manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Android', - osVersion: '6.0', - browser: 'Opera Mini', - browserVersion: '27.0', - device: 'Android Nexus 9' - }, { - os: 'Android', - osVersion: '5.0', - browser: 'Opera Mobile', - browserVersion: '43.0', - device: 'Android Nexus 6' - }], { - local: true, - localIdentifier: 'close-test-tunnel', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should stop remaining script jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one of the script jobs from the run of script jobs that access a local url was manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '10', - browser: 'Edge', - browserVersion: '14.0' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].scriptJobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - it('should stop test jobs of an ongoing run of test jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '10', - browser: 'Opera', - browserVersion: '40.0' - }, { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Opera', - browserVersion: '34.0' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - it('should stop scripts jobs of an ongoing run of script jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mountain Lion', - browser: 'Chrome x64', - browserVersion: '46.0' - }, { - local: true, - localIdentifier: 'close-script-run-tunnel', - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - }) - + require('./platform/open') + require('./platform/job') + require('./platform/scriptjob') + require('./platform/status') + require('./platform/stop') + require('./platform/close') }) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/close.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/close.js new file mode 100644 index 0000000..558ca84 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/close.js @@ -0,0 +1,446 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('close', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete in case there are no ongoing runs', function() { + return platform.close() + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of test jobs that access a remote url and close the platform', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'iOS', + osVersion: '10.2', + browser: 'Chrome for iOS', + browserVersion: '57.0', + device: 'iPad Pro' + }, { + os: 'Android', + osVersion: '4.1', + browser: 'Maxthon Mobile HD', + browserVersion: '4.3', + device: 'Android Galaxy Tab 2' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a remote url and close the platform', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '26.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should complete closing the platform if an ongoing run of test jobs that access a remote url was stopped by calling "stop" method explicitly', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Android', + osVersion: '5.0', + browser: 'Maxthon Mobile', + browserVersion: '4.3', + device: 'Android Nexus 9' + }, { + os: 'Windows', + osVersion: 'XP Service Pack 2', + browser: 'Mozilla', + browserVersion: '1.7.13' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should complete closing the platform if an ongoing run of script jobs that access a remote url was stopped by calling the "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8 Preview', + browser: 'Internet Explorer', + browserVersion: '10.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should shutdown the tunnels and complete closing the platform if an ongoing run of test jobs that access a local url was stopped by calling "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: 'Vista Home', + browser: 'Netscape', + browserVersion: '9.0.0.5' + }, { + os: 'iOS', + osVersion: '10.2', + browser: 'Opera Mini for iOS', + browserVersion: '14.0', + device: 'iPad Pro' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should shutdown the tunnels and complete closing the platform if an ongoing run of script jobs that access a local url was stopped by calling "stop" method manually', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Safari', + browserVersion: '10.0' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should stop remaining test jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one test from the run of test jobs that access a local url was manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Android', + osVersion: '6.0', + browser: 'Opera Mini', + browserVersion: '27.0', + device: 'Android Nexus 9' + }, { + os: 'Android', + osVersion: '5.0', + browser: 'Opera Mobile', + browserVersion: '43.0', + device: 'Android Nexus 6' + }], { + local: true, + localIdentifier: 'close-test-tunnel', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should stop remaining script jobs of an ongoing run, shutdown the tunnels, and complete closing the platform if one of the script jobs from the run of script jobs that access a local url was manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '14.0' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].scriptJobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should stop test jobs of an ongoing run of test jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '10', + browser: 'Opera', + browserVersion: '40.0' + }, { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Opera', + browserVersion: '34.0' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should stop scripts jobs of an ongoing run of script jobs that access a local url and complete closing the platform even if tunnels involved in the run were stopped manually in between', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome x64', + browserVersion: '46.0' + }, { + local: true, + localIdentifier: 'close-script-run-tunnel', + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/job.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/job.js new file mode 100644 index 0000000..ebeb7dc --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/job.js @@ -0,0 +1,340 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +describe('run', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.run(undefined, undefined, undefined) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if required browser keys are not provided', function() { + return platform.run('http://www.piaxis.tech', { }, { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if an unsupported browser key is provided', function() { + return platform.run('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: 'XP Service Pack 3', + browser: 'Chrome', + browserVersion: '21.0' + }, { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a test job if an unsupported capabilities key is provided', function() { + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: 'XP Service Pack 2', + browser: 'Chrome', + browserVersion: '24.0' + }, { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of a test job if a valid remote url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '52.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Opera', + browserVersion: '47.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'my-tunnel', + video: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job for native runner case if a valid local url, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Ubuntu', + osVersion: 'Vivid', + browser: 'Chromium', + browserVersion: '48.0' + }, { + timeout: 60, + local: true, + video: true, + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job for native runner case if a valid local url ending in ?, valid values for all mandatory parameters, and few optional capabilities are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '34.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'my-tunnel-1', + video: true, + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) + +describe('runMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.runMultiple(undefined, undefined, undefined) + .should.be.rejectedWith('no browsers specified for createMultiple') + }) + + it('should fail to create a run of test jobs if required keys are not provided in even one of the input browsers', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '55.0' + }, { + os: 'Windows' + }], { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of test jobs if an unsupported key is provided in even one of the input browsers', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP Service Pack 2', + browser: 'Chrome', + browserVersion: '31.0' + }, { + os: 'Windows', + osVersion: '7 64-bit', + browser: 'Chrome', + browserVersion: '31.0', + abc: 123 + }], { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of tests jobs if an unsupported capabilities key is provided', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: 'XP Service Pack 3', + browser: 'Chrome', + browserVersion: '35.0' + }], { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of test jobs if a valid remote url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '7 64-bit', + browser: 'Firefox', + browserVersion: '33.0' + }, { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Safari', + browserVersion: '8.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs if a valid local url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '8.1', + browser: 'Internet Explorer', + browserVersion: '11.0' + }, { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Opera', + browserVersion: '46.0' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs for native runner case if a valid local url containing query parameters, and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Camino', + browserVersion: '2.1' + }, { + os: 'Windows Phone', + osVersion: '8', + browser: 'IE Mobile', + browserVersion: '10.0', + device: 'Win Phone 8 Simulator' + }], { + local: true, + localIdentifier: 'my-mult-tunnel', + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/open.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/open.js new file mode 100644 index 0000000..21fc6d5 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/open.js @@ -0,0 +1,125 @@ +'use strict'; + +var + retry = require('p-retry'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + Manager = require('./../../../../../../lib/platforms/crossbrowsertesting/manager').Manager, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('open', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete if no capabilities are provided', function() { + return platform.open() + .should.be.fulfilled + }) + + it('should fail in case capabilities input is not an array', function() { + function tester() { + platform.open({ local: true }) + } + expect(tester).to.throw('capabilitiesArr.forEach is not a function') + }) + + it('should fail if an invalid/unsupported capability key is provided', function() { + function tester() { + platform.open([{ + abc: 123 + }]) + } + expect(tester).to.throw('option abc is not allowed') + }) + + it('should open the platform by creating a tunnel if "local" capability is provided', function() { + return platform.open([{ + local: true + }]) + .then(() => { + platform.stopMonitoring = true + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + function waitForTunnel() { + const check = () => { + return Manager.withoutId() + .then(procs => { + if(procs.length) { + utils.log.debug('Got a tunnel process') + return true + } + utils.log.debug('No tunnels running yet') + throw new Error('no tunnels yet') + }) + }, + minTimeout = 2000, factor = 1, max = 60 + return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) + } + + it('should open the platform by creating a tunnel process if "local" capability was provided, and then monitor the tunnel process availability and restart it if it dies', function() { + platform.stopMonitoring = false + platform.tunnels = [ ] + return platform.open([{ + local: true + }]) + .then(() => { + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + utils.stopProc(platform.tunnels[0].process.pid) + return true + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .then(() => { + return waitForTunnel() + }) + .then(() => { + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/scriptjob.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/scriptjob.js new file mode 100644 index 0000000..b638c43 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/scriptjob.js @@ -0,0 +1,299 @@ +'use strict'; + +var + Bluebird = require('bluebird'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + }, + badScript = (driver, webdriver) => { + return driver.findElement({id : 'xyz'}) + } + +if(process.version > 'v6') { + + describe('runScript', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + return platform.runScript(undefined, undefined, undefined, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if required browser keys are not provided', function() { + return platform.runScript('http://www.piaxis.tech', { }, { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if unsupported browser key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: '7 64-bit', + browser: 'Chrome', + browserVersion: '31.0' + }, { }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if unsupported capabilities key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '31.0' + }, { + abc: 123 + }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if script parameter is not a function', function() { + expect(()=>{platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Opera', + browserVersion: '45.0' + }, { + })}) + .to.throw('invalid script') + }) + + it('should create a run of a script session if a valid remote url and valid values for all mandatary parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'High Sierra', + browser: 'Safari', + browserVersion: '11.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session and tolerate the error thrown by the script if a valid remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome x64', + browserVersion: '52.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session if a valid local url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '35.0' + }, { + timeout: 60, + build: build.build, + test: build.test, + project: build.project, + local: true, + video: true + }, + script) + .then(run => { + checkRun(run) + return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + //if(err.message.match(/is set to true but local testing through CrossBrowserTesting is not connected/)) { + //utils.log.warn('tunnel got disconnected in the midst of the script run') + //return true + //} + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + + describe('runScriptMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if no input is provided', function() { + expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) + .to.throw('no browsers specified for runScriptMultiple') + }) + + it('should fail to create a run of script sessions if required browser keys are not provided', function() { + return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of script sessions if script parameter provided is not of function type', function() { + expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '59.0' + }], { + })}) + .to.throw('invalid script') + }) + + it('should create a run of script sessions if a valid remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Safari', + browserVersion: '9.0' + }, { + os: 'Windows', + osVersion: '8.1', + browser: 'Internet Explorer', + browserVersion: '11.0' + }], { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of script sessions and tolerate errors thrown by scripts run if a valid local url tests and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '7 64-bit', + browser: 'Firefox', + browserVersion: '30.0' + }, { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome x64', + browserVersion: '39.0' + }], { + build: build.build, + test: build.test, + project: build.project, + local: true, + localIdentifier: 'my-mult-script-tunnel' + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) +} diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/status.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/status.js new file mode 100644 index 0000000..6386a70 --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/status.js @@ -0,0 +1,496 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('status', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail for a non-existent run id', function() { + function tester() { + platform.status('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Opera', + browserVersion: '39.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.equal('running') + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome x64', + browserVersion: '43.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('running') + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "stopped" for a completed run of a test job that accessed a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Android', + osVersion: '6.0', + browser: 'UC Browser', + browserVersion: '11.3', + device: 'Android Nexus 9' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "stopped" for a completed run of a script job that accessed a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '7 64-bit', + browser: 'Chrome', + browserVersion: '30.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script, + () => { + return Promise.resolve(false) + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "running" for an ongoing run of a test job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: 'XP Service Pack 2', + browser: 'AOL Explorer', + browserVersion: '1.5' + }, { + local: true, + localIdentifier: 'my-run-tunnel', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.equal('running') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + utils.log.error('error: ', err) + throw err + } + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "running" for an ongoing run of a script job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mountain Lion', + browser: 'Chrome x64', + browserVersion: '41.0' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('running') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "stopped" for a completed run of a test job that accessed a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Blackberry', + osVersion: 'Blackberry Bold 9900', + browser: 'Blackberry Browser', + browserVersion: '9900', + device: 'BB Bold 9900 Simulator' + }, { + local: true, + localIdentifier: 'stop-test-tunnel', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.equal('stopped') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "stopped" for a completed run of a script job that accessed a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8.1', + browser: 'Internet Explorer', + browserVersion: '11.0' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'iOS', + osVersion: '10.2', + browser: 'Dolphin for iOS', + browserVersion: '9.0', + device: 'iPad Pro' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('messy' !== results.status) { + utils.log.warn('expected status to be "messy", not %s', results.status) + } + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should say "messy" for an ongoing run of a script job that access a local url after the tunnel is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Firefox', + browserVersion: '38.0' + }, { + local: true, + localIdentifier: 'messy-test-tunnel', + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('messy' !== results.status) { + utils.log.warn('expected status to be "messy", not %s', results.status) + } + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/platform/stop.js b/tests/unit/tests/platforms/crossbrowsertesting/platform/stop.js new file mode 100644 index 0000000..30d603a --- /dev/null +++ b/tests/unit/tests/platforms/crossbrowsertesting/platform/stop.js @@ -0,0 +1,263 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/crossbrowsertesting/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('stop', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail for a non-existent run id', function() { + function tester() { + platform.stop('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + it('should successfully stop an ongoing run of test jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '8 Preview', + browser: 'Chrome', + browserVersion: '24.0' + }, { + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '16.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Safari', + browserVersion: '10.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully take screenshots and stop an ongoing run of test jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'iOS', + osVersion: '9.3', + browser: 'Mobile Safari', + browserVersion: '9.0', + device: 'iPad Pro Simulator' + }, { + os: 'Android', + osVersion: '4.4', + browser: 'Chrome Mobile', + browserVersion: '61.0', + device: 'Android Galaxy Tab S' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + + it('should successfully take screenshots and stop an ongoing run of script jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8.1', + browser: 'Chrome', + browserVersion: '40.0' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully stop an ongoing run of test jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome x64', + browserVersion: '58.0' + }, { + os: 'Windows', + osVersion: '10', + browser: 'Edge', + browserVersion: '14.0' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + it('should successfully stop an ongoing run of script jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Firefox', + browserVersion: '47.0' + }, { + local: true, + localIdentifier: 'my-script-tunnel', + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + //if(err.message.match(/is set to true but local testing through CrossBrowserTesting is not connected/)) { + //utils.log.warn('tunnel got disconnected in the midst of the script run') + //return true + //} + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + + it('should successfully stop remaining running test jobs of a run that access a local url after one test job from the run is stopped manually', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Android', + osVersion: '5.0', + browser: 'Dolphin Mobile', + browserVersion: '11.5', + device: 'Android Nexus 9' + }, { + os: 'Android', + osVersion: '4.2', + browser: 'Sleipnir Mobile', + browserVersion: '3.5', + device: 'Android Nexus 7' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/crossbrowsertesting/scriptjob.js b/tests/unit/tests/platforms/crossbrowsertesting/scriptjob.js index bee1795..543b010 100644 --- a/tests/unit/tests/platforms/crossbrowsertesting/scriptjob.js +++ b/tests/unit/tests/platforms/crossbrowsertesting/scriptjob.js @@ -97,12 +97,12 @@ if(process.version > 'v6') { var build = utils.buildDetails() var scriptJob = new ScriptJob('http://google.com', { browser: 'Chrome Mobile', - browserVersion: '61.0', + browserVersion: '33.0', os: 'Android', - osVersion: '7.0', - device: 'Android Nexus 6P', + osVersion: '4.2', + device: 'Android Galaxy S4', orientation: 'portrait', - resolution: '1440x2560' + resolution: '1080x1920' }, { build: build.build, test: build.test, diff --git a/tests/unit/tests/platforms/saucelabs-platform-close.js b/tests/unit/tests/platforms/saucelabs-platform-close.js new file mode 100644 index 0000000..2d0fc1a --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-close.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/close') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs-platform-job.js b/tests/unit/tests/platforms/saucelabs-platform-job.js new file mode 100644 index 0000000..f0438de --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-job.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/job') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs-platform-open.js b/tests/unit/tests/platforms/saucelabs-platform-open.js new file mode 100644 index 0000000..94bebf7 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-open.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/open') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs-platform-scriptjob.js b/tests/unit/tests/platforms/saucelabs-platform-scriptjob.js new file mode 100644 index 0000000..91f1b25 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-scriptjob.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/scriptjob') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs-platform-status.js b/tests/unit/tests/platforms/saucelabs-platform-status.js new file mode 100644 index 0000000..9b97fa0 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-status.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/status') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs-platform-stop.js b/tests/unit/tests/platforms/saucelabs-platform-stop.js new file mode 100644 index 0000000..987478c --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs-platform-stop.js @@ -0,0 +1,5 @@ +describe('SauceLabs', function() { + describe('Platform', function() { + require('./saucelabs/platform/stop') + }) +}) diff --git a/tests/unit/tests/platforms/saucelabs/platform.js b/tests/unit/tests/platforms/saucelabs/platform.js index 8a9cbcd..f1f981f 100644 --- a/tests/unit/tests/platforms/saucelabs/platform.js +++ b/tests/unit/tests/platforms/saucelabs/platform.js @@ -1,1906 +1,8 @@ -'use strict'; - -var - Bluebird = require('bluebird'), - retry = require('p-retry'), - fs = require('fs'), - chai = require('chai'), - spies = require('chai-spies'), - chaiAsPromised = require('chai-as-promised'), - Env = require('./../../../../../lib/core/env').Env, - platform = require('./../../../../../lib/platforms/saucelabs/platform'), - Platform = platform.Platform, - Manager = require('./../../../../../lib/platforms/saucelabs/manager').Manager, - ArchiveVars = require('./../../../../../lib/platforms/saucelabs/tunnel/archive').ArchiveVars, - utils = require('./utils') - -chai.use(spies) -chai.use(chaiAsPromised) - -var - expect = chai.expect, - should = chai.should() - -function checkRun(run) { - expect(run).to.not.be.undefined - expect(run.id).to.not.be.undefined - expect(run.id).to.be.a('string') -} - -const - script = (driver, webdriver) => { - return driver.getTitle() - .then(function(title) { - utils.log.debug(title) - return true - }) - }, - badScript = (driver, webdriver) => { - return driver.findElement({id : 'xyz'}) - } - describe('Platform', function() { - - describe('open', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete if no input is provided', function() { - return platform.open() - .should.be.fulfilled - }) - - it('should fail if capabilities input parameter is not of array type', function() { - function tester() { - platform.open({ local: true }) - } - expect(tester).to.throw('capabilitiesArr.forEach is not a function') - }) - - it('should fail if an unsupported capabilities key is provided', function() { - function tester() { - platform.open([{ - abc: 123 - }]) - } - expect(tester).to.throw('option abc is not allowed') - }) - - it('should open the platform by creating a tunnel process without identifier if local capability key is provided', function() { - return platform.open([{ - local: true - }]) - .then(() => { - platform.stopMonitoring = true - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - function waitForTunnel() { - const check = () => { - return Manager.withoutId() - .then(procs => { - if(procs.length) { - utils.log.debug('Got a tunnel process') - return true - } - utils.log.debug('No tunnels running yet') - throw new Error('no tunnels yet') - }) - }, - minTimeout = 1000, factor = 1, max = 240 - return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) - } - - it('should open the plaform by creating a tunnel process without identifier if local capability key is specified and then monitor and restart the tunnel process if it dies', function() { - platform.stopMonitoring = false - platform.tunnels = [ ] - return platform.open([{ - local: true - }]) - .then(() => { - return Manager.withoutId() - }) - .then(procs => { - if(1 !== procs.length) { - utils.log.warn('expected 1 tunnel to be running') - } - utils.stopProc(platform.tunnels[0].process.pid) - return true - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .then(() => { - return waitForTunnel() - }) - .then(() => { - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - if(process.version > 'v6') { - - describe('run', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail to create a run of a test job if no input is provided', function() { - return platform.run(undefined, undefined, undefined) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if required browser keys are not provided', function() { - return platform.run('http://www.piaxis.tech', { }, { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a test job if an supported browser key is provided', function() { - return platform.run('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '31.0' - }, { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a test job if an unspported capabilities key is provided', function() { - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '31.0' - }, { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of a test job if a remote url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '32.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job if a local url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '45.0' - }, { - timeout: 60, - local: true, - localIdentifier: 'platform-run-1', - screenshots: false, - video: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a test job for native runner case if a local url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '39.0' - }, { - timeout: 60, - local: true, - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - return utils.safeKillJob(platform.runs[run.id].jobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail to create a run of test jobs if no input is provided', function() { - return platform.runMultiple(undefined, undefined, undefined) - .should.be.rejectedWith('no browsers specified for createMultiple') - }) - - it('should fail to create a run of test jobs if required browser keys are not provided for even one browser', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'Windows' - }], { }) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of test jobs if an unsupported browser key is provided for even one browser', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '31.0' - }, { - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '31.0', - abc: 123 - }], { }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of test jobs if an unsupported capabilities key is provided', function() { - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '41.0' - }], { - abc: 123 - }) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should create a run of test jobs if a remote url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '40.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs if a local url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Firefox', - browserVersion: '39.0' - }, { - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '41.0' - }], { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of test jobs for native runner case if a local url and valid values for all mandatory parameters are provided', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '37.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }, - true) - .then(run => { - checkRun(run) - runId = run.id - return Promise.all([ - utils.safeKillJob(platform.runs[runId].jobs[0]), - utils.safeKillJob(platform.runs[runId].jobs[1]) - ]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runScript', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail to create a run of a script session if no input is provided', function() { - return platform.runScript(undefined, undefined, undefined, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if required browser keys are not provided', function() { - return platform.runScript('http://www.piaxis.tech', { }, { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of a script session if an unsupported browser key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - abc: 123, - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '31.0' - }, { }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if an unsupported capabilities key is provided', function() { - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '51.0' - }, { - abc: 123 - }, script) - .should.be.rejectedWith('option abc is not allowed') - }) - - it('should fail to create a run of a script session if the script parameter is not of function type', function() { - expect(()=>{ platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - })}) - .to.throw('invalid script') - }) - - it('should create a run of a script session if a remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Android', - osVersion: '4.4', - browser: 'Android Browser', - browserVersion: null, - device: 'LG Nexus 4 GoogleAPI Emulator' - }, { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session and tolerate errors thrown by the script if a remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'iOS', - osVersion: '9.3', - browser: 'Mobile Safari', - browserVersion: null, - device: 'iPhone 6s Plus Simulator' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of a script session if a local url and valid values for all mandatory parameters are provided', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '35.0' - }, { - timeout: 60, - build: build.build, - test: build.test, - project: build.project, - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - video: true - }, - script) - .then(run => { - checkRun(run) - return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - - describe('runScriptMultiple', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail to create a run of script sessions if no input is provided', function() { - expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) - .to.throw('no browsers specified for runScriptMultiple') - }) - - it('should fail to create a run of script sessions if required browser keys are not provided', function() { - return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) - .should.be.rejectedWith('required option browser missing') - }) - - it('should fail to create a run of script sessions if script parameter is not of function type', function() { - expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }], { - })}) - .to.throw('invalid script') - }) - - it('should create a run of script sessions if a remote url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '35.0' - }, { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Firefox', - browserVersion: '47.0' - }], { - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should create a run of script sessions and tolerate errors thrown by the script if a local url and valid values for all mandatory parameters are provided', function() { - var saveRun - var build = utils.buildDetails() - return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '39.0' - }, { - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '41.0' - }], { - build: build.build, - test: build.test, - project: build.project - }, - badScript - ) - .then(run => { - checkRun(run) - saveRun = run - return new Promise(resolve => { - setTimeout(()=>{resolve(true)}, 20000) - }) - }) - .then(() => { - let promises = [ - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), - utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) - ] - return Bluebird.all(promises) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - }) - } - - describe('stop', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if a non-existent run id is provided', function() { - function tester() { - platform.stop('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - if(process.version > 'v6') { - - it('should successfully take screenshots of and stop an ongoing run of test jobs accessing a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '44.0' - }, { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '34.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of test jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '7', - browser: 'Chrome', - browserVersion: '34.0' - }, { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Firefox', - browserVersion: '32.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop remaining test jobs of an ongoing run that access a local url using a tunnel with identifier after one test job is manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Sierra', - browser: 'Firefox', - browserVersion: '45.0' - }, { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '38.0' - }], { - local: true, - localIdentifier: 'my-test-id', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of a script job that accesses a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '45.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully take screenshots of and stop an ongoing run of a script job that accesses a remote url', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '35.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of a script job that accesses a local url', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Chrome', - browserVersion: '45.0' - }, { - local: true, - localIdentifier: 'tunnel-x', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of jobs that accesses a local url having one of the jobs failed', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Sierra', - browser: 'Firefox', - browserVersion: '42.0' - }, { - os: 'Android', - osVersion: '7.0', - browser: 'Android Browser', - browserVersion: null, - device: 'Android GoogleAPI Emulator' - }], { - local: true, - localIdentifier: 'tunnel-x', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id, true) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - } - - }) - - describe('status', function() { - - var platform = new Platform() - platform.stopMonitoring = true - this.timeout(0) - - it('should fail if a non-existent run id is provided', function() { - function tester() { - platform.status('1909aoopopo=oioid') - } - expect(tester).to.throw('no such run 1909aoopopo=oioid found') - }) - - if(process.version > 'v6') { - - it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '42.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "stopped" for a stopped run of test jobs that accessed a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Firefox', - browserVersion: '43.0' - }, { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "stopped" for a stopped run of test jobs that accessed a remote url having one failed job', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '54.0' - },{ - os: 'Android', - osVersion: '7.0', - browser: 'Android Browser', - browserVersion: null, - device: 'Android GoogleAPI Emulator' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId, true) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(2) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - if('stopped' !== results.jobs[1]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "running" for an ongoing run of a test job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8', - browser: 'Chrome', - browserVersion: '32.0' - }, { - local: true, - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('running' !== results.status) { - utils.log.warn('expected status to be running, not %s', results.status) - } - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - utils.log.error('error: ', err) - throw err - } - }) - .should.be.fulfilled - }) - - it('should say "stopped" for a stopped run of a test job that accessed a local url', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8.1', - browser: 'Firefox', - browserVersion: '46.0' - }, { - local: true, - localIdentifier: 'platform-run-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('stopped' !== results.status) { - utils.log.warn('expected test status to be stopped, not %s', results.status) - } - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - if('stopped' !== results.jobs[0]) { - utils.log.warn('expected job status to be stopped') - } - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel process is manually stopped before the test completes', function() { - var runId - var build = utils.buildDetails() - return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '31.0' - }, { - local: true, - localIdentifier: 'platform-run-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.be.oneOf(['messy', 'stopped']) - expect(results.jobs).to.not.be.undefined - expect(results.jobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '52.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('running') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.equal('none') - return platform.stop(runId) - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "stopped" for a stopped run of a script job that accesses a remote url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '45.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script, - () => { - return Promise.resolve(false) - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.equal('none') - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "running" for an ongoing run of a script job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '48.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('running' !== results.status) { - utils.log.warn('expected status to be running, not %s', results.status) - } - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to keep running') - } - return platform.stop(runId) - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - utils.log.error('error: ', err) - throw err - } - }) - .should.be.fulfilled - }) - - it('should say "stopped" for a stopped run of a script job that accesses a local url', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Chrome', - browserVersion: '41.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.stop(runId) - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - expect(results.status).to.equal('stopped') - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.scriptJobs[0]).to.equal('stopped') - expect(results.tunnel).to.not.be.undefined - if('running' !== results.tunnel) { - utils.log.warn('expected tunnel to be running') - } - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should say "messy" for an ongoing run of a script job that accesses a local url after the tunnel process is stopped manually before the test completes', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Firefox', - browserVersion: '35.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].tunnel.stop() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return platform.status(runId) - }) - .then(results => { - expect(results).to.not.be.undefined - expect(results.status).to.not.be.undefined - if('messy' !== results.status) { - utils.log.warn('expected results status to be messy') - } - expect(results.scriptJobs).to.not.be.undefined - expect(results.scriptJobs).to.have.lengthOf(1) - expect(results.tunnel).to.not.be.undefined - expect(results.tunnel).to.equal('stopped') - return platform.stop(runId) - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - }) - - describe('close', function() { - - var platform = new Platform() - this.timeout(0) - - it('should silently complete in case there are no ongoing runs', function() { - return platform.close() - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - if(process.version > 'v6') { - - it('should successfully close the platform after stopping an ongoing run of test jobs that access a remote url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '32.0' - }, { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '39.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should silently close the platform if called after stopping an ongoing run of test jobs that access a remote url manually by calling "stop" method', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://www.piaxis.tech', [{ - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '45.0' - }, { - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Chrome', - browserVersion: '39.0' - }], { - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully close the platform after stopping an ongoing run of test jobs that access a local url', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '32.0' - }, { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Chrome', - browserVersion: '48.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnel to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully shutdown the tunnel process and close the platform if called after manually stopping an ongoing run of test jobs that access a local url by calling the "stop" method', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '8.1', - browser: 'Chrome', - browserVersion: '47.0' - }, { - os: 'OS X', - osVersion: 'Mavericks', - browser: 'Chrome', - browserVersion: '39.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop remaining test jobs of an ongoing run that access a local url, shutdown the associated tunnel with identifier process, and close the platform if called after one of the test jobs of the run was manually stopped', function() { - var runId - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'OS X', - osVersion: 'Yosemite', - browser: 'Chrome', - browserVersion: '51.0' - }, { - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '37.0' - }], { - local: true, - localIdentifier: 'my-test-id', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].jobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should stop test jobs of an ongoing run of test jobs that access a local url and close the platform if called after manually stopping associated tunnels', function() { - var build = utils.buildDetails() - return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ - os: 'Windows', - osVersion: '10', - browser: 'Chrome', - browserVersion: '53.0' - }, { - os: 'Windows', - osVersion: '8', - browser: 'Firefox', - browserVersion: '40.0' - }], { - local: true, - localIdentifier: 'platform-run-mult-1', - build: build.build, - test: build.test, - project: build.project - }) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should successfully stop an ongoing run of a script test that accesses a remote url and close the platform', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'OS X', - osVersion: 'Sierra', - browser: 'Chrome', - browserVersion: '53.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should silently close the platform if called after manually stopping an ongoing run of a script test that accesses a remote url by calling "stop" method', function() { - var build = utils.buildDetails() - return platform.runScript('http://www.piaxis.tech', { - os: 'Windows', - osVersion: '10', - browser: 'Firefox', - browserVersion: '38.0' - }, { - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should shutdown the associated tunnel processes and close the platform if called after manually stopping an ongoing run of a script test that accesses a local url by calling the "stop" method', function() { - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '8.1', - browser: 'Chrome', - browserVersion: '48.0' - }, { - local: true, - localIdentifier: 'platform-run-scr-1', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - return platform.stop(run.id) - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should shutdown the associated tunnel process and close the platform if called after stopping a script test of an ongoing run that accesses a local url manually', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'Windows', - osVersion: '7', - browser: 'Firefox', - browserVersion: '36.0' - }, { - local: true, - localIdentifier: 'my-test-id', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - runId = run.id - return platform.runs[runId].scriptJobs[0].stop() - }) - .then(() => { - return platform.close() - }) - .catch(err => { - if(err && err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - else { - throw err - } - }) - .then(() => { - return utils.ensureZeroTunnels() - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - - it('should stop scripts jobs of an ongoing run of script jobs that access a local url and close the platform if called after manually stopping associated tunnels', function() { - var runId - var build = utils.buildDetails() - return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { - os: 'OS X', - osVersion: 'El Capitan', - browser: 'Chrome', - browserVersion: '42.0' - }, { - local: true, - localIdentifier: 'my-test-id', - screenshots: true, - build: build.build, - test: build.test, - project: build.project - }, - script) - .then(run => { - checkRun(run) - platform.stopMonitoring = true - return utils.ensureZeroTunnels() - }) - .catch(err => { - if(err.message && err.message.match(/Process: already stopped/)) { - utils.log.warn('did not expect tunnels to be stopped already') - return true - } - throw err - }) - .then(() => { - return platform.close() - }) - .then(() => { - return utils.tunnels() - }) - .then(tunnels => { - expect(tunnels.length).to.equal(0) - return true - }) - .catch(err => { - utils.log.error('error: ', err) - throw err - }) - .should.be.fulfilled - }) - } - - }) - + require('./platform/open') + require('./platform/job') + require('./platform/scriptjob') + require('./platform/status') + require('./platform/stop') + require('./platform/close') }) diff --git a/tests/unit/tests/platforms/saucelabs/platform/close.js b/tests/unit/tests/platforms/saucelabs/platform/close.js new file mode 100644 index 0000000..f35c373 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/close.js @@ -0,0 +1,484 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('close', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete in case there are no ongoing runs', function() { + return platform.close() + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + if(process.version > 'v6') { + + it('should successfully close the platform after stopping an ongoing run of test jobs that access a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '32.0' + }, { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '39.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should silently close the platform if called after stopping an ongoing run of test jobs that access a remote url manually by calling "stop" method', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Chrome', + browserVersion: '39.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully close the platform after stopping an ongoing run of test jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '32.0' + }, { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Chrome', + browserVersion: '48.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully shutdown the tunnel process and close the platform if called after manually stopping an ongoing run of test jobs that access a local url by calling the "stop" method', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '8.1', + browser: 'Chrome', + browserVersion: '47.0' + }, { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '39.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop remaining test jobs of an ongoing run that access a local url, shutdown the associated tunnel with identifier process, and close the platform if called after one of the test jobs of the run was manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Chrome', + browserVersion: '51.0' + }, { + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '37.0' + }], { + local: true, + localIdentifier: 'my-test-id', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should stop test jobs of an ongoing run of test jobs that access a local url and close the platform if called after manually stopping associated tunnels', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '53.0' + }, { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '40.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of a script test that accesses a remote url and close the platform', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '53.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should silently close the platform if called after manually stopping an ongoing run of a script test that accesses a remote url by calling "stop" method', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '38.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should shutdown the associated tunnel processes and close the platform if called after manually stopping an ongoing run of a script test that accesses a local url by calling the "stop" method', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8.1', + browser: 'Chrome', + browserVersion: '48.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should shutdown the associated tunnel process and close the platform if called after stopping a script test of an ongoing run that accesses a local url manually', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '36.0' + }, { + local: true, + localIdentifier: 'my-test-id', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].scriptJobs[0].stop() + }) + .then(() => { + return platform.close() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should stop scripts jobs of an ongoing run of script jobs that access a local url and close the platform if called after manually stopping associated tunnels', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Chrome', + browserVersion: '42.0' + }, { + local: true, + localIdentifier: 'my-test-id', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + throw err + }) + .then(() => { + return platform.close() + }) + .then(() => { + return utils.tunnels() + }) + .then(tunnels => { + expect(tunnels.length).to.equal(0) + return true + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + +}) diff --git a/tests/unit/tests/platforms/saucelabs/platform/job.js b/tests/unit/tests/platforms/saucelabs/platform/job.js new file mode 100644 index 0000000..54f11c6 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/job.js @@ -0,0 +1,312 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +if(process.version > 'v6') { + + describe('run', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail to create a run of a test job if no input is provided', function() { + return platform.run(undefined, undefined, undefined) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if required browser keys are not provided', function() { + return platform.run('http://www.piaxis.tech', { }, { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a test job if an supported browser key is provided', function() { + return platform.run('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '31.0' + }, { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a test job if an unspported capabilities key is provided', function() { + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '31.0' + }, { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of a test job if a remote url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '32.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job if a local url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '45.0' + }, { + timeout: 60, + local: true, + localIdentifier: 'platform-run-1', + screenshots: false, + video: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a test job for native runner case if a local url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '39.0' + }, { + timeout: 60, + local: true, + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + return utils.safeKillJob(platform.runs[run.id].jobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + + describe('runMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail to create a run of test jobs if no input is provided', function() { + return platform.runMultiple(undefined, undefined, undefined) + .should.be.rejectedWith('no browsers specified for createMultiple') + }) + + it('should fail to create a run of test jobs if required browser keys are not provided for even one browser', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'Windows' + }], { }) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of test jobs if an unsupported browser key is provided for even one browser', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '31.0' + }, { + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '31.0', + abc: 123 + }], { }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of test jobs if an unsupported capabilities key is provided', function() { + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '41.0' + }], { + abc: 123 + }) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should create a run of test jobs if a remote url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '40.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs if a local url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Firefox', + browserVersion: '39.0' + }, { + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '41.0' + }], { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of test jobs for native runner case if a local url and valid values for all mandatory parameters are provided', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html?_=1414190941', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '37.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }, + true) + .then(run => { + checkRun(run) + runId = run.id + return Promise.all([ + utils.safeKillJob(platform.runs[runId].jobs[0]), + utils.safeKillJob(platform.runs[runId].jobs[1]) + ]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + +} diff --git a/tests/unit/tests/platforms/saucelabs/platform/open.js b/tests/unit/tests/platforms/saucelabs/platform/open.js new file mode 100644 index 0000000..2e51593 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/open.js @@ -0,0 +1,125 @@ +'use strict'; + +var + retry = require('p-retry'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + Manager = require('./../../../../../../lib/platforms/saucelabs/manager').Manager, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +describe('open', function() { + + var platform = new Platform() + this.timeout(0) + + it('should silently complete if no input is provided', function() { + return platform.open() + .should.be.fulfilled + }) + + it('should fail if capabilities input parameter is not of array type', function() { + function tester() { + platform.open({ local: true }) + } + expect(tester).to.throw('capabilitiesArr.forEach is not a function') + }) + + it('should fail if an unsupported capabilities key is provided', function() { + function tester() { + platform.open([{ + abc: 123 + }]) + } + expect(tester).to.throw('option abc is not allowed') + }) + + it('should open the platform by creating a tunnel process without identifier if local capability key is provided', function() { + return platform.open([{ + local: true + }]) + .then(() => { + platform.stopMonitoring = true + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + function waitForTunnel() { + const check = () => { + return Manager.withoutId() + .then(procs => { + if(procs.length) { + utils.log.debug('Got a tunnel process') + return true + } + utils.log.debug('No tunnels running yet') + throw new Error('no tunnels yet') + }) + }, + minTimeout = 1000, factor = 1, max = 240 + return retry(check, {minTimeout: minTimeout, factor: factor, retries: max}) + } + + it('should open the plaform by creating a tunnel process without identifier if local capability key is specified and then monitor and restart the tunnel process if it dies', function() { + platform.stopMonitoring = false + platform.tunnels = [ ] + return platform.open([{ + local: true + }]) + .then(() => { + return Manager.withoutId() + }) + .then(procs => { + if(1 !== procs.length) { + utils.log.warn('expected 1 tunnel to be running') + } + utils.stopProc(platform.tunnels[0].process.pid) + return true + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .then(() => { + return waitForTunnel() + }) + .then(() => { + platform.stopMonitoring = true + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + +}) diff --git a/tests/unit/tests/platforms/saucelabs/platform/scriptjob.js b/tests/unit/tests/platforms/saucelabs/platform/scriptjob.js new file mode 100644 index 0000000..dc26f1f --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/scriptjob.js @@ -0,0 +1,299 @@ +'use strict'; + +var + Bluebird = require('bluebird'), + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + }, + badScript = (driver, webdriver) => { + return driver.findElement({id : 'xyz'}) + } + +if(process.version > 'v6') { + + describe('runScript', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail to create a run of a script session if no input is provided', function() { + return platform.runScript(undefined, undefined, undefined, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if required browser keys are not provided', function() { + return platform.runScript('http://www.piaxis.tech', { }, { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of a script session if an unsupported browser key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + abc: 123, + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '31.0' + }, { }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if an unsupported capabilities key is provided', function() { + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '51.0' + }, { + abc: 123 + }, script) + .should.be.rejectedWith('option abc is not allowed') + }) + + it('should fail to create a run of a script session if the script parameter is not of function type', function() { + expect(()=>{ platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + })}) + .to.throw('invalid script') + }) + + it('should create a run of a script session if a remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Android', + osVersion: '4.4', + browser: 'Android Browser', + browserVersion: null, + device: 'LG Nexus 4 GoogleAPI Emulator' + }, { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session and tolerate errors thrown by the script if a remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'iOS', + osVersion: '9.3', + browser: 'Mobile Safari', + browserVersion: null, + device: 'iPhone 6s Plus Simulator' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + return utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of a script session if a local url and valid values for all mandatory parameters are provided', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '35.0' + }, { + timeout: 60, + build: build.build, + test: build.test, + project: build.project, + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + video: true + }, + script) + .then(run => { + checkRun(run) + return utils.safeStopScript(platform.runs[run.id].scriptJobs[0]) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + + describe('runScriptMultiple', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail to create a run of script sessions if no input is provided', function() { + expect(()=>{platform.runScriptMultiple(undefined, undefined, undefined, script)}) + .to.throw('no browsers specified for runScriptMultiple') + }) + + it('should fail to create a run of script sessions if required browser keys are not provided', function() { + return platform.runScriptMultiple('http://www.piaxis.tech', [{ }], { }, script) + .should.be.rejectedWith('required option browser missing') + }) + + it('should fail to create a run of script sessions if script parameter is not of function type', function() { + expect(()=>{platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }], { + })}) + .to.throw('invalid script') + }) + + it('should create a run of script sessions if a remote url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '35.0' + }, { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Firefox', + browserVersion: '47.0' + }], { + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should create a run of script sessions and tolerate errors thrown by the script if a local url and valid values for all mandatory parameters are provided', function() { + var saveRun + var build = utils.buildDetails() + return platform.runScriptMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '39.0' + }, { + os: 'Windows', + osVersion: '7', + browser: 'Firefox', + browserVersion: '41.0' + }], { + build: build.build, + test: build.test, + project: build.project + }, + badScript + ) + .then(run => { + checkRun(run) + saveRun = run + return new Promise(resolve => { + setTimeout(()=>{resolve(true)}, 20000) + }) + }) + .then(() => { + let promises = [ + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[0]), + utils.safeStopScript(platform.runs[saveRun.id].scriptJobs[1]) + ] + return Bluebird.all(promises) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + }) + +} diff --git a/tests/unit/tests/platforms/saucelabs/platform/status.js b/tests/unit/tests/platforms/saucelabs/platform/status.js new file mode 100644 index 0000000..8fe82e9 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/status.js @@ -0,0 +1,550 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('status', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if a non-existent run id is provided', function() { + function tester() { + platform.status('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + if(process.version > 'v6') { + + it('should say "running" for an ongoing run of a test job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '42.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "stopped" for a stopped run of test jobs that accessed a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Firefox', + browserVersion: '43.0' + }, { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "stopped" for a stopped run of test jobs that accessed a remote url having one failed job', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '54.0' + },{ + os: 'Android', + osVersion: '7.0', + browser: 'Android Browser', + browserVersion: null, + device: 'Android GoogleAPI Emulator' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId, true) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(2) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + if('stopped' !== results.jobs[1]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "running" for an ongoing run of a test job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8', + browser: 'Chrome', + browserVersion: '32.0' + }, { + local: true, + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('running' !== results.status) { + utils.log.warn('expected status to be running, not %s', results.status) + } + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.jobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + utils.log.error('error: ', err) + throw err + } + }) + .should.be.fulfilled + }) + + it('should say "stopped" for a stopped run of a test job that accessed a local url', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '8.1', + browser: 'Firefox', + browserVersion: '46.0' + }, { + local: true, + localIdentifier: 'platform-run-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('stopped' !== results.status) { + utils.log.warn('expected test status to be stopped, not %s', results.status) + } + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + if('stopped' !== results.jobs[0]) { + utils.log.warn('expected job status to be stopped') + } + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "messy" for an ongoing run of a test job that accesses a local url after the tunnel process is manually stopped before the test completes', function() { + var runId + var build = utils.buildDetails() + return platform.run('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '31.0' + }, { + local: true, + localIdentifier: 'platform-run-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.be.oneOf(['messy', 'stopped']) + expect(results.jobs).to.not.be.undefined + expect(results.jobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "running" for an ongoing run of a script job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'OS X', + osVersion: 'Sierra', + browser: 'Chrome', + browserVersion: '52.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('running') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.equal('none') + return platform.stop(runId) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "stopped" for a stopped run of a script job that accesses a remote url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '45.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script, + () => { + return Promise.resolve(false) + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.equal('none') + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "running" for an ongoing run of a script job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '48.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('running' !== results.status) { + utils.log.warn('expected status to be running, not %s', results.status) + } + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.be.oneOf(['running', 'queue']) + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to keep running') + } + return platform.stop(runId) + }) + .catch(err => { + if(err && err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnels to be stopped already') + return true + } + else { + utils.log.error('error: ', err) + throw err + } + }) + .should.be.fulfilled + }) + + it('should say "stopped" for a stopped run of a script job that accesses a local url', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Chrome', + browserVersion: '41.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.stop(runId) + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + expect(results.status).to.equal('stopped') + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.scriptJobs[0]).to.equal('stopped') + expect(results.tunnel).to.not.be.undefined + if('running' !== results.tunnel) { + utils.log.warn('expected tunnel to be running') + } + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should say "messy" for an ongoing run of a script job that accesses a local url after the tunnel process is stopped manually before the test completes', function() { + var runId + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Firefox', + browserVersion: '35.0' + }, { + local: true, + localIdentifier: 'platform-run-scr-1', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].tunnel.stop() + }) + .catch(err => { + if(err.message && err.message.match(/Process: already stopped/)) { + utils.log.warn('did not expect tunnel to be stopped already') + return true + } + else { + throw err + } + }) + .then(() => { + return platform.status(runId) + }) + .then(results => { + expect(results).to.not.be.undefined + expect(results.status).to.not.be.undefined + if('messy' !== results.status) { + utils.log.warn('expected results status to be messy') + } + expect(results.scriptJobs).to.not.be.undefined + expect(results.scriptJobs).to.have.lengthOf(1) + expect(results.tunnel).to.not.be.undefined + expect(results.tunnel).to.equal('stopped') + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + } + +}) diff --git a/tests/unit/tests/platforms/saucelabs/platform/stop.js b/tests/unit/tests/platforms/saucelabs/platform/stop.js new file mode 100644 index 0000000..ab49a26 --- /dev/null +++ b/tests/unit/tests/platforms/saucelabs/platform/stop.js @@ -0,0 +1,265 @@ +'use strict'; + +var + chai = require('chai'), + spies = require('chai-spies'), + chaiAsPromised = require('chai-as-promised'), + platform = require('./../../../../../../lib/platforms/saucelabs/platform'), + Platform = platform.Platform, + utils = require('./../utils') + +chai.use(spies) +chai.use(chaiAsPromised) + +var + expect = chai.expect, + should = chai.should() + +function checkRun(run) { + expect(run).to.not.be.undefined + expect(run.id).to.not.be.undefined + expect(run.id).to.be.a('string') +} + +const + script = (driver, webdriver) => { + return driver.getTitle() + .then(function(title) { + utils.log.debug(title) + return true + }) + } + +describe('stop', function() { + + var platform = new Platform() + platform.stopMonitoring = true + this.timeout(0) + + it('should fail if a non-existent run id is provided', function() { + function tester() { + platform.stop('1909aoopopo=oioid') + } + expect(tester).to.throw('no such run 1909aoopopo=oioid found') + }) + + if(process.version > 'v6') { + + it('should successfully take screenshots of and stop an ongoing run of test jobs accessing a remote url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://www.piaxis.tech', [{ + os: 'Windows', + osVersion: '10', + browser: 'Firefox', + browserVersion: '44.0' + }, { + os: 'OS X', + osVersion: 'Mavericks', + browser: 'Chrome', + browserVersion: '34.0' + }], { + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of test jobs that access a local url', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'Windows', + osVersion: '7', + browser: 'Chrome', + browserVersion: '34.0' + }, { + os: 'OS X', + osVersion: 'El Capitan', + browser: 'Firefox', + browserVersion: '32.0' + }], { + local: true, + localIdentifier: 'platform-run-mult-1', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop remaining test jobs of an ongoing run that access a local url using a tunnel with identifier after one test job is manually stopped', function() { + var runId + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Sierra', + browser: 'Firefox', + browserVersion: '45.0' + }, { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '38.0' + }], { + local: true, + localIdentifier: 'my-test-id', + build: build.build, + test: build.test, + project: build.project + }) + .then(run => { + checkRun(run) + runId = run.id + return platform.runs[runId].jobs[0].stop() + }) + .then(() => { + return platform.stop(runId) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of a script job that accesses a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '10', + browser: 'Chrome', + browserVersion: '45.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully take screenshots of and stop an ongoing run of a script job that accesses a remote url', function() { + var build = utils.buildDetails() + return platform.runScript('http://www.piaxis.tech', { + os: 'Windows', + osVersion: '8', + browser: 'Firefox', + browserVersion: '35.0' + }, { + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of a script job that accesses a local url', function() { + var build = utils.buildDetails() + return platform.runScript('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', { + os: 'OS X', + osVersion: 'Yosemite', + browser: 'Chrome', + browserVersion: '45.0' + }, { + local: true, + localIdentifier: 'tunnel-x', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + it('should successfully stop an ongoing run of jobs that accesses a local url having one of the jobs failed', function() { + var build = utils.buildDetails() + return platform.runMultiple('http://build.cross-browser-tests-runner.org:3000/tests/pages/tests.html', [{ + os: 'OS X', + osVersion: 'Sierra', + browser: 'Firefox', + browserVersion: '42.0' + }, { + os: 'Android', + osVersion: '7.0', + browser: 'Android Browser', + browserVersion: null, + device: 'Android GoogleAPI Emulator' + }], { + local: true, + localIdentifier: 'tunnel-x', + screenshots: true, + build: build.build, + test: build.test, + project: build.project + }, + script) + .then(run => { + checkRun(run) + return platform.stop(run.id, true) + }) + .then(() => { + return utils.ensureZeroTunnels() + }) + .catch(err => { + utils.log.error('error: ', err) + throw err + }) + .should.be.fulfilled + }) + + } + +}) diff --git a/tests/unit/tests/saucelabs-platform-close.js b/tests/unit/tests/saucelabs-platform-close.js new file mode 100644 index 0000000..1f33bfa --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-close.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-close') +}) diff --git a/tests/unit/tests/saucelabs-platform-job.js b/tests/unit/tests/saucelabs-platform-job.js new file mode 100644 index 0000000..f8a7f97 --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-job.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-job') +}) diff --git a/tests/unit/tests/saucelabs-platform-open.js b/tests/unit/tests/saucelabs-platform-open.js new file mode 100644 index 0000000..87537c4 --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-open.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-open') +}) diff --git a/tests/unit/tests/saucelabs-platform-scriptjob.js b/tests/unit/tests/saucelabs-platform-scriptjob.js new file mode 100644 index 0000000..66db372 --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-scriptjob.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-scriptjob') +}) diff --git a/tests/unit/tests/saucelabs-platform-status.js b/tests/unit/tests/saucelabs-platform-status.js new file mode 100644 index 0000000..98d4252 --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-status.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-status') +}) diff --git a/tests/unit/tests/saucelabs-platform-stop.js b/tests/unit/tests/saucelabs-platform-stop.js new file mode 100644 index 0000000..d6e702e --- /dev/null +++ b/tests/unit/tests/saucelabs-platform-stop.js @@ -0,0 +1,3 @@ +describe('Platforms', function() { + require('./platforms/saucelabs-platform-stop') +})