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

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: 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 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..6334c7482d68640a4b7264ae1226344b1a3a4241 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,116 @@
</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' +
+ '- 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();
+ server.respondWith(
+ 'GET',
+ /\/_ah\/api\/config\/v1\/config-sets\?include_last_import_attempt=true/,
+ [
+ 200,
+ responseHeaders.json,
+ '{"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} ' +
+ '} ' +
+ ']} ' +
+ '} ' +
+ '} ' +
+ '} '
+ ]
+ );
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);
+ 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