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

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

Issue 2985223002: config_service: Changed file links to point to latest revision instead of master (Closed)
Patch Set: Created a function to set up server properly for each test 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/config-set.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 28 matching lines...) Expand all
39 var ajax; 39 var ajax;
40 var request; 40 var request;
41 var server; 41 var server;
42 var responseHeaders = { 42 var responseHeaders = {
43 json: { 'Content-Type': 'application/json' } 43 json: { 'Content-Type': 'application/json' }
44 }; 44 };
45 var config_set; 45 var config_set;
46 46
47 setup(function() { 47 setup(function() {
48 server = sinon.fakeServer.create(); 48 server = sinon.fakeServer.create();
49 var param = {
50 config_sets: [{
51 files: [{path: "OWNERS"}, {path: "README.md"}],
52 location: "https://test.com/valid-project-with-config-files",
53 last_import_attempt: {success: true}
54 }]
55 };
56 server.respondWith(
57 'GET',
58 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)\/([a-z\- ]+)&include_files=true&include_last_import_attempt=true/,
59 [
60 200,
61 responseHeaders.json,
62 JSON.stringify(param)
63 ]
64 );
65 config_set = fixture('valid-project-with-config-files'); 49 config_set = fixture('valid-project-with-config-files');
66 ajax = Polymer.dom(config_set.root).querySelector('#requestConfigs'); 50 ajax = Polymer.dom(config_set.root).querySelector('#requestConfigs');
67 }); 51 });
68 52
69 teardown(function() { 53 teardown(function() {
70 server.restore(); 54 server.restore();
71 }); 55 });
72 56
57 function setserver(param) {
58 server.respondWith(
59 'GET',
60 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)\/([a-z\- ]+)&include_files=true&include_last_import_attempt=true/,
61 [
62 200,
63 responseHeaders.json,
64 JSON.stringify(param)
65 ]
66 );
67 }
68
73 test('has correct category', function() { 69 test('has correct category', function() {
74 assert.equal(config_set.category, 'projects'); 70 assert.equal(config_set.category, 'projects');
75 }); 71 });
76 72
77 test('has correct name', function() { 73 test('has correct name', function() {
78 assert.equal(config_set.name, 'valid-project-with-config-files'); 74 assert.equal(config_set.name, 'valid-project-with-config-files');
79 }); 75 });
80 76
81 test('sets isLoading by default', function() { 77 test('sets isLoading by default', function() {
82 assert.equal(config_set.isLoading, true); 78 assert.equal(config_set.isLoading, true);
83 }); 79 });
84 80
85 test('gets iron-ajax response', function (done) { 81 test('gets iron-ajax response', function (done) {
82 var param = {
83 config_sets: [{
84 files: [{path: "OWNERS"}, {path: "README.md"}],
85 last_import_attempt: { success: true },
86 }]
87 };
88 setserver(param);
86 request = ajax.generateRequest(); 89 request = ajax.generateRequest();
87 server.respond(); 90 server.respond();
88 assert.equal(request.status, 200); 91 assert.equal(request.status, 200);
89 assert.isObject(request.response); 92 assert.isObject(request.response);
90 config_set.addEventListener('processedConfigFiles', function() { 93 config_set.addEventListener('processedConfigFiles', function() {
91 assert.equal(config_set.isLoading, false); 94 assert.equal(config_set.isLoading, false);
92 assert.equal(config_set.files.length, 2); 95 assert.equal(config_set.files.length, 2);
93 assert.equal(config_set.lastImportAttempt.success, true); 96 assert.equal(config_set.lastImportAttempt.success, true);
94 assert.equal(config_set.location,
95 "https://test.com/valid-project-with-config-files");
96 done(); 97 done();
97 }.bind(config_set)); 98 }.bind(config_set));
98 }); 99 });
100
101 test('correct url when revision is provided', function(done) {
Sergey Berezin 2017/07/27 23:03:58 nit: '_has_ correct url...'
cwpayton 2017/07/27 23:14:26 Done.
102 var param = {
103 config_sets: [{
104 files: [{path: "OWNERS"}, {path: "README.md"}],
105 location: "https://test.com/refs/master/valid-project-with-config- files",
106 last_import_attempt: {
107 success: true,
108 revision: {
109 url: "https://test.com/120c81237zv23hj22/valid-project-with-co nfig-files",
110 timestamp: "1501162530000000"
111 }
112 },
113 revision: {
114 url: "https://test.com/120c81237zv23hj22/valid-project-with-conf ig-files",
115 id: "4acc18843ff0b8cc858d4cc92ea6fe030cefc2b7"
116 }
117 }]
118 };
119 setserver(param);
120 request = ajax.generateRequest();
121 server.respond();
122 config_set.addEventListener('processedConfigFiles', function() {
123 assert.equal(config_set.url, "https://test.com/120c81237zv23hj22/val id-project-with-config-files");
124 done();
125 }.bind(config_set));
126 });
127
128 test('correct url when revision is not provided', function(done) {
Sergey Berezin 2017/07/27 23:03:58 nit: 'has correct url...'
cwpayton 2017/07/27 23:14:26 Done.
129 var param = {
130 config_sets: [{
131 files: [{path: "OWNERS"}, {path: "README.md"}],
132 location: "https://test.com/refs/master/valid-project-with-config- files",
133 }]
134 };
135 setserver(param);
136 request = ajax.generateRequest();
137 server.respond();
138 config_set.addEventListener('processedConfigFiles', function() {
139 assert.equal(config_set.url, "https://test.com/refs/master/valid-pro ject-with-config-files");
140 done();
141 }.bind(config_set));
142 });
99 }); 143 });
100 144
101 suite('Inalid project without config files', function() { 145 suite('Inalid project without config files', function() {
102 var ajax; 146 var ajax;
103 var request; 147 var request;
104 var server; 148 var server;
105 var responseHeaders = { 149 var responseHeaders = {
106 json: { 'Content-Type': 'application/json' } 150 json: { 'Content-Type': 'application/json' }
107 }; 151 };
108 var config_set; 152 var config_set;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 190
147 test('gets iron-ajax response', function (done) { 191 test('gets iron-ajax response', function (done) {
148 request = ajax.generateRequest(); 192 request = ajax.generateRequest();
149 server.respond(); 193 server.respond();
150 assert.equal(request.status, 200); 194 assert.equal(request.status, 200);
151 assert.isObject(request.response); 195 assert.isObject(request.response);
152 config_set.addEventListener('processedConfigFiles', function() { 196 config_set.addEventListener('processedConfigFiles', function() {
153 assert.equal(config_set.isLoading, false); 197 assert.equal(config_set.isLoading, false);
154 assert.equal(config_set.files.length, 0); 198 assert.equal(config_set.files.length, 0);
155 assert.equal(config_set.lastImportAttempt.success, false); 199 assert.equal(config_set.lastImportAttempt.success, false);
156 assert.equal(config_set.location, 200 assert.equal(config_set.url,
157 "https://test.com/invalid-project-without-config-files"); 201 "https://test.com/invalid-project-without-config-files");
158 done(); 202 done();
159 }.bind(config_set)); 203 }.bind(config_set));
160 }); 204 });
161 }); 205 });
162 206
163 suite('Successful force refresh', function() { 207 suite('Successful force refresh', function() {
164 var ajax; 208 var ajax;
165 var request; 209 var request;
166 var server; 210 var server;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 assert.equal(config_set.errorMessage, "Internal server error."); 374 assert.equal(config_set.errorMessage, "Internal server error.");
331 done(); 375 done();
332 }.bind(config_set)); 376 }.bind(config_set));
333 }); 377 });
334 378
335 }); 379 });
336 380
337 </script> 381 </script>
338 </body> 382 </body>
339 </html> 383 </html>
OLDNEW
« no previous file with comments | « appengine/config_service/ui/src/config-ui/config-set.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698