Skip to content

Commit 16a71c2

Browse files
committed
merge component harness test-app into e2e-app
1 parent 5e8b690 commit 16a71c2

26 files changed

+126
-223
lines changed

src/cdk-experimental/testing/BUILD.bazel

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ load("@npm_angular_bazel//:index.bzl", "protractor_web_test_suite")
66

77
ng_module(
88
name = "testing",
9-
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts", "test-app/**"]),
9+
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts", "tests/**"]),
1010
module_name = "@angular/cdk-experimental/testing",
1111
deps = [
1212
"@npm//@angular/core",
@@ -16,19 +16,21 @@ ng_module(
1616

1717
ng_web_test_suite(
1818
name = "unit_tests",
19-
deps = ["//src/cdk-experimental/testing/test-app:test_app_test_sources"],
19+
deps = ["//src/cdk-experimental/testing/tests:unit_test_sources"],
2020
)
2121

2222
protractor_web_test_suite(
2323
name = "e2e_tests",
24-
configuration = ":protractor.conf.js",
25-
on_prepare = ":start-devserver.js",
26-
server = "//src/cdk-experimental/testing/test-app:devserver",
24+
tags = ["e2e"],
25+
configuration = "//src/e2e-app:protractor.conf.js",
26+
on_prepare = "//src/e2e-app:start-devserver.js",
27+
server = "//src/e2e-app:devserver",
2728
deps = [
2829
"@npm//protractor",
29-
"//src/cdk-experimental/testing/test-app:test_app_e2e_test_sources",
30+
"//src/cdk-experimental/testing/tests:e2e_test_sources",
3031
],
3132
data = [
3233
"@npm//@angular/bazel",
34+
"//tools/axe-protractor",
3335
],
3436
)

src/cdk-experimental/testing/protractor.conf.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/cdk-experimental/testing/start-devserver.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/BUILD.bazel

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/devserver-configure.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/index.html

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/main.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/test-app.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/cdk-experimental/testing/test-app/tsconfig.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package(default_visibility=["//visibility:public"])
2+
3+
load("//tools:defaults.bzl", "ng_module", "ts_library", "ng_test_library", "ng_e2e_test_library")
4+
5+
ng_module(
6+
name = "test_components",
7+
module_name = "@angular/cdk-experimental/testing/tests",
8+
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts", "harnesses/**"]),
9+
deps = [
10+
"@npm//@angular/forms",
11+
],
12+
)
13+
14+
ts_library(
15+
name = "test_harnesses",
16+
srcs = glob(["harnesses/**/*.ts"]),
17+
deps = [
18+
"//src/cdk-experimental/testing",
19+
],
20+
)
21+
22+
ng_test_library(
23+
name = "unit_test_sources",
24+
srcs = glob(["**/*.spec.ts"], exclude=["**/*.e2e.spec.ts"]),
25+
deps = [
26+
":test_components",
27+
":test_harnesses",
28+
"//src/cdk-experimental/testing",
29+
],
30+
)
31+
32+
ng_e2e_test_library(
33+
name = "e2e_test_sources",
34+
srcs = glob(["**/*.e2e.spec.ts"]),
35+
deps = [
36+
":test_harnesses",
37+
"//src/cdk-experimental/testing",
38+
],
39+
)

src/cdk-experimental/testing/test-app/harnesses/main-component-harness.ts renamed to src/cdk-experimental/testing/tests/harnesses/main-component-harness.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class MainComponentHarness extends ComponentHarness {
1616
readonly input = this.find('#input');
1717
readonly value = this.find('#value');
1818
readonly allLabels = this.findAll('label');
19-
readonly allLists = this.findAll(SubComponentHarness, 'sub');
19+
readonly allLists = this.findAll(SubComponentHarness, 'test-sub');
2020
readonly memo = this.find('textarea');
2121
// Allow null for element
2222
readonly nullItem = this.find('wrong locator', {allowNull: true});
@@ -32,7 +32,7 @@ export class MainComponentHarness extends ComponentHarness {
3232
this.find('wrong locator', {global: true, allowNull: true});
3333

3434
private _button = this.find('button');
35-
private _testTools = this.find(SubComponentHarness, 'sub');
35+
private _testTools = this.find(SubComponentHarness, 'test-sub');
3636

3737
async increaseCounter(times: number) {
3838
const button = await this._button();

src/cdk-experimental/testing/test-app/test-app-types.d.ts renamed to src/cdk-experimental/testing/tests/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
declare var module: { id: string };
9+
export * from './test-components-module';
10+
export * from './test-main-component';
11+
export * from './test-sub-component';

src/cdk-experimental/testing/test-app/protractor.e2e.spec.ts renamed to src/cdk-experimental/testing/tests/protractor.e2e.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe('Protractor Helper Test:', () => {
77
let harness: MainComponentHarness;
88

99
beforeEach(async () => {
10-
await browser.get('/');
11-
harness = await load(MainComponentHarness, 'main');
10+
await browser.get('/component-harness');
11+
harness = await load(MainComponentHarness, 'test-main');
1212
});
1313

1414
describe('Locator ', () => {
@@ -174,7 +174,7 @@ describe('Protractor Helper Test:', () => {
174174

175175
describe('getElementFinder', () => {
176176
it('should return the element finder', async () => {
177-
const mainElement = await element(by.css('main'));
177+
const mainElement = await element(by.css('test-main'));
178178
const elementFromHarness = getElementFinder(harness.host());
179179
expect(await elementFromHarness.getId())
180180
.toEqual(await mainElement.getId());
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 {CommonModule} from '@angular/common';
10+
import {NgModule} from '@angular/core';
11+
import {FormsModule} from '@angular/forms';
12+
import {TestMainComponent} from './test-main-component';
13+
import {TestSubComponent} from './test-sub-component';
14+
15+
@NgModule({
16+
imports: [CommonModule, FormsModule],
17+
declarations: [TestMainComponent, TestSubComponent],
18+
exports: [TestMainComponent, TestSubComponent]
19+
})
20+
export class TestComponentsModule {}

src/cdk-experimental/testing/test-app/main-component.ts renamed to src/cdk-experimental/testing/tests/test-main-component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
@Component({
1717
moduleId: module.id,
18-
selector: 'main',
18+
selector: 'test-main',
1919
template: `
2020
<h1 style="height:50px">Main Component</h1>
2121
<div id = 'username'>Hello {{username}} from Angular 2!</div>
@@ -24,11 +24,11 @@ import {
2424
<div id = 'counter'>{{counter}}</div>
2525
<label>AsyncCounter:</label>
2626
<div id = 'asyncCounter'>{{asyncCounter}}</div>
27-
<input [(ngModel)]='input' placeholder='' id = 'input'>
27+
<input [(ngModel)]='input' placeholder='' id = 'input' aria-label="input">
2828
<div id = 'value'>Input:{{input}}</div>
29-
<textarea id = 'memo'>{{memo}}</textarea>
30-
<sub title = 'test tools' [items] = testTools></sub>
31-
<sub title = 'test methods' [items] = testMethods></sub>
29+
<textarea id = 'memo' aria-label="memo">{{memo}}</textarea>
30+
<test-sub title = 'test tools' [items] = testTools></test-sub>
31+
<test-sub title = 'test methods' [items] = testMethods></test-sub>
3232
`,
3333
host: {
3434
'[class.hovering]': '_isHovering',
@@ -39,7 +39,7 @@ import {
3939
changeDetection: ChangeDetectionStrategy.OnPush,
4040
})
4141

42-
export class MainComponent {
42+
export class TestMainComponent {
4343
username: string;
4444
counter: number;
4545
asyncCounter: number;

src/cdk-experimental/testing/test-app/sub-component.ts renamed to src/cdk-experimental/testing/tests/test-sub-component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {ChangeDetectionStrategy, Component, Input, ViewEncapsulation} from '@ang
1010

1111
@Component({
1212
moduleId: module.id,
13-
selector: 'sub',
13+
selector: 'test-sub',
1414
template: `
1515
<h2>List of {{title}}</h2>
1616
<ul>
@@ -19,7 +19,7 @@ import {ChangeDetectionStrategy, Component, Input, ViewEncapsulation} from '@ang
1919
encapsulation: ViewEncapsulation.None,
2020
changeDetection: ChangeDetectionStrategy.OnPush,
2121
})
22-
export class SubComponent {
22+
export class TestSubComponent {
2323
// TODO: remove '!'.
2424
@Input() title!: string;
2525
// TODO: remove '!'.

0 commit comments

Comments
 (0)