@@ -21,6 +21,9 @@ describe('docs.angularjs.org', function() {
21
21
console . log ( 'browser console errors: ' + require ( 'util' ) . inspect ( filteredLog ) ) ;
22
22
}
23
23
} ) ;
24
+
25
+ browser . ignoreSynchronization = false ;
26
+ browser . clearMockModules ( ) ;
24
27
} ) ;
25
28
26
29
@@ -102,6 +105,66 @@ describe('docs.angularjs.org', function() {
102
105
expect ( mainHeader . getText ( ) ) . toEqual ( 'Oops!' ) ;
103
106
} ) ;
104
107
108
+ it ( 'should set "noindex" if the page does not exist' , function ( ) {
109
+ browser . get ( 'build/docs/index-production.html#!/api/does/not/exist' ) ;
110
+ var robots = element ( by . css ( 'meta[name="robots"][content="noindex"]' ) ) ;
111
+ var googleBot = element ( by . css ( 'meta[name="googlebot"][content="noindex"]' ) ) ;
112
+ expect ( robots . isPresent ( ) ) . toBe ( true ) ;
113
+ expect ( googleBot . isPresent ( ) ) . toBe ( true ) ;
114
+ } ) ;
115
+
116
+ it ( 'should remove "noindex" if the page exists' , function ( ) {
117
+ browser . get ( 'build/docs/index-production.html#!/api' ) ;
118
+ var robots = element ( by . css ( 'meta[name="robots"][content="noindex"]' ) ) ;
119
+ var googleBot = element ( by . css ( 'meta[name="googlebot"][content="noindex"]' ) ) ;
120
+ expect ( robots . isPresent ( ) ) . toBe ( false ) ;
121
+ expect ( googleBot . isPresent ( ) ) . toBe ( false ) ;
122
+ } ) ;
123
+
124
+ describe ( 'template request error' , function ( ) {
125
+ beforeEach ( function ( ) {
126
+ browser . addMockModule ( 'httpMocker' , function ( ) {
127
+ angular . module ( 'httpMocker' , [ 'ngMock' ] )
128
+ . run ( [ '$httpBackend' , function ( $httpBackend ) {
129
+ $httpBackend . whenGET ( 'localhost:8000/build/docs/partials/api.html' ) . respond ( 404 , '' ) ;
130
+ } ] ) ;
131
+ } ) ;
132
+ } ) ;
133
+
134
+ it ( 'should set "noindex" for googlebot if the request fails' , function ( ) {
135
+ // index-test includes ngMock
136
+ browser . get ( 'build/docs/index-test.html#!/api' ) ;
137
+ var robots = element ( by . css ( 'meta[name="robots"][content="noindex"]' ) ) ;
138
+ var googleBot = element ( by . css ( 'meta[name="googlebot"][content="noindex"]' ) ) ;
139
+ expect ( robots . isPresent ( ) ) . toBe ( false ) ;
140
+ expect ( googleBot . isPresent ( ) ) . toBe ( true ) ;
141
+ } ) ;
142
+ } ) ;
143
+
144
+
145
+ describe ( 'page bootstrap error' , function ( ) {
146
+ beforeEach ( function ( ) {
147
+ browser . addMockModule ( 'httpMocker' , function ( ) {
148
+ // Require a module that does not exist to break the bootstrapping
149
+ angular . module ( 'httpMocker' , [ 'doesNotExist' ] ) ;
150
+ } ) ;
151
+ } ) ;
152
+
153
+ it ( 'should have "noindex" for googlebot if bootstrapping fails' , function ( ) {
154
+ browser . get ( 'build/docs/index.html#!/api' ) . catch ( function ( ) {
155
+ // get() will fail on AngularJS bootstrap, but if we continue here, protractor
156
+ // will assume the app is ready
157
+ browser . ignoreSynchronization = true ;
158
+ var robots = element ( by . css ( 'meta[name="robots"][content="noindex"]' ) ) ;
159
+ var googleBot = element ( by . css ( 'meta[name="googlebot"][content="noindex"]' ) ) ;
160
+ expect ( robots . isPresent ( ) ) . toBe ( false ) ;
161
+ expect ( googleBot . isPresent ( ) ) . toBe ( true ) ;
162
+ } ) ;
163
+ } ) ;
164
+
165
+
166
+ } ) ;
167
+
105
168
} ) ;
106
169
107
170
} ) ;
0 commit comments