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

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: 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
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' +
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 server.respondWith(
45 'GET',
46 /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=tr ue/,
47 [
48 200,
49 responseHeaders.json,
50 '{"event": ' +
51 '{"detail": ' +
52 '{"response": ' +
53 '{"config_sets": [ ' +
54 '{"config_set": "valid-project", '+
55 '"location": "https://chromium.googlesource.com/valid-pr oject", ' +
56 '"last_import_attempt": {"success": true} ' +
57 '}, ' +
58 '{"config_set": "invalid-project", '+
59 '"location": "https://chromium.googlesource.com/invalid- project", ' +
60 '"last_import_attempt": {"success": false} ' +
61 '} ' +
62 ']} ' +
63 '} ' +
64 '} ' +
65 '} '
66 ]
67 );
33 front_page = fixture('front-pageTestFixture'); 68 front_page = fixture('front-pageTestFixture');
69 ajax = Polymer.dom(front_page.root).querySelector('iron-ajax');
34 }); 70 });
35 71
72 teardown(function() {
73 server.restore();
74 });
75
76 test('checks the config set list is empty before iron ajax call',
77 function() {
78 assert.equal(front_page.configSetList.length, 0);
79 });
80
81 test('checks the search results list is empty before iron ajax call',
82 function() {
83 assert.equal(front_page.searchResults.length, 0);
84 });
85
86 test('checks that isLoading property is true by default', function() {
87 assert.equal(front_page.isLoading, true);
88 });
89
90 test('gets iron-ajax response', function () {
91 request = ajax.generateRequest();
92 server.respond();
93 expect(request.response).to.be.ok;
94 expect(request.response).to.be.an('object');
95 expect(request.response.event).to.be.an('object');
96 front_page._onGotConfigSets(request.response.event);
97 assert.equal(front_page.isLoading, false);
98 assert.equal(front_page.configSetList.length, 2);
99 assert.deepEqual(front_page.configSetList,
100 front_page.searchResults);
101 assert.equal(front_page.configSetList[0].last_import_attempt.success,
102 true);
103 assert.equal(front_page.configSetList[1].last_import_attempt.success,
104 false);
105 });
106
107 test('query does not match any results', function () {
108 request = ajax.generateRequest();
109 server.respond();
110 front_page._onGotConfigSets(request.response.event);
111 front_page.query = "service";
112 assert.notEqual(front_page.configSetList,
113 front_page.searchResults);
114 assert.equal(front_page.searchResults.length, 0);
115 });
116
117 test('query matches all results', function () {
118 request = ajax.generateRequest();
119 server.respond();
120 front_page._onGotConfigSets(request.response.event);
121 front_page.query = "project";
122 assert.deepEqual(front_page.configSetList,
123 front_page.searchResults);
124 assert.equal(front_page.searchResults.length, 2);
125 });
126
127 test('query matches one result', function () {
128 request = ajax.generateRequest();
129 server.respond();
130 front_page._onGotConfigSets(request.response.event);
131 front_page.query = "valid-project";
132 assert.notEqual(front_page.configSetList,
133 front_page.searchResults);
134 assert.equal(front_page.searchResults[0].config_set, "valid-project");
135 });
136
36 }); 137 });
138
37 </script> 139 </script>
38 </body> 140 </body>
39 </html> 141 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698