Skip to content

Commit 20a033e

Browse files
committed
chore(material): add simple e2e smoke tests for components.
1 parent 93c331d commit 20a033e

File tree

22 files changed

+137
-66
lines changed

22 files changed

+137
-66
lines changed

gulpfile.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,22 @@ gulp.task('build', ['build.js', 'build.dart']);
746746

747747
// ------------
748748
// angular material testing rules
749-
gulp.task('build.js.material', ['build.js.dev'], function() {
749+
gulp.task('build.css.material', function() {
750750
return gulp.src('modules/*/src/**/*.scss')
751751
.pipe(sass())
752752
.pipe(autoprefixer())
753-
.pipe(gulp.dest(CONFIG.dest.js.dev.es5));
753+
.pipe(gulp.dest(CONFIG.dest.js.prod.es5))
754+
.pipe(gulp.dest(CONFIG.dest.js.dev.es5))
755+
.pipe(gulp.dest(CONFIG.dest.js.dart2js + '/examples/packages'));
756+
});
757+
758+
759+
gulp.task('build.js.material', function(done) {
760+
runSequence('build.js.dev', 'build.css.material', done);
761+
});
762+
763+
gulp.task('build.dart2js.material', function(done) {
764+
runSequence('build.dart', 'build.css.material', done);
754765
});
755766

756767
// TODO: this target is temporary until we find a way to use the SASS transformer

modules/angular2_material/src/components/checkbox/checkbox.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
1919
'tabindex': 'tabindex',
2020
'role': 'attr.role',
2121
'checked': 'attr.aria-checked',
22-
'disabled_': 'attr.aria-disabled'
22+
'disabled': 'attr.aria-disabled'
2323
}
2424
})
2525
@View({
@@ -31,7 +31,7 @@ export class MdCheckbox {
3131
checked: boolean;
3232

3333
/** Whether this checkbox is disabled. */
34-
disabled_: boolean;
34+
_disabled: boolean;
3535

3636
/** Setter for `role` attribute. */
3737
role: string;
@@ -43,14 +43,15 @@ export class MdCheckbox {
4343
this.role = 'checkbox';
4444
this.checked = false;
4545
this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
46+
this._disabled = false;
4647
}
4748

4849
get disabled() {
49-
return this.disabled_;
50+
return this._disabled;
5051
}
5152

5253
set disabled(value) {
53-
this.disabled_ = isPresent(value) && value !== false;
54+
this._disabled = isPresent(value) && value !== false;
5455
}
5556

5657
onKeydown(event: KeyboardEvent) {

modules/angular2_material/src/components/radio/radio_button.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class MdRadioButton {
7777

7878
constructor(
7979
@Optional() @Parent() radioGroup: MdRadioGroup,
80-
@Attribute('id') id: string,
81-
@Attribute('tabindex') tabindex: string,
80+
@Attribute('id') id: String,
81+
@Attribute('tabindex') tabindex: String,
8282
radioDispatcher: MdRadioDispatcher) {
8383
// Assertions. Ideally these should be stripped out by the compiler.
8484
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
@@ -213,8 +213,8 @@ export class MdRadioGroup {
213213
role: string;
214214

215215
constructor(
216-
@Attribute('tabindex') tabindex: string,
217-
@Attribute('disabled') disabled: string,
216+
@Attribute('tabindex') tabindex: String,
217+
@Attribute('disabled') disabled: String,
218218
radioDispatcher: MdRadioDispatcher) {
219219
this.name_ = `md-radio-group-${_uniqueIdCounter++}`;
220220
this.radios_ = [];
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var testUtil = require('angular2/src/test_lib/e2e_util');
2+
3+
describe('md-button', function () {
4+
var url = 'examples/src/material/button/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(testUtil.verifyNoBrowserErrors);
8+
9+
// Buttons are broken right now, see https://github.com/angular/angular/issues/1602
10+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var testUtil = require('angular2/src/test_lib/e2e_util');
2+
3+
describe('md-checkbox', function () {
4+
var url = 'examples/src/material/checkbox/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(testUtil.verifyNoBrowserErrors);
8+
9+
it('should toggle a checkbox', function() {
10+
var checkbox = element.all(by.css('md-checkbox')).first();
11+
12+
checkbox.click();
13+
expect(checkbox.getAttribute('aria-checked')).toBe('true');
14+
15+
checkbox.click();
16+
expect(checkbox.getAttribute('aria-checked')).toBe('false');
17+
});
18+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var testUtil = require('angular2/src/test_lib/e2e_util');
2+
3+
describe('md-dialog', function () {
4+
var url = 'examples/src/material/dialog/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(testUtil.verifyNoBrowserErrors);
8+
9+
it('should open a dialog', function() {
10+
var openButton = element(by.id('open'));
11+
openButton.click();
12+
expect(element(by.css('.md-dialog')).isPresent()).toBe(true);
13+
14+
var dialog = element(by.css('.md-dialog'));
15+
dialog.sendKeys(protractor.Key.ESCAPE);
16+
17+
expect(element(by.css('.md-dialog')).isPresent()).toBe(false);
18+
});
19+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var testUtil = require('angular2/src/test_lib/e2e_util');
2+
3+
describe('md-progress-linear', function () {
4+
var url = 'examples/src/material/progress-linear/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(testUtil.verifyNoBrowserErrors);
8+
9+
it('should increment and decrement progress', function() {
10+
var progressBar = element.all(by.css('md-progress-linear')).first();
11+
var incrementButton = element(by.id('increment'));
12+
var decrementButton = element(by.id('decrement'));
13+
14+
var initialValue = progressBar.getAttribute('aria-valuenow');
15+
16+
incrementButton.click();
17+
expect(progressBar.getAttribute('aria-valuenow')).toBeGreaterThan(initialValue);
18+
19+
decrementButton.click();
20+
decrementButton.click();
21+
expect(progressBar.getAttribute('aria-valuenow')).toBeLessThan(initialValue);
22+
});
23+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var testUtil = require('angular2/src/test_lib/e2e_util');
2+
3+
describe('md-radio-button', function () {
4+
var url = 'examples/src/material/radio/index.html';
5+
6+
beforeEach(() => { browser.get(url); });
7+
afterEach(testUtil.verifyNoBrowserErrors);
8+
9+
// Radio buttons are broken right now, see https://github.com/angular/angular/issues/1643
10+
});

modules/examples/src/material/button/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
<style> * { font-family: RobotoDraft, Roboto, 'Helvetica Neue', sans-serif; } </style>
88
</head>
99
<body>
10-
1110
<demo-app>Loading...</demo-app>
12-
1311
$SCRIPTS$
14-
1512
</body>
1613
</html>

modules/examples/src/material/checkbox/index.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
<meta charset="UTF-8">
55
<title>ng-material checkbox demo</title>
66
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:400,500,700,400italic">
7-
<style>
8-
* {
9-
font-family: RobotoDraft, Roboto;
10-
}
11-
</style>
7+
<style> * { font-family: RobotoDraft, Roboto; } </style>
128
</head>
139
<body>
14-
15-
$SCRIPTS$
1610
<demo-app>Loading...</demo-app>
11+
$SCRIPTS$
1712
</body>
1813
</html>

0 commit comments

Comments
 (0)