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

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

Issue 2959833002: config_service: add last import validation and tests (Closed)
Patch Set: Fix some test files. Created 3 years, 5 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
OLDNEW
(Empty)
1 <!--
2 Copyright 2017 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file.
5 -->
6
7 <!doctype html>
8 <html lang="en">
9 <head>
10 <meta charset="utf-8">
11 <meta name="viewport" content="width=device-width, minimum-scale=1, initial- scale=1, user-scalable=yes">
12
13 <title>config-set test</title>
14
15 <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js">< /script>
16 <script src="../../bower_components/web-component-tester/browser.js"></scrip t>
17
18 <link rel="import" href="../../src/config-ui/config-set.html">
19 </head>
20 <body>
21
22 <test-fixture id="valid-project-with-config-files">
23 <template>
24 <config-set category="projects"
25 name="valid-project-with-config-files"></config-set>
26 </template>
27 </test-fixture>
28
29 <test-fixture id="invalid-project-without-config-files">
30 <template>
31 <config-set category="projects"
32 name="invalid-project-without-config-files"></config-set>
33 </template>
34 </test-fixture>
35
36 <script>
37 suite('Valid project with config files:' +
38 '- has correct category' +
Sergey Berezin 2017/07/10 23:53:33 Let's move these sub-bullets into test names. So y
ayanaadylova 2017/07/11 00:23:21 Done.
39 '- has correct name' +
40 '- contains 2 config files' +
41 '- sets isLoading by default' +
42 '- has valid last import attempt', function() {
43
44 var ajax;
45 var request;
46 var server;
47 var responseHeaders = {
48 json: { 'Content-Type': 'application/json' }
49 };
50 var config_set;
51
52 setup(function() {
53 server = sinon.fakeServer.create();
54 var param = {
55 event : {
56 detail: {
57 response: {
58 config_sets: [{
59 files: [{path: "OWNERS"}, {path: "README.md"}],
60 location: "https://chromium.googlesource.com/valid-project-w ith-config-files",
Sergey Berezin 2017/07/10 23:53:33 nit: let's make the domain name also look obviousl
ayanaadylova 2017/07/11 00:23:21 Done.
61 last_import_attempt: {success: true}
62 }]
63 }
64 }
65 }
66 };
67 server.respondWith(
68 'GET',
69 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\ -]+)&include_files=true&include_last_import_attempt=true/,
70 [
71 200,
72 responseHeaders.json,
73 JSON.stringify(param)
74 ]
75 );
76 config_set = fixture('valid-project-with-config-files');
77 ajax = Polymer.dom(config_set.root).querySelector('iron-ajax');
78 });
79
80 teardown(function() {
81 server.restore();
82 });
83
84 test('checks the category of config set', function() {
85 assert.equal(config_set.category, 'projects');
86 });
87
88 test('checks the name of config set', function() {
89 assert.equal(config_set.name, 'valid-project-with-config-files');
90 });
91
92 test('checks that isLoading property is true by default', function() {
93 assert.equal(config_set.isLoading, true);
94 });
95
96 test('gets iron-ajax response', function () {
97 request = ajax.generateRequest();
98 server.respond();
99 expect(request.response).to.be.ok;
100 expect(request.response).to.be.an('object');
101 expect(request.response.event).to.be.an('object');
102 config_set._onGotConfigFiles(request.response.event);
103 assert.equal(config_set.isLoading, false);
104 assert.equal(config_set.files.length, 2);
105 assert.equal(config_set.lastImportAttempt.success, true);
106 assert.equal(config_set.location,
107 "https://chromium.googlesource.com/valid-project-with-config-files") ;
108 });
109
110 });
111
112 suite('Inalid project without config files:' +
113 '- has correct category' +
114 '- has correct name' +
115 '- contains 0 config files' +
116 '- sets isLoading by default' +
117 '- has invalid last import attempt', function() {
118 var ajax;
119 var request;
120 var server;
121 var responseHeaders = {
122 json: { 'Content-Type': 'application/json' }
123 };
124 var config_set;
125
126 setup(function() {
127 server = sinon.fakeServer.create();
128 var param = {
129 event : {
130 detail: {
131 response: {
132 config_sets: [{
133 location: "https://chromium.googlesource.com/invalid-project -without-config-files",
134 last_import_attempt: {success: false}
135 }]
136 }
137 }
138 }
139 };
140 server.respondWith(
141 'GET',
142 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\ -]+)&include_files=true&include_last_import_attempt=true/,
143 [
144 200,
145 responseHeaders.json,
146 JSON.stringify(param)
147 ]
148 );
149 config_set = fixture('invalid-project-without-config-files');
150 ajax = Polymer.dom(config_set.root).querySelector('iron-ajax');
151 });
152
153 teardown(function() {
154 server.restore();
155 });
156
157 test('checks the category of config set', function() {
158 assert.equal(config_set.category, 'projects');
159 });
160
161 test('checks the name of config set', function() {
162 assert.equal(config_set.name, 'invalid-project-without-config-files');
163 });
164
165 test('checks that isLoading property is true by default', function() {
166 assert.equal(config_set.isLoading, true);
167 });
168
169 test('gets iron-ajax response', function () {
170 request = ajax.generateRequest();
171 server.respond();
172 expect(request.response).to.be.ok;
173 expect(request.response).to.be.an('object');
174 expect(request.response.event).to.be.an('object');
175 config_set._onGotConfigFiles(request.response.event);
Sergey Berezin 2017/07/10 23:53:33 nit: IMHO it's OK for this CL to call the event ex
ayanaadylova 2017/07/11 00:23:21 Done.
176 assert.equal(config_set.isLoading, false);
177 assert.equal(config_set.files.length, 0);
178 assert.equal(config_set.lastImportAttempt.success, false);
179 assert.equal(config_set.location,
180 "https://chromium.googlesource.com/invalid-project-without-config-fi les");
181 });
182
183 });
184
185 </script>
186 </body>
187 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698