Skip to content

Commit 2edb4c1

Browse files
committed
4.3. Copy over e2e tests if any exist
Adds MDC-based MatCheckbox to the e2e app and copies over the tests for the existing MatCheckbox.
1 parent 3638678 commit 2edb4c1

File tree

10 files changed

+89
-1
lines changed

10 files changed

+89
-1
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
/e2e/components/icon-e2e.spec.ts @jelbourn
168168
/e2e/components/input-e2e.spec.ts @mmalerba
169169
/e2e/components/list-e2e.spec.ts @jelbourn @crisbeto @devversion
170+
/e2e/components/mdc-checkbox-e2e.spec.ts @mmalerba
170171
/e2e/components/menu-e2e.spec.ts @crisbeto
171172
/e2e/components/progress-bar-e2e.spec.ts @jelbourn @crisbeto @josephperrott
172173
/e2e/components/progress-spinner-e2e.spec.ts @jelbourn @crisbeto @josephperrott
@@ -192,6 +193,7 @@
192193
/src/e2e-app/icon/** @jelbourn
193194
/src/e2e-app/input/** @mmalerba
194195
/src/e2e-app/list/** @jelbourn
196+
/src/e2e-app/mdc-checkbox/** @mmalerba
195197
/src/e2e-app/menu/** @crisbeto
196198
/src/e2e-app/progress-bar/** @jelbourn @crisbeto @josephperrott
197199
/src/e2e-app/progress-spinner/** @jelbourn @crisbeto @josephperrott
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {browser, by, element, Key} from 'protractor';
2+
3+
describe('MDC checkbox', () => {
4+
describe('check behavior', () => {
5+
beforeEach(async () => await browser.get('/mdc-checkbox'));
6+
7+
it('should be checked when clicked, and unchecked when clicked again', async () => {
8+
const checkboxEl = element(by.id('test-checkbox'));
9+
const inputEl = element(by.css('input[id=test-checkbox-input]'));
10+
11+
await checkboxEl.click();
12+
13+
expect(await inputEl.getAttribute('checked'))
14+
.toBeTruthy('Expect checkbox "checked" property to be true');
15+
16+
await checkboxEl.click();
17+
18+
expect(await inputEl.getAttribute('checked'))
19+
.toBeFalsy('Expect checkbox "checked" property to be false');
20+
});
21+
22+
it('should toggle the checkbox when pressing space', async () => {
23+
const inputEl = element(by.css('input[id=test-checkbox-input]'));
24+
25+
expect(await inputEl.getAttribute('checked'))
26+
.toBeFalsy('Expect checkbox "checked" property to be false');
27+
await inputEl.sendKeys(Key.SPACE);
28+
29+
expect(await inputEl.getAttribute('checked'))
30+
.toBeTruthy('Expect checkbox "checked" property to be true');
31+
});
32+
});
33+
});

src/e2e-app/BUILD.bazel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ ng_module(
2525
"//src/material-examples:examples",
2626
"//src/cdk-experimental/dialog",
2727
"//src/cdk-experimental/scrolling",
28+
"//src/material-experimental/mdc-checkbox",
2829
],
2930
)
3031

3132
sass_binary(
3233
name = "theme",
3334
src = "theme.scss",
35+
include_paths = [
36+
"external/npm/node_modules",
37+
],
3438
deps = [
35-
"//src/lib/core:all_themes"
39+
"//src/lib/core:all_themes",
40+
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib",
41+
"//src/material-experimental/mdc-checkbox:checkbox_scss_lib",
3642
]
3743
)
3844

src/e2e-app/e2e-app/e2e-app-layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<a mat-list-item [routerLink]="['cards']">Cards</a>
2323
<a mat-list-item [routerLink]="['toolbar']">Toolbar</a>
2424
<a mat-list-item [routerLink]="['virtual-scroll']">Virtual Scroll</a>
25+
<a mat-list-item [routerLink]="['mdc-checkbox']">MDC Checkbox</a>
2526
</mat-nav-list>
2627

2728
<main>

src/e2e-app/e2e-app/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {GridListE2E} from '../grid-list/grid-list-e2e';
1010
import {IconE2E} from '../icon/icon-e2e';
1111
import {InputE2E} from '../input/input-e2e';
1212
import {ListE2e} from '../list/list-e2e';
13+
import {MdcCheckboxE2e} from '../mdc-checkbox/mdc-checkbox-e2e';
1314
import {MenuE2E} from '../menu/menu-e2e';
1415
import {ProgressBarE2E} from '../progress-bar/progress-bar-e2e';
1516
import {ProgressSpinnerE2E} from '../progress-spinner/progress-spinner-e2e';
@@ -34,6 +35,7 @@ export const E2E_APP_ROUTES: Routes = [
3435
{path: 'icon', component: IconE2E},
3536
{path: 'input', component: InputE2E},
3637
{path: 'list', component: ListE2e},
38+
{path: 'mdc-checkbox', component: MdcCheckboxE2e},
3739
{path: 'menu', component: MenuE2E},
3840
{path: 'progress-bar', component: ProgressBarE2E},
3941
{path: 'progress-spinner', component: ProgressSpinnerE2E},

src/e2e-app/main-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {GridListE2eModule} from './grid-list/grid-list-e2e-module';
1818
import {IconE2eModule} from './icon/icon-e2e-module';
1919
import {InputE2eModule} from './input/input-e2e-module';
2020
import {ListE2eModule} from './list/list-e2e-module';
21+
import {MdcCheckboxE2eModule} from './mdc-checkbox/mdc-checkbox-e2e-module';
2122
import {MenuE2eModule} from './menu/menu-e2e-module';
2223
import {ProgressBarE2eModule} from './progress-bar/progress-bar-e2e-module';
2324
import {ProgressSpinnerE2eModule} from './progress-spinner/progress-spinner-e2e-module';
@@ -48,6 +49,7 @@ import {VirtualScrollE2eModule} from './virtual-scroll/virtual-scroll-e2e-module
4849
IconE2eModule,
4950
InputE2eModule,
5051
ListE2eModule,
52+
MdcCheckboxE2eModule,
5153
MenuE2eModule,
5254
ProgressBarE2eModule,
5355
ProgressSpinnerE2eModule,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {NgModule} from '@angular/core';
10+
import {MatCheckboxModule} from '@angular/material-experimental/mdc-checkbox';
11+
import {MdcCheckboxE2e} from './mdc-checkbox-e2e';
12+
13+
@NgModule({
14+
imports: [MatCheckboxModule],
15+
declarations: [MdcCheckboxE2e],
16+
})
17+
export class MdcCheckboxE2eModule {
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mat-checkbox id="test-checkbox">Check this button</mat-checkbox>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Component} from '@angular/core';
10+
11+
@Component({
12+
moduleId: module.id,
13+
selector: 'mdc-checkbox-e2e',
14+
templateUrl: 'mdc-checkbox-e2e.html',
15+
})
16+
export class MdcCheckboxE2e {
17+
selected: string = '';
18+
}

src/e2e-app/theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
@import '../lib/core/theming/all-theme';
2+
@import '../material-experimental/mdc-checkbox/mdc-checkbox';
3+
@import '../material-experimental/mdc-helpers/mdc-helpers';
24

35
// Plus imports for other components in your app.
46

57
// Include the common styles for Angular Material. We include this here so that you only
68
// have to load a single css file for Angular Material in your app.
79
// **Be sure that you only ever include this mixin once!**
810
@include mat-core();
11+
@include mat-checkbox-typography-mdc(mat-typography-config());
912

1013
// Define the default theme (same as the example above).
1114
$candy-app-primary: mat-palette($mat-indigo);
@@ -14,3 +17,5 @@ $candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent);
1417

1518
// Include the default theme styles.
1619
@include angular-material-theme($candy-app-theme);
20+
@include mat-checkbox-theme-mdc($candy-app-theme);
21+

0 commit comments

Comments
 (0)