Skip to content

build: fix small browser test coverage #11970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,864 changes: 2,181 additions & 1,683 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,14 @@
"image-diff": "^1.6.3",
"jasmine-core": "2.8.0",
"jsonwebtoken": "^7.4.1",
"karma": "^1.7.1",
"karma": "^2.0.4",
"karma-browserstack-launcher": "^1.3.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-sauce-launcher": "^1.2.0",
"karma-sharding": "^4.4.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"madge": "^2.2.0",
"magic-string": "^0.22.4",
"minimatch": "^3.0.4",
Expand Down
2 changes: 1 addition & 1 deletion scripts/saucelabs/start-tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e -o pipefail

TUNNEL_FILE="sc-4.4.10-linux.tar.gz"
TUNNEL_FILE="sc-4.4.12-linux.tar.gz"
TUNNEL_URL="https://saucelabs.com/downloads/${TUNNEL_FILE}"
TUNNEL_DIR="/tmp/saucelabs-connect"

Expand Down
12 changes: 10 additions & 2 deletions src/cdk/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,16 @@ describe('CdkTable', () => {
return;
}

expect(element.style[d])
.toBe(directions[d], `Expected direction ${d} to be ${directions[d]}`);
const expectationMessage = `Expected direction ${d} to be ${directions[d]}`;

// If the direction contains `px`, we parse the number to be able to avoid deviations
// caused by individual browsers.
if (directions[d].includes('px')) {
expect(Math.round(parseInt(element.style[d])))
.toBe(Math.round(parseInt(directions[d])), expectationMessage);
} else {
expect(element.style[d]).toBe(directions[d], expectationMessage);
}
});
}

