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

Side by Side Diff: appengine/config_service/ui/test/config-ui/front-page_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
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">
11 <meta name="viewport" content="width=device-width, minimum-scale=1, initial- scale=1, user-scalable=yes"> 11 <meta name="viewport" content="width=device-width, minimum-scale=1, initial- scale=1, user-scalable=yes">
12 12
13 <title>front-page test</title> 13 <title>front-page test</title>
14 14
15 <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js">< /script> 15 <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js">< /script>
16 <script src="../../bower_components/web-component-tester/browser.js"></scrip t> 16 <script src="../../bower_components/web-component-tester/browser.js"></scrip t>
17 17
18 <link rel="import" href="../../src/config-ui/front-page.html"> 18 <link rel="import" href="../../src/config-ui/front-page.html">
19 </head> 19 </head>
20 <body> 20 <body>
21 21
22 <test-fixture id="front-pageTestFixture"> 22 <test-fixture id="front-pageTestFixture">
23 <template> 23 <template>
24 <front-page></front-page> 24 <front-page></front-page>
25 </template> 25 </template>
26 </test-fixture> 26 </test-fixture>
27 27
28 <script> 28 <script>
29 suite('<front-page>', function() { 29
30 // TODO(cwpayton): write tests for the front page element. 30 suite('Front page with config sets:' +
31 '- contains 2 config sets' +
Sergey Berezin 2017/07/10 23:53:33 Same as above - let's move these sub-bullets into
ayanaadylova 2017/07/11 00:23:21 Done.
32 '- sets isLoading by default' +
33 '- checks search results with different query variations' , function () {
34
35 var ajax;
36 var request;
37 var server;
38 var responseHeaders = {
39 json: { 'Content-Type': 'application/json' }
40 };
31 var front_page; 41 var front_page;
32 setup(function() { 42 setup(function() {
43 server = sinon.fakeServer.create();
44 var param = {
45 event : {
46 detail: {
47 response: {
48 config_sets: [
49 {
50 config_set: "valid-project",
51 location: "https://chromium.googlesource.com/valid-project",
52 last_import_attempt: {success: true}
53 },{
54 config_set: "invalid-project",
55 location: "https://chromium.googlesource.com/invalid-project ",
56 last_import_attempt: {success: false}
57 }]
58 }
59 }
60 }
61 };
62 server.respondWith(
63 'GET',
64 /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=tr ue/,
65 [
66 200,
67 responseHeaders.json,
68 JSON.stringify(param)
69 ]
70 );
33 front_page = fixture('front-pageTestFixture'); 71 front_page = fixture('front-pageTestFixture');
72 ajax = Polymer.dom(front_page.root).querySelector('iron-ajax');
34 }); 73 });
35 74
75 teardown(function() {
76 server.restore();
77 });
78
79 test('checks the config set list is empty before iron ajax call',
80 function() {
81 assert.equal(front_page.configSetList.length, 0);
82 });
83
84 test('checks the search results list is empty before iron ajax call',
85 function() {
86 assert.equal(front_page.searchResults.length, 0);
87 });
88
89 test('checks that isLoading property is true by default', function() {
90 assert.equal(front_page.isLoading, true);
91 });
92
93 test('gets iron-ajax response', function () {
94 request = ajax.generateRequest();
95 server.respond();
96 expect(request.response).to.be.ok;
97 expect(request.response).to.be.an('object');
98 expect(request.response.event).to.be.an('object');
99 front_page._onGotConfigSets(request.response.event);
Sergey Berezin 2017/07/10 23:53:33 nit: I'd add a "TODO(crbug.com/xxxxx): make the el
ayanaadylova 2017/07/11 00:23:21 Done.
100 assert.equal(front_page.isLoading, false);
101 assert.equal(front_page.configSetList.length, 2);
102 assert.deepEqual(front_page.configSetList,
103 front_page.searchResults);
104 assert.equal(front_page.configSetList[0].last_import_attempt.success,
105 true);
106 assert.equal(front_page.configSetList[1].last_import_attempt.success,
107 false);
108 });
109
110 test('query does not match any results', function () {
111 request = ajax.generateRequest();
112 server.respond();
113 front_page._onGotConfigSets(request.response.event);
114 front_page.query = "service";
115 assert.notEqual(front_page.configSetList,
116 front_page.searchResults);
117 assert.equal(front_page.searchResults.length, 0);
118 });
119
120 test('query matches all results', function () {
121 request = ajax.generateRequest();
122 server.respond();
123 front_page._onGotConfigSets(request.response.event);
124 front_page.query = "project";
125 assert.deepEqual(front_page.configSetList,
126 front_page.searchResults);
127 assert.equal(front_page.searchResults.length, 2);
128 });
129
130 test('query matches one result', function () {
131 request = ajax.generateRequest();
132 server.respond();
133 front_page._onGotConfigSets(request.response.event);
134 front_page.query = "valid-project";
135 assert.notEqual(front_page.configSetList,
136 front_page.searchResults);
137 assert.equal(front_page.searchResults[0].config_set, "valid-project");
138 });
139
36 }); 140 });
141
37 </script> 142 </script>
38 </body> 143 </body>
39 </html> 144 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698