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

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: Add tests for config-set page and front-page. 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' +
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 server.respondWith(
55 'GET',
56 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\ -]+)&include_files=true&include_last_import_attempt=true/,
57 [
58 200,
59 responseHeaders.json,
60 '{"event": ' +
Ryan Tseng 2017/07/10 19:37:01 Just build a normal object and then use JSON.strin
ayanaadylova 2017/07/10 20:33:34 Done. It includes a javascript event object becau
61 '{"detail": ' +
62 '{"response": ' +
63 '{"config_sets": [ ' +
64 '{"files": ' +
65 '[{"path": "OWNERS"}, ' +
66 '{"path": "README.md"}], ' +
67 '"location": "https://chromium.googlesource.com/valid-pr oject-with-config-files", ' +
68 '"last_import_attempt": {"success": true} ' +
69 '}] ' +
70 '} ' +
71 '} ' +
72 '} ' +
73 '} '
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);
Ryan Tseng 2017/07/10 19:37:01 Doesn't this get triggered twice then? Once when i
ayanaadylova 2017/07/10 20:33:34 I thought it will trigger when when iron-ajax comp
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 server.respondWith(
129 'GET',
130 /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\ -]+)&include_files=true&include_last_import_attempt=true/,
131 [
132 200,
133 responseHeaders.json,
134 '{"event": ' +
135 '{"detail": ' +
136 '{"response": ' +
137 '{"config_sets": [ ' +
138 '{' +
139 '"location": "https://chromium.googlesource.com/invalid- project-without-config-files", ' +
140 '"last_import_attempt": {"success": false} ' +
141 '}] ' +
142 '} ' +
143 '} ' +
144 '} ' +
145 '} '
146 ]
147 );
148 config_set = fixture('invalid-project-without-config-files');
149 ajax = Polymer.dom(config_set.root).querySelector('iron-ajax');
150 });
151
152 teardown(function() {
153 server.restore();
154 });
155
156 test('checks the category of config set', function() {
157 assert.equal(config_set.category, 'projects');
158 });
159
160 test('checks the name of config set', function() {
161 assert.equal(config_set.name, 'invalid-project-without-config-files');
162 });
163
164 test('checks that isLoading property is true by default', function() {
165 assert.equal(config_set.isLoading, true);
166 });
167
168 test('gets iron-ajax response', function () {
169 request = ajax.generateRequest();
170 server.respond();
171 expect(request.response).to.be.ok;
172 expect(request.response).to.be.an('object');
173 expect(request.response.event).to.be.an('object');
174 config_set._onGotConfigFiles(request.response.event);
175 assert.equal(config_set.isLoading, false);
176 assert.equal(config_set.files.length, 0);
177 assert.equal(config_set.lastImportAttempt.success, false);
178 assert.equal(config_set.location,
179 "https://chromium.googlesource.com/invalid-project-without-config-fi les");
180 });
181
182 });
183
184 </script>
185 </body>
186 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698