Expand Down
21 changes: 17 additions & 4 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3361,8 +3361,14 @@ describe('MatSelect', () => {
fixture.componentInstance.heightBelow = 400;
fixture.detectChanges();

// Scroll the select into view
setScrollTop(1700);
// Space that is needed in order to show the menu below the trigger.
// 256 (height of the menu overlay) - 45 (estimated height of the trigger)
const requiredSpaceBelow = 256 - 45;

// Scroll the select into view. Make sure that there is enough space for the menu
// to open below the trigger (depending on the screen resolution)
setScrollTop(2000 - requiredSpaceBelow);


// In the iOS simulator (BrowserStack & SauceLabs), adding the content to the
// body causes karma's iframe for the test to stretch to fit that content once we attempt to
Expand All @@ -3389,8 +3395,15 @@ describe('MatSelect', () => {
fixture.detectChanges();
flush();

// Scroll the select into view
setScrollTop(1700);
// Space that is needed in order to show the menu below the trigger.
// 256 (height of the menu overlay) - 45 (estimated height of the trigger)
// Even though there might be less options displayed below the trigger because the
// selected option is the fourth item, we want to make sure we have enough space here.
const requiredSpaceBelow = 256 - 45;

// Scroll the select into view. Make sure that there is enough space for the menu
// to open below the trigger (depending on the screen resolution)
setScrollTop(2000 - requiredSpaceBelow);

// In the iOS simulator (BrowserStack & SauceLabs), adding the content to the
// body causes karma's iframe for the test to stretch to fit that content once we attempt
Expand Down
13 changes: 8 additions & 5 deletions test/browser-providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const browserConfig = {
'FirefoxHeadless': { unitTest: {target: 'TC', required: true }},
'ChromeBeta': { unitTest: {target: null, required: false }},
'FirefoxBeta': { unitTest: {target: null, required: false }},
'ChromeDev': { unitTest: {target: null, required: true }},
'FirefoxDev': { unitTest: {target: null, required: true }},
'ChromeDev': { unitTest: {target: null, required: false }},
'FirefoxDev': { unitTest: {target: null, required: false }},
'IE9': { unitTest: {target: null, required: false }},
'IE10': { unitTest: {target: null, required: true }},
'IE10': { unitTest: {target: null, required: false }},
'IE11': { unitTest: {target: null, required: false }},
'Edge': { unitTest: {target: 'SL', required: true }},
'Edge': { unitTest: {target: 'BS', required: true }},
'Android4.1': { unitTest: {target: null, required: false }},
'Android4.2': { unitTest: {target: null, required: false }},
'Android4.3': { unitTest: {target: null, required: false }},
Expand All @@ -27,7 +27,10 @@ const browserConfig = {
'iOS7': { unitTest: {target: null, required: false }},
'iOS8': { unitTest: {target: null, required: false }},
'iOS9': { unitTest: {target: null, required: false }},
'iOS10': { unitTest: {target: 'BS', required: true }},
'iOS10': { unitTest: {target: null, required: false }},
// Don't use Browserstack until our open-source license includes automate testing on
// mobile devices. For now, we need to use Saucelabs to keep our coverage.
'iOS11': { unitTest: {target: 'SL', required: true }},
'WindowsPhone': { unitTest: {target: null, required: false }}
};

Expand Down
112 changes: 112 additions & 0 deletions test/karma-system-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Configure the base path and map the different node packages.
System.config({
baseURL: '/base',
paths: {
'node:*': 'node_modules/*'
},
map: {
'rxjs': 'node:rxjs',
'tslib': 'node:tslib/tslib.js',
'moment': 'node:moment/min/moment-with-locales.min.js',

// Angular specific mappings.
'@angular/core': 'node:@angular/core/bundles/core.umd.js',
'@angular/core/testing': 'node:@angular/core/bundles/core-testing.umd.min.js',
'@angular/common': 'node:@angular/common/bundles/common.umd.min.js',
'@angular/common/testing': 'node:@angular/common/bundles/common-testing.umd.min.js',
'@angular/common/http': 'node:@angular/common/bundles/common-http.umd.min.js',
'@angular/common/http/testing': 'node:@angular/common/bundles/common-http-testing.umd.min.js',
'@angular/compiler': 'node:@angular/compiler/bundles/compiler.umd.min.js',
'@angular/compiler/testing': 'node:@angular/compiler/bundles/compiler-testing.umd.min.js',
'@angular/forms': 'node:@angular/forms/bundles/forms.umd.min.js',
'@angular/forms/testing': 'node:@angular/forms/bundles/forms-testing.umd.min.js',
'@angular/animations': 'node:@angular/animations/bundles/animations.umd.min.js',
'@angular/animations/browser': 'node:@angular/animations/bundles/animations-browser.umd.min.js',
'@angular/platform-browser/animations':
'node:@angular/platform-browser/bundles/platform-browser-animations.umd.min.js',
'@angular/platform-browser':
'node:@angular/platform-browser/bundles/platform-browser.umd.min.js',
'@angular/platform-browser/testing':
'node:@angular/platform-browser/bundles/platform-browser-testing.umd.min.js',
'@angular/platform-browser-dynamic':
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js',
'@angular/platform-browser-dynamic/testing':
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.min.js',

// Path mappings for local packages that can be imported inside of tests.
'@angular/material': 'dist/packages/material/index.js',
'@angular/material-experimental': 'dist/packages/material-experimental/index.js',
'@angular/cdk-experimental': 'dist/packages/cdk-experimental/index.js',

'@angular/cdk': 'dist/packages/cdk/index.js',
'@angular/cdk/a11y': 'dist/packages/cdk/a11y/index.js',
'@angular/cdk/accordion': 'dist/packages/cdk/accordion/index.js',
'@angular/cdk/bidi': 'dist/packages/cdk/bidi/index.js',
'@angular/cdk/coercion': 'dist/packages/cdk/coercion/index.js',
'@angular/cdk/collections': 'dist/packages/cdk/collections/index.js',
'@angular/cdk/keycodes': 'dist/packages/cdk/keycodes/index.js',
'@angular/cdk/layout': 'dist/packages/cdk/layout/index.js',
'@angular/cdk/observers': 'dist/packages/cdk/observers/index.js',
'@angular/cdk/overlay': 'dist/packages/cdk/overlay/index.js',
'@angular/cdk/platform': 'dist/packages/cdk/platform/index.js',
'@angular/cdk/portal': 'dist/packages/cdk/portal/index.js',
'@angular/cdk/scrolling': 'dist/packages/cdk/scrolling/index.js',
'@angular/cdk/stepper': 'dist/packages/cdk/stepper/index.js',
'@angular/cdk/table': 'dist/packages/cdk/table/index.js',
'@angular/cdk/testing': 'dist/packages/cdk/testing/index.js',
'@angular/cdk/text-field': 'dist/packages/cdk/text-field/index.js',
'@angular/cdk/tree': 'dist/packages/cdk/tree/index.js',

'@angular/cdk-experimental/scrolling': 'dist/packages/cdk-experimental/scrolling/index.js',
'@angular/cdk-experimental/dialog': 'dist/packages/cdk-experimental/dialog/index.js',
'@angular/cdk-experimental/drag-drop':
'dist/packages/cdk-experimental/drag-drop/index.js',

'@angular/material/autocomplete': 'dist/packages/material/autocomplete/index.js',
'@angular/material/badge': 'dist/packages/material/badge/index.js',
'@angular/material/bottom-sheet': 'dist/packages/material/bottom-sheet/index.js',
'@angular/material/button': 'dist/packages/material/button/index.js',
'@angular/material/button-toggle': 'dist/packages/material/button-toggle/index.js',
'@angular/material/card': 'dist/packages/material/card/index.js',
'@angular/material/checkbox': 'dist/packages/material/checkbox/index.js',
'@angular/material/chips': 'dist/packages/material/chips/index.js',
'@angular/material/core': 'dist/packages/material/core/index.js',
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
'@angular/material/divider': 'dist/packages/material/divider/index.js',
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',
'@angular/material/grid-list': 'dist/packages/material/grid-list/index.js',
'@angular/material/icon': 'dist/packages/material/icon/index.js',
'@angular/material/input': 'dist/packages/material/input/index.js',
'@angular/material/list': 'dist/packages/material/list/index.js',
'@angular/material/menu': 'dist/packages/material/menu/index.js',
'@angular/material/paginator': 'dist/packages/material/paginator/index.js',
'@angular/material/progress-bar': 'dist/packages/material/progress-bar/index.js',
'@angular/material/progress-spinner': 'dist/packages/material/progress-spinner/index.js',
'@angular/material/radio': 'dist/packages/material/radio/index.js',
'@angular/material/select': 'dist/packages/material/select/index.js',
'@angular/material/sidenav': 'dist/packages/material/sidenav/index.js',
'@angular/material/slide-toggle': 'dist/packages/material/slide-toggle/index.js',
'@angular/material/slider': 'dist/packages/material/slider/index.js',
'@angular/material/snack-bar': 'dist/packages/material/snack-bar/index.js',
'@angular/material/sort': 'dist/packages/material/sort/index.js',
'@angular/material/stepper': 'dist/packages/material/stepper/index.js',
'@angular/material/table': 'dist/packages/material/table/index.js',
'@angular/material/tabs': 'dist/packages/material/tabs/index.js',
'@angular/material/toolbar': 'dist/packages/material/toolbar/index.js',
'@angular/material/tooltip': 'dist/packages/material/tooltip/index.js',
'@angular/material/tree': 'dist/packages/material/tree/index.js',
},
packages: {
// Thirdparty barrels.
'rxjs': {main: 'index'},
'rxjs/operators': {main: 'index'},

// Set the default extension for the root package, because otherwise the demo-app can't
// be built within the production mode. Due to missing file extensions.
'.': {
defaultExtension: 'js'
}
}
});
115 changes: 0 additions & 115 deletions test/karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,123 +8,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;

__karma__.loaded = function () {};

var baseDir = '/base';
var specFiles = Object.keys(window.__karma__.files).filter(isMaterialSpecFile);

// Configure the base path and map the different node packages.
System.config({
baseURL: baseDir,
paths: {
'node:*': 'node_modules/*'
},
map: {
'rxjs': 'node:rxjs',
'main': 'main.js',
'tslib': 'node:tslib/tslib.js',
'moment': 'node:moment/min/moment-with-locales.min.js',

// Angular specific mappings.
'@angular/core': 'node:@angular/core/bundles/core.umd.js',
'@angular/core/testing': 'node:@angular/core/bundles/core-testing.umd.js',
'@angular/common': 'node:@angular/common/bundles/common.umd.js',
'@angular/common/testing': 'node:@angular/common/bundles/common-testing.umd.js',
'@angular/common/http': 'node:@angular/common/bundles/common-http.umd.js',
'@angular/common/http/testing': 'node:@angular/common/bundles/common-http-testing.umd.js',
'@angular/compiler': 'node:@angular/compiler/bundles/compiler.umd.js',
'@angular/compiler/testing': 'node:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/forms': 'node:@angular/forms/bundles/forms.umd.js',
'@angular/forms/testing': 'node:@angular/forms/bundles/forms-testing.umd.js',
'@angular/animations': 'node:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'node:@angular/animations/bundles/animations-browser.umd.js',
'@angular/platform-browser/animations':
'node:@angular/platform-browser/bundles/platform-browser-animations.umd',
'@angular/platform-browser':
'node:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser/testing':
'node:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic':
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/platform-browser-dynamic/testing':
'node:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',

// Path mappings for local packages that can be imported inside of tests.
'@angular/material': 'dist/packages/material/index.js',
'@angular/material-experimental': 'dist/packages/material-experimental/index.js',
'@angular/cdk-experimental': 'dist/packages/cdk-experimental/index.js',

'@angular/cdk': 'dist/packages/cdk/index.js',
'@angular/cdk/a11y': 'dist/packages/cdk/a11y/index.js',
'@angular/cdk/accordion': 'dist/packages/cdk/accordion/index.js',
'@angular/cdk/bidi': 'dist/packages/cdk/bidi/index.js',
'@angular/cdk/coercion': 'dist/packages/cdk/coercion/index.js',
'@angular/cdk/collections': 'dist/packages/cdk/collections/index.js',
'@angular/cdk/keycodes': 'dist/packages/cdk/keycodes/index.js',
'@angular/cdk/layout': 'dist/packages/cdk/layout/index.js',
'@angular/cdk/observers': 'dist/packages/cdk/observers/index.js',
'@angular/cdk/overlay': 'dist/packages/cdk/overlay/index.js',
'@angular/cdk/platform': 'dist/packages/cdk/platform/index.js',
'@angular/cdk/portal': 'dist/packages/cdk/portal/index.js',
'@angular/cdk/scrolling': 'dist/packages/cdk/scrolling/index.js',
'@angular/cdk/stepper': 'dist/packages/cdk/stepper/index.js',
'@angular/cdk/table': 'dist/packages/cdk/table/index.js',
'@angular/cdk/testing': 'dist/packages/cdk/testing/index.js',
'@angular/cdk/text-field': 'dist/packages/cdk/text-field/index.js',
'@angular/cdk/tree': 'dist/packages/cdk/tree/index.js',

'@angular/cdk-experimental/scrolling': 'dist/packages/cdk-experimental/scrolling/index.js',
'@angular/cdk-experimental/dialog': 'dist/packages/cdk-experimental/dialog/index.js',
'@angular/cdk-experimental/drag-drop':
'dist/packages/cdk-experimental/drag-drop/index.js',

'@angular/material/autocomplete': 'dist/packages/material/autocomplete/index.js',
'@angular/material/badge': 'dist/packages/material/badge/index.js',
'@angular/material/bottom-sheet': 'dist/packages/material/bottom-sheet/index.js',
'@angular/material/button': 'dist/packages/material/button/index.js',
'@angular/material/button-toggle': 'dist/packages/material/button-toggle/index.js',
'@angular/material/card': 'dist/packages/material/card/index.js',
'@angular/material/checkbox': 'dist/packages/material/checkbox/index.js',
'@angular/material/chips': 'dist/packages/material/chips/index.js',
'@angular/material/core': 'dist/packages/material/core/index.js',
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
'@angular/material/divider': 'dist/packages/material/divider/index.js',
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',
'@angular/material/grid-list': 'dist/packages/material/grid-list/index.js',
'@angular/material/icon': 'dist/packages/material/icon/index.js',
'@angular/material/input': 'dist/packages/material/input/index.js',
'@angular/material/list': 'dist/packages/material/list/index.js',
'@angular/material/menu': 'dist/packages/material/menu/index.js',
'@angular/material/paginator': 'dist/packages/material/paginator/index.js',
'@angular/material/progress-bar': 'dist/packages/material/progress-bar/index.js',
'@angular/material/progress-spinner': 'dist/packages/material/progress-spinner/index.js',
'@angular/material/radio': 'dist/packages/material/radio/index.js',
'@angular/material/select': 'dist/packages/material/select/index.js',
'@angular/material/sidenav': 'dist/packages/material/sidenav/index.js',
'@angular/material/slide-toggle': 'dist/packages/material/slide-toggle/index.js',
'@angular/material/slider': 'dist/packages/material/slider/index.js',
'@angular/material/snack-bar': 'dist/packages/material/snack-bar/index.js',
'@angular/material/sort': 'dist/packages/material/sort/index.js',
'@angular/material/stepper': 'dist/packages/material/stepper/index.js',
'@angular/material/table': 'dist/packages/material/table/index.js',
'@angular/material/tabs': 'dist/packages/material/tabs/index.js',
'@angular/material/toolbar': 'dist/packages/material/toolbar/index.js',
'@angular/material/tooltip': 'dist/packages/material/tooltip/index.js',
'@angular/material/tree': 'dist/packages/material/tree/index.js',
},
packages: {
// Thirdparty barrels.
'rxjs': {main: 'index'},
'rxjs/operators': {main: 'index'},

// Set the default extension for the root package, because otherwise the demo-app can't
// be built within the production mode. Due to missing file extensions.
'.': {
defaultExtension: 'js'
}
}
});

// Configure the Angular test bed and run all specs once configured.
configureTestBed()
.then(runMaterialSpecs)
Expand Down
Loading