Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: appengine/config_service/ui/test/config-ui/front-page_test.html

Issue 2985923002: config_service: Handled errors in the front page (Closed)
Patch Set: Removed extraneous code from testing suite and fixed error messages Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/config_service/ui/src/config-ui/front-page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 Copyright 2017 The LUCI Authors. All rights reserved. 2 Copyright 2017 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 --> 5 -->
6 6
7 <!doctype html> 7 <!doctype html>
8 <html lang="en"> 8 <html lang="en">
9 <head> 9 <head>
10 <meta charset="utf-8"> 10 <meta charset="utf-8">
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 server.respond(); 136 server.respond();
137 front_page.addEventListener('processedConfigSets', function() { 137 front_page.addEventListener('processedConfigSets', function() {
138 front_page.query = "invalid-project"; 138 front_page.query = "invalid-project";
139 assert.notEqual(front_page.configSetList, 139 assert.notEqual(front_page.configSetList,
140 front_page.searchResults); 140 front_page.searchResults);
141 assert.equal(front_page.searchResults[0].config_set, "invalid-projec t"); 141 assert.equal(front_page.searchResults[0].config_set, "invalid-projec t");
142 done(); 142 done();
143 }.bind(front_page)); 143 }.bind(front_page));
144 }); 144 });
145 }); 145 });
146
147 suite('Front page handles ajax errors correctly', function() {
148 var ajax;
149 var request;
150 var server500;
151 var server403;
152 var server400;
153 var responseHeaders = {
154 json: { 'Content-Type': 'application/json' }
155 };
156 var front_page;
157 setup(function() {
158 server500 = sinon.fakeServer.create();
Sergey Berezin 2017/07/26 23:09:13 Suggestion: instead of using setup(), how about cr
159 var param500 = {
160 error: {
161 code: 500,
162 message: "Internal Server Error."
163 }
164 }
165 server500.respondWith(
166 'GET',
167 /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=tr ue/,
168 [
169 500,
170 responseHeaders.json,
171 JSON.stringify(param500)
172 ]
173 );
174
175 server403 = sinon.fakeServer.create();
176 var param403 = {
177 error: {
178 code: 403,
179 message: "The request returned with a status of 403."
180 }
181 }
182 server403.respondWith(
183 'GET',
184 /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=tr ue/,
185 [
186 403,
187 responseHeaders.json,
188 JSON.stringify(param403)
189 ]
190 );
191
192 server400 = sinon.fakeServer.create();
193 var param400 = {
194 error: {
195 code: 400,
196 message: "This error represents all errors that are not forbidden or internal server errors."
197 }
198 }
199 server400.respondWith(
200 'GET',
201 /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=tr ue/,
202 [
203 400,
204 responseHeaders.json,
205 JSON.stringify(param400)
206 ]
207 );
208 front_page = fixture('front-pageTestFixture');
209 ajax = Polymer.dom(front_page.root).querySelector('iron-ajax');
210 });
211
212 teardown(function() {
213 server500.restore();
214 server403.restore();
215 server400.restore();
216 });
217
218 test('front page handles 500 error', function() {
219 request = ajax.generateRequest();
220 server500.respond();
221 front_page.addEventListener('fetchError', function() {
222 expect(front_page.errorMessage).to.be
223 .equal("Internal server error. Please refresh or try again later .");
224 })
225 });
226
227 test('front page handles 403 error', function() {
228 request = ajax.generateRequest();
229 server403.respond();
230 front_page.addEventListener('fetchError', function() {
231 expect(front_page.errorMessage).to.be.equal("Access denied.");
232 })
233 });
234
235 test('front page handles error that is not 403 or 500', function() {
236 request = ajax.generateRequest();
237 server400.respond();
238 front_page.addEventListener('fetchError', function() {
239 expect(front_page.errorMessage).to.be.equal("Error occured. Please t ry again later.");
240 })
241 });
242 });
146 </script> 243 </script>
147 </body> 244 </body>
148 </html> 245 </html>
OLDNEW
« no previous file with comments | « appengine/config_service/ui/src/config-ui/front-page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698