Permalink
Browse files

chore(travis): run tests against angular snapshot (#10229)

* chore: run tests against angular snapshot

* Now runs unit tests against Angular snapshot
* Exported the version download script from the `test-versions.sh` script from Jenkins (allows us to test against snapshot)

* Verify that folder is a repository

* Input elements with selection need to be focused

* Unique identifiers for travis modes

* Print user agent for failing test..

* Updates
  • Loading branch information...
1 parent e8d29db commit 366c1b623e1589b3053634b49bcf482a956026ae @DevVersion DevVersion committed with ThomasBurleson Jan 6, 2017
View
@@ -14,17 +14,18 @@ env:
- BROWSER_STACK_ACCESS_KEY=BWCd4SynLzdDcv8xtzsB
- secure: X7CNmOMemAJ9Jqrsmv6MXyeh8n8TIL5CKzE9LYsZUbsyKo0l5CyyysJq0y/AbpQS6awsSv2qP/cZ/kand6r6z0wMFbUcxa4HjMZEfRwv3sGtwj1OKJko/GvjcZQzD54FtHy1NU7wR0mYhAlE5IwH7f8bMa/nUiijgD/TOCTtKH8=
matrix:
- - NG_VERSION=1.5.9
- - NG_VERSION=1.6.1
+ - NG_VERSION=1.5
+ - NG_VERSION=snapshot
matrix:
fast_finish: true
allow_failures:
- - env: "NG_VERSION=1.6.1"
+ - env: "NG_VERSION=snapshot"
cache:
directories:
- node_modules/
+ - tmp/angular.js
branches:
only:
@@ -28,8 +28,8 @@ module.exports = function(config) {
sauceLabs: {
testName: 'Angular Material 1.x Unit Tests',
- tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
- build: 'Build ' + process.env.TRAVIS_BUILD_NUMBER + '.' + process.env.TRAVIS_BUILD_ID,
+ tunnelIdentifier: process.env.TRAVIS_JOB_ID,
+ build: 'Build ' + process.env.TRAVIS_JOB_ID,
// Don't start the Sauce Connector. We use the integrated from Travis CI.
startConnect: false,
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Bash Script to replace the current Angular version in the node modules.
+# Accepts a version as an argument. The resolved version will be downloaded, extracted and replaced.
+
+CDN="https://code.angularjs.org"
+ANGULAR_FILES=(
+ angular
+ angular-animate
+ angular-route
+ angular-aria
+ angular-messages
+ angular-mocks
+ angular-sanitize
+ angular-touch
+)
+
+# The version will be specified from the first argument.
+VERSION=$1
+
+# Download the Angular repository for `find-max-versions` if not present.
+if [ ! -e ./tmp/angular.js/.git ]; then
+ # Cleanup potential broken repository files.
+ rm -rf ./tmp/angular.js/
+ git clone https://github.com/angular/angular.js ./tmp/angular.js
+fi
+
+# this will guarantee that we have the latest versions
+# of AngularJS when testing material in case the HEAD
+# of ./tmp/angular.js is outdated.
+git --git-dir ./tmp/angular.js/.git fetch
+
+# Determines the exact version name and the download URL.
+if [ $VERSION == "snapshot" ]; then
+ ZIP_FILE_SHA=$(curl "$CDN/snapshot/version.txt")
+ ZIP_URL="$CDN/snapshot/angular-$ZIP_FILE_SHA.zip"
+else
+ LATEST_VERSION=$(node ./scripts/find-max-version.js $VERSION)
+ if [ ! $LATEST_VERSION ]; then
+ echo "Error: version "$VERSION" of angular does not exist..."
+ exit 1
+ fi
+
+ VERSION=$LATEST_VERSION
+ ZIP_FILE_SHA=$VERSION
+ ZIP_URL="$CDN/$VERSION/angular-$VERSION.zip"
+fi
+
+ZIP_FILE="angular-$VERSION.zip"
+ZIP_FILE_PATH="./tmp/$ZIP_FILE"
+BASE_DIR="./tmp/angular-$VERSION"
+
+# Downloads and extracts the resolved Angular version.
+rm -rf $BASE_DIR
+curl $ZIP_URL > $ZIP_FILE_PATH
+unzip -q -d $BASE_DIR $ZIP_FILE_PATH
+mv "$BASE_DIR/angular-$ZIP_FILE_SHA" "$BASE_DIR/files"
+
+# Copies over all Angular files into the node modules.
+for ANGULAR_FILE in "${ANGULAR_FILES[@]}"; do
+ REPLACEMENT_FILE="$BASE_DIR/files/$ANGULAR_FILE.js"
+ MIN_REPLACEMENT_FILE="$BASE_DIR/files/$ANGULAR_FILE.min.js"
+
+ NODE_LIB_FILE="./node_modules/$ANGULAR_FILE/$ANGULAR_FILE.js"
+ MIN_NODE_LIB_FILE="./node_modules/$ANGULAR_FILE/$ANGULAR_FILE.min.js"
+
+ rm -f $NODE_LIB_FILE
+ cp $REPLACEMENT_FILE $NODE_LIB_FILE
+ echo "[copy] copied over $REPLACEMENT_FILE to $NODE_LIB_FILE"
+
+ if [ -e $MIN_NODE_LIB_FILE ]; then
+ rm $MIN_NODE_LIB_FILE
+ fi
+
+ if [ -e $MIN_REPLACEMENT_FILE ]; then
+ cp $MIN_REPLACEMENT_FILE $MIN_NODE_LIB_FILE
+ fi
+ echo "[copy] copied over $MIN_REPLACEMENT_FILE to $MIN_NODE_LIB_FILE"
+done
@@ -17,7 +17,7 @@ CONNECT_ARGS="--readyfile $SAUCE_READY_FILE"
# Apply the Travis Job Number to the tunnel
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then
- CONNECT_ARGS="$CONNECT_ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER"
+ CONNECT_ARGS="$CONNECT_ARGS --tunnel-identifier $TRAVIS_JOB_ID"
fi
echo "Starting Sauce Connector Tunnel"
@@ -22,89 +22,25 @@
# Available Options are: 1.X, 1.X.X, 1.X.X-(beta|rc).X or snapshot
VERSIONS=(1.3 1.4 1.5 snapshot)
-BROWSERS="Firefox,Chrome,Safari"
+BROWSERS="Firefox"
#
# DO NOT EDIT PAST THIS LINE
#
-CDN="https://code.angularjs.org"
FAILED=false
-ANGULAR_FILES=(
- angular
- angular-animate
- angular-route
- angular-aria
- angular-messages
- angular-mocks
- angular-sanitize
- angular-touch
-)
if [ ${#VERSIONS[@]} == 0 ]; then
echo "Error: please specify one or more versions of AngularJS to test..."
exit 1
fi;
-if [ ! -e ./tmp ]; then
- mkdir -p ./tmp
-fi
-
-if [ ! -e ./tmp/angular.js ]; then
- git clone https://github.com/angular/angular.js ./tmp/angular.js
-fi
-# this will guarantee that we have the latest versions
-# of AngularJS when testing material in case the HEAD
-# of ./tmp/angular.js is outdated.
-git --git-dir ./tmp/angular.js/.git fetch
for VERSION in "${VERSIONS[@]}"; do
- if [ $VERSION == "snapshot" ]; then
- ZIP_FILE_SHA=$(curl "$CDN/snapshot/version.txt")
- ZIP_URL="$CDN/snapshot/angular-$ZIP_FILE_SHA.zip"
- else
- LATEST_VERSION=$(node ./scripts/find-max-version.js $VERSION)
- if [ ! $LATEST_VERSION ]; then
- echo "Error: version "$VERSION" of angular does not exist..."
- exit 1
- fi
-
- VERSION=$LATEST_VERSION
- ZIP_FILE_SHA=$VERSION
- ZIP_URL="$CDN/$VERSION/angular-$VERSION.zip"
- fi
-
- ZIP_FILE="angular-$VERSION.zip"
- ZIP_FILE_PATH="./tmp/$ZIP_FILE"
- BASE_DIR="./tmp/angular-$VERSION"
-
- rm -rf $BASE_DIR
- curl $ZIP_URL > $ZIP_FILE_PATH
- unzip -q -d $BASE_DIR $ZIP_FILE_PATH
- mv "$BASE_DIR/angular-$ZIP_FILE_SHA" "$BASE_DIR/files"
echo "\n\n--- Testing AngularMaterial against AngularJS (${VERSION}) ---\n"
- for ANGULAR_FILE in "${ANGULAR_FILES[@]}"; do
- REPLACEMENT_FILE="$BASE_DIR/files/$ANGULAR_FILE.js"
- MIN_REPLACEMENT_FILE="$BASE_DIR/files/$ANGULAR_FILE.min.js"
-
- NODE_LIB_FILE="./node_modules/$ANGULAR_FILE/$ANGULAR_FILE.js"
- MIN_NODE_LIB_FILE="./node_modules/$ANGULAR_FILE/$ANGULAR_FILE.min.js"
-
- rm $NODE_LIB_FILE
- cp $REPLACEMENT_FILE $NODE_LIB_FILE
- echo "[copy] copied over $REPLACEMENT_FILE to $NODE_LIB_FILE"
-
- if [ -e $MIN_NODE_LIB_FILE ]; then
- rm $MIN_NODE_LIB_FILE
- fi
-
- if [ -e $MIN_REPLACEMENT_FILE ]; then
- cp $MIN_REPLACEMENT_FILE $MIN_NODE_LIB_FILE
- fi
- echo "[copy] copied over $MIN_REPLACEMENT_FILE to $MIN_NODE_LIB_FILE"
- done
+ ./scripts/fetch-angular-version.sh $VERSION
echo "\n"
pwd
@@ -3,10 +3,12 @@
# Terminate the execution if anything fails in the pipeline.
set -e
+# Ensure that scripts will run from project dir.
+cd $(dirname $0)/..
+
# When Travis CI specifies an Angular version, try to install those for tests.
if [[ -n "$NG_VERSION" ]]; then
- npm i angular@$NG_VERSION \
- angular-{animate,aria,messages,mocks,route,sanitize,touch}@$NG_VERSION
+ ./scripts/fetch-angular-version.sh "$NG_VERSION"
fi
# Run our check to make sure all tests will actually run
@@ -647,24 +647,27 @@ describe('md-input-container directive', function() {
});
it('should select the input value on focus', inject(function($timeout) {
- var container = setup('md-select-on-focus');
- var input = container.find('input');
- input.val('Auto Text Select');
+ var input = $compile('<input md-select-on-focus value="Text">')($rootScope);
- document.body.appendChild(container[0]);
+ document.body.appendChild(input[0]);
expect(isTextSelected(input[0])).toBe(false);
+ input.focus();
input.triggerHandler('focus');
+ $timeout.flush();
expect(isTextSelected(input[0])).toBe(true);
- document.body.removeChild(container[0]);
+ input.remove();
+
function isTextSelected(input) {
- // The selection happens in a timeout which needs to be flushed.
- $timeout.flush();
- return input.selectionStart === 0 && input.selectionEnd == input.value.length;
+ if (typeof input.selectionStart === "number") {
+ return input.selectionStart === 0 && input.selectionEnd === input.value.length;
+ } else if (typeof document.selection !== "undefined") {
+ return document.selection.createRange().text === input.value;
+ }
}
}));

0 comments on commit 366c1b6

Please sign in to comment.