@@ -5,97 +5,102 @@ 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
- // 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-2' ,
15
- name : 'Test App' ,
16
- sdkVersion : '1.0.0-preview2-1-003177' ,
17
- tests : false
18
- } ) ;
19
- publishProjectSync ( appDir , publishedAppDir ) ;
20
- }
21
-
22
- function testBasicNavigation ( ) {
23
- describe ( 'Basic navigation' , ( ) => {
24
- beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
25
-
26
- it ( 'should initially display the home page' , ( ) => {
27
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
28
- expect ( browser . getText ( 'li a[href="https://angular.io/"]' ) ) . to . eq ( 'Angular 2' ) ;
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
29
20
} ) ;
30
-
31
- it ( 'should be able to show the counter page' , ( ) => {
32
- browser . click ( 'a[href="/counter"]' ) ;
33
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Counter' ) ;
34
-
35
- // Test clicking the 'increment' button
36
- expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '0' ) ;
37
- browser . click ( 'counter button' ) ;
38
- expect ( browser . getText ( 'counter strong' ) ) . to . eq ( '1' ) ;
39
- } ) ;
40
-
41
- it ( 'should be able to show the fetchdata page' , ( ) => {
42
- browser . click ( 'a[href="/fetch-data"]' ) ;
43
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Weather forecast' ) ;
44
-
45
- browser . waitForExist ( 'fetchdata table' ) ;
46
- expect ( getValue ( browser . elements ( 'fetchdata table tbody tr' ) ) . length ) . to . eq ( 5 ) ;
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
+ } ) ;
47
50
} ) ;
48
- } ) ;
49
- }
51
+ }
50
52
51
- function testHotModuleReplacement ( ) {
52
- describe ( 'Hot module replacement' , ( ) => {
53
- beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
53
+ function testHotModuleReplacement ( ) {
54
+ describe ( 'Hot module replacement' , ( ) => {
55
+ beforeEach ( ( ) => browser . url ( defaultUrl ) ) ;
54
56
55
- it ( 'should update when HTML is changed' , ( ) => {
56
- expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
57
+ it ( 'should update when HTML is changed' , ( ) => {
58
+ expect ( browser . getText ( 'h1' ) ) . to . eq ( 'Hello, world!' ) ;
57
59
58
- const filePath = path . resolve ( appDir , './ClientApp/app/components/home/home.component.html' ) ;
59
- const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
60
+ const filePath = path . resolve ( appDir , './ClientApp/app/components/home/home.component.html' ) ;
61
+ const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
60
62
61
- try {
62
- const newFileContents = origFileContents . replace ( '<h1>Hello, world!</h1>' , '<h1>HMR is working</h1>' ) ;
63
- fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
63
+ try {
64
+ const newFileContents = origFileContents . replace ( '<h1>Hello, world!</h1>' , '<h1>HMR is working</h1>' ) ;
65
+ fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
64
66
65
- browser . waitUntil ( ( ) => browser . getText ( 'h1' ) . toString ( ) === 'HMR is working' ) ;
66
- } finally {
67
- // Restore old contents so that other tests don't have to account for this
68
- fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
69
- }
70
- } ) ;
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
+ } ) ;
71
73
72
- it ( 'should update when CSS is changed' , ( ) => {
73
- expect ( getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) ) . to . eq ( 'rgba(255,255,255,1)' ) ;
74
+ it ( 'should update when CSS is changed' , ( ) => {
75
+ expect ( getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) ) . to . eq ( 'rgba(255,255,255,1)' ) ;
74
76
75
- const filePath = path . resolve ( appDir , './ClientApp/app/components/navmenu/navmenu.component.css' ) ;
76
- const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
77
+ const filePath = path . resolve ( appDir , './ClientApp/app/components/navmenu/navmenu.component.css' ) ;
78
+ const origFileContents = fs . readFileSync ( filePath , 'utf8' ) ;
77
79
78
- try {
79
- const newFileContents = origFileContents . replace ( 'color: white;' , 'color: purple;' ) ;
80
- fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
80
+ try {
81
+ const newFileContents = origFileContents . replace ( 'color: white;' , 'color: purple;' ) ;
82
+ fs . writeFileSync ( filePath , newFileContents , { encoding : 'utf8' } ) ;
81
83
82
- browser . waitUntil ( ( ) => getCssPropertyValue ( browser , 'li.link-active a' , 'color' ) === 'rgba(128,0,128,1)' ) ;
83
- } finally {
84
- // Restore old contents so that other tests don't have to account for this
85
- fs . writeFileSync ( filePath , origFileContents , { encoding : 'utf8' } ) ;
86
- }
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
+ } ) ;
87
90
} ) ;
88
- } ) ;
89
- }
91
+ }
90
92
91
- // Now launch dotnet and use selenium to perform tests
92
- describe ( 'Angular template: dev mode' , ( ) => {
93
- AspNetProcess . RunInMochaContext ( appDir , AspNetCoreEnviroment . development ) ;
94
- testBasicNavigation ( ) ;
95
- testHotModuleReplacement ( ) ;
96
- } ) ;
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
+ } ) ;
97
99
98
- describe ( 'Angular template: production mode' , ( ) => {
99
- AspNetProcess . RunInMochaContext ( publishedAppDir , AspNetCoreEnviroment . production , 'angular.dll' ) ;
100
- testBasicNavigation ( ) ;
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 ( ) ;
105
+ } ) ;
101
106
} ) ;
0 commit comments