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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: appengine/config_service/ui/test/config-ui/front-page_test.html
diff --git a/appengine/config_service/ui/test/config-ui/front-page_test.html b/appengine/config_service/ui/test/config-ui/front-page_test.html
index 11f3ab7ded566f14f8445624732f30e0eb080674..905119932dfebea79b763ef40dba6df0ea88a7b4 100644
--- a/appengine/config_service/ui/test/config-ui/front-page_test.html
+++ b/appengine/config_service/ui/test/config-ui/front-page_test.html
@@ -26,14 +26,119 @@
</test-fixture>
<script>
- suite('<front-page>', function() {
- // TODO(cwpayton): write tests for the front page element.
+
+ suite('Front page with config sets:' +
+ '- 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.
+ '- sets isLoading by default' +
+ '- checks search results with different query variations' , function() {
+
+ var ajax;
+ var request;
+ var server;
+ var responseHeaders = {
+ json: { 'Content-Type': 'application/json' }
+ };
var front_page;
setup(function() {
+ server = sinon.fakeServer.create();
+ var param = {
+ event : {
+ detail: {
+ response: {
+ config_sets: [
+ {
+ config_set: "valid-project",
+ location: "https://chromium.googlesource.com/valid-project",
+ last_import_attempt: {success: true}
+ },{
+ config_set: "invalid-project",
+ location: "https://chromium.googlesource.com/invalid-project",
+ last_import_attempt: {success: false}
+ }]
+ }
+ }
+ }
+ };
+ server.respondWith(
+ 'GET',
+ /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=true/,
+ [
+ 200,
+ responseHeaders.json,
+ JSON.stringify(param)
+ ]
+ );
front_page = fixture('front-pageTestFixture');
+ ajax = Polymer.dom(front_page.root).querySelector('iron-ajax');
+ });
+
+ teardown(function() {
+ server.restore();
+ });
+
+ test('checks the config set list is empty before iron ajax call',
+ function() {
+ assert.equal(front_page.configSetList.length, 0);
+ });
+
+ test('checks the search results list is empty before iron ajax call',
+ function() {
+ assert.equal(front_page.searchResults.length, 0);
+ });
+
+ test('checks that isLoading property is true by default', function() {
+ assert.equal(front_page.isLoading, true);
});
+ test('gets iron-ajax response', function () {
+ request = ajax.generateRequest();
+ server.respond();
+ expect(request.response).to.be.ok;
+ expect(request.response).to.be.an('object');
+ expect(request.response.event).to.be.an('object');
+ 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.
+ assert.equal(front_page.isLoading, false);
+ assert.equal(front_page.configSetList.length, 2);
+ assert.deepEqual(front_page.configSetList,
+ front_page.searchResults);
+ assert.equal(front_page.configSetList[0].last_import_attempt.success,
+ true);
+ assert.equal(front_page.configSetList[1].last_import_attempt.success,
+ false);
+ });
+
+ test('query does not match any results', function () {
+ request = ajax.generateRequest();
+ server.respond();
+ front_page._onGotConfigSets(request.response.event);
+ front_page.query = "service";
+ assert.notEqual(front_page.configSetList,
+ front_page.searchResults);
+ assert.equal(front_page.searchResults.length, 0);
+ });
+
+ test('query matches all results', function () {
+ request = ajax.generateRequest();
+ server.respond();
+ front_page._onGotConfigSets(request.response.event);
+ front_page.query = "project";
+ assert.deepEqual(front_page.configSetList,
+ front_page.searchResults);
+ assert.equal(front_page.searchResults.length, 2);
+ });
+
+ test('query matches one result', function () {
+ request = ajax.generateRequest();
+ server.respond();
+ front_page._onGotConfigSets(request.response.event);
+ front_page.query = "valid-project";
+ assert.notEqual(front_page.configSetList,
+ front_page.searchResults);
+ assert.equal(front_page.searchResults[0].config_set, "valid-project");
+ });
+
});
+
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698