@@ -5,102 +5,96 @@ import { generateProjectSync } from './util/yeoman';
5
5
import { AspNetProcess , AspNetCoreEnviroment , defaultUrl , publishProjectSync } from './util/aspnet' ;
6
6
import { getValue , getCssPropertyValue } from './util/webdriverio' ;
7
7
8
- // Currently we test both 'csproj' and 'project.json' project types. Eventually we'll only need csproj.
9
- [ 'csproj' , 'projectjson' ] . forEach ( toolingType => {
10
- // First, generate a new project using the locally-built generator-aspnetcore-spa
11
- // Do this outside the Mocha fixture, otherwise Mocha will time out
12
- const appDir = path . resolve ( __dirname , '../generated/angular' , toolingType ) ;
13
- const publishedAppDir = path . resolve ( appDir , './bin/Release/published' ) ;
14
- if ( ! process . env . SKIP_PROJECT_GENERATION ) {
15
- generateProjectSync ( appDir , {
16
- framework : 'angular-2' ,
17
- name : 'Test App' ,
18
- sdkVersion : toolingType === 'projectjson' ? '1.0.0-preview2-1-003177' : '1.0.0-preview3-004056' ,
19
- tests : false
20
- } ) ;
21
- publishProjectSync ( appDir , publishedAppDir ) ;
22
- }
23
-
24
- function testBasicNavigation ( ) {
25
- describe ( 'Basic navigation' , ( ) => {
26
- beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
27
-
28
- it ( 'should initially display the home page' , ( ) => {
29
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
30
- expect ( browser . getText ( 'li a[href="https://angular.io/"]' ) ) . to . eq ( 'Angular 2' ) ;
31
- } ) ;
32
-
33
- it ( 'should be able to show the counter page' , ( ) => {
34
- browser . click ( 'a[href="/counter"]' ) ;
35
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Counter' ) ;
36
-
37
- // Test clicking the 'increment' button
38
- expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '0' ) ;
39
- browser . click ( 'counter button' ) ;
40
- expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '1' ) ;
41
- } ) ;
42
-
43
- it ( 'should be able to show the fetchdata page' , ( ) => {
44
- browser . click ( 'a[href="/fetch-data"]' ) ;
45
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Weather forecast' ) ;
46
-
47
- browser . waitForExist ( 'fetchdata table' ) ;
48
- expect ( getValue ( browser . elements ( 'fetchdata table tbody tr' ) ) . length ) . to . eq ( 5 ) ;
49
- } ) ;
8
+ // First, generate a new project using the locally-built generator-aspnetcore-spa
9
+ // Do this outside the Mocha fixture, otherwise Mocha will time out
10
+ const appDir = path . resolve ( __dirname , '../generated/angular' ) ;
11
+ const publishedAppDir = path . resolve ( appDir , './bin/Release/published' ) ;
12
+ if ( ! process . env . SKIP_PROJECT_GENERATION ) {
13
+ generateProjectSync ( appDir , {
14
+ framework : 'angular' ,
15
+ name : 'Test App' ,
16
+ tests : false
17
+ } ) ;
18
+ publishProjectSync ( appDir , publishedAppDir ) ;
19
+ }
20
+
21
+ function testBasicNavigation ( ) {
22
+ describe ( 'Basic navigation' , ( ) => {
23
+ beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
24
+
25
+ it ( 'should initially display the home page' , ( ) => {
26
+ expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
27
+ expect ( browser . getText ( 'li a[href="https://angular.io/"]' ) ) . to . eq ( 'Angular 2' ) ;
50
28
} ) ;
51
- }
52
29
53
- function testHotModuleReplacement ( ) {
54
- describe ( 'Hot module replacement' , ( ) => {
55
- beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
30
+ it ( 'should be able to show the counter page' , ( ) => {
31
+ browser . click ( 'a[href="/counter"]' ) ;
32
+ expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Counter' ) ;
56
33
57
- it ( 'should update when HTML is changed' , ( ) => {
58
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
34
+ // Test clicking the 'increment' button
35
+ expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '0' ) ;
36
+ browser . click ( 'counter button' ) ;
37
+ expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '1' ) ;
38
+ } ) ;
59
39
60
- const filePath = path . resolve ( appDir , './ClientApp/app/components/home/home.component.html' ) ;
61
- const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
40
+ it ( 'should be able to show the fetchdata page' , ( ) => {
41
+ browser . click ( 'a[href="/fetch-data"]' ) ;
42
+ expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Weather forecast' ) ;
62
43
63
- try {
64
- const newFileContents = origFileContents . replace ( '<h1>Hello, world!</h1>' , '<h1>HMR is working</h1>' ) ;
65
- fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
44
+ browser . waitForExist ( 'fetchdata table' ) ;
45
+ expect ( getValue ( browser . elements ( 'fetchdata table tbody tr' ) ) . length ) . to . eq ( 5 ) ;
46
+ } ) ;
47
+ } ) ;
48
+ }
66
49
67
- browser . waitUntil ( ( ) => browser . getText ( 'h1' ) . toString ( ) === 'HMR is working' ) ;
68
- } finally {
69
- // Restore old contents so that other tests don't have to account for this
70
- fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
71
- }
72
- } ) ;
50
+ function testHotModuleReplacement ( ) {
51
+ describe ( 'Hot module replacement' , ( ) => {
52
+ beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
73
53
74
- it ( 'should update when CSS is changed' , ( ) => {
75
- expect ( getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) ) . to . eq ( 'rgba(255,255,255,1) ' ) ;
54
+ it ( 'should update when HTML is changed' , ( ) => {
55
+ expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world! ' ) ;
76
56
77
- const filePath = path . resolve ( appDir , './ClientApp/app/components/navmenu/navmenu .component.css ' ) ;
78
- const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
57
+ const filePath = path . resolve ( appDir , './ClientApp/app/components/home/home .component.html ' ) ;
58
+ const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
79
59
80
- try {
81
- const newFileContents = origFileContents . replace ( 'color: white; ' , 'color: purple; ' ) ;
82
- fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
60
+ try {
61
+ const newFileContents = origFileContents . replace ( '<h1>Hello, world!</h1> ' , '<h1>HMR is working</h1> ' ) ;
62
+ fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
83
63
84
- browser . waitUntil ( ( ) => getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) === 'rgba(128,0,128,1)' ) ;
85
- } finally {
86
- // Restore old contents so that other tests don't have to account for this
87
- fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
88
- }
89
- } ) ;
64
+ browser . waitUntil ( ( ) => browser . getText ( 'h1' ) . toString ( ) === 'HMR is working' ) ;
65
+ } finally {
66
+ // Restore old contents so that other tests don't have to account for this
67
+ fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
68
+ }
90
69
} ) ;
91
- }
92
70
93
- // Now launch dotnet and use selenium to perform tests
94
- describe ( 'Angular template: dev mode' , ( ) => {
95
- AspNetProcess . RunInMochaContext ( appDir , AspNetCoreEnviroment . development ) ;
96
- testBasicNavigation ( ) ;
97
- testHotModuleReplacement ( ) ;
98
- } ) ;
71
+ it ( 'should update when CSS is changed' , ( ) => {
72
+ expect ( getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) ) . to . eq ( 'rgba(255,255,255,1)' ) ;
73
+
74
+ const filePath = path . resolve ( appDir , './ClientApp/app/components/navmenu/navmenu.component.css' ) ;
75
+ const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
76
+
77
+ try {
78
+ const newFileContents = origFileContents . replace ( 'color: white;' , 'color: purple;' ) ;
79
+ fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
99
80
100
- describe ( 'Angular template: production mode' , ( ) => {
101
- // csproj tooling takes the assembly name from <name>.csproj, whereas project.json takes it from the directory name
102
- const assemblyName = toolingType === 'csproj' ? 'TestApp.dll' : 'projectjson.dll' ;
103
- AspNetProcess . RunInMochaContext ( publishedAppDir , AspNetCoreEnviroment . production , assemblyName ) ;
104
- testBasicNavigation ( ) ;
81
+ browser . waitUntil ( ( ) => getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) === 'rgba(128,0,128,1)' ) ;
82
+ } finally {
83
+ // Restore old contents so that other tests don't have to account for this
84
+ fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
85
+ }
86
+ } ) ;
105
87
} ) ;
88
+ }
89
+
90
+ // Now launch dotnet and use selenium to perform tests
91
+ describe ( 'Angular template: dev mode' , ( ) => {
92
+ AspNetProcess . RunInMochaContext ( appDir , AspNetCoreEnviroment . development ) ;
93
+ testBasicNavigation ( ) ;
94
+ testHotModuleReplacement ( ) ;
106
95
} ) ;
96
+
97
+ describe ( 'Angular template: production mode' , ( ) => {
98
+ AspNetProcess . RunInMochaContext ( publishedAppDir , AspNetCoreEnviroment . production , 'TestApp.dll' ) ;
99
+ testBasicNavigation ( ) ;
100
+ } ) ;
0 commit comments