Chromium Code Reviews| Index: appengine/config_service/ui/test/config-ui/config-set_test.html |
| diff --git a/appengine/config_service/ui/test/config-ui/config-set_test.html b/appengine/config_service/ui/test/config-ui/config-set_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..58b97beb2967024f07250cf883f6e7f3719991b4 |
| --- /dev/null |
| +++ b/appengine/config_service/ui/test/config-ui/config-set_test.html |
| @@ -0,0 +1,187 @@ |
| +<!-- |
| + Copyright 2017 The LUCI Authors. All rights reserved. |
| + Use of this source code is governed under the Apache License, Version 2.0 |
| + that can be found in the LICENSE file. |
| +--> |
| + |
| +<!doctype html> |
| +<html lang="en"> |
| + <head> |
| + <meta charset="utf-8"> |
| + <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> |
| + |
| + <title>config-set test</title> |
| + |
| + <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script> |
| + <script src="../../bower_components/web-component-tester/browser.js"></script> |
| + |
| + <link rel="import" href="../../src/config-ui/config-set.html"> |
| + </head> |
| + <body> |
| + |
| + <test-fixture id="valid-project-with-config-files"> |
| + <template> |
| + <config-set category="projects" |
| + name="valid-project-with-config-files"></config-set> |
| + </template> |
| + </test-fixture> |
| + |
| + <test-fixture id="invalid-project-without-config-files"> |
| + <template> |
| + <config-set category="projects" |
| + name="invalid-project-without-config-files"></config-set> |
| + </template> |
| + </test-fixture> |
| + |
| + <script> |
| + suite('Valid project with config files:' + |
| + '- has correct category' + |
|
Sergey Berezin
2017/07/10 23:53:33
Let's move these sub-bullets into test names. So y
ayanaadylova
2017/07/11 00:23:21
Done.
|
| + '- has correct name' + |
| + '- contains 2 config files' + |
| + '- sets isLoading by default' + |
| + '- has valid last import attempt', function() { |
| + |
| + var ajax; |
| + var request; |
| + var server; |
| + var responseHeaders = { |
| + json: { 'Content-Type': 'application/json' } |
| + }; |
| + var config_set; |
| + |
| + setup(function() { |
| + server = sinon.fakeServer.create(); |
| + var param = { |
| + event : { |
| + detail: { |
| + response: { |
| + config_sets: [{ |
| + files: [{path: "OWNERS"}, {path: "README.md"}], |
| + location: "https://chromium.googlesource.com/valid-project-with-config-files", |
|
Sergey Berezin
2017/07/10 23:53:33
nit: let's make the domain name also look obviousl
ayanaadylova
2017/07/11 00:23:21
Done.
|
| + last_import_attempt: {success: true} |
| + }] |
| + } |
| + } |
| + } |
| + }; |
| + server.respondWith( |
| + 'GET', |
| + /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\-]+)&include_files=true&include_last_import_attempt=true/, |
| + [ |
| + 200, |
| + responseHeaders.json, |
| + JSON.stringify(param) |
| + ] |
| + ); |
| + config_set = fixture('valid-project-with-config-files'); |
| + ajax = Polymer.dom(config_set.root).querySelector('iron-ajax'); |
| + }); |
| + |
| + teardown(function() { |
| + server.restore(); |
| + }); |
| + |
| + test('checks the category of config set', function() { |
| + assert.equal(config_set.category, 'projects'); |
| + }); |
| + |
| + test('checks the name of config set', function() { |
| + assert.equal(config_set.name, 'valid-project-with-config-files'); |
| + }); |
| + |
| + test('checks that isLoading property is true by default', function() { |
| + assert.equal(config_set.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'); |
| + config_set._onGotConfigFiles(request.response.event); |
| + assert.equal(config_set.isLoading, false); |
| + assert.equal(config_set.files.length, 2); |
| + assert.equal(config_set.lastImportAttempt.success, true); |
| + assert.equal(config_set.location, |
| + "https://chromium.googlesource.com/valid-project-with-config-files"); |
| + }); |
| + |
| + }); |
| + |
| + suite('Inalid project without config files:' + |
| + '- has correct category' + |
| + '- has correct name' + |
| + '- contains 0 config files' + |
| + '- sets isLoading by default' + |
| + '- has invalid last import attempt', function() { |
| + var ajax; |
| + var request; |
| + var server; |
| + var responseHeaders = { |
| + json: { 'Content-Type': 'application/json' } |
| + }; |
| + var config_set; |
| + |
| + setup(function() { |
| + server = sinon.fakeServer.create(); |
| + var param = { |
| + event : { |
| + detail: { |
| + response: { |
| + config_sets: [{ |
| + location: "https://chromium.googlesource.com/invalid-project-without-config-files", |
| + last_import_attempt: {success: false} |
| + }] |
| + } |
| + } |
| + } |
| + }; |
| + server.respondWith( |
| + 'GET', |
| + /\/_ah\/api\/config\/v1\/config-sets\?config_set=([a-z\-]+)%2F([a-z\-]+)&include_files=true&include_last_import_attempt=true/, |
| + [ |
| + 200, |
| + responseHeaders.json, |
| + JSON.stringify(param) |
| + ] |
| + ); |
| + config_set = fixture('invalid-project-without-config-files'); |
| + ajax = Polymer.dom(config_set.root).querySelector('iron-ajax'); |
| + }); |
| + |
| + teardown(function() { |
| + server.restore(); |
| + }); |
| + |
| + test('checks the category of config set', function() { |
| + assert.equal(config_set.category, 'projects'); |
| + }); |
| + |
| + test('checks the name of config set', function() { |
| + assert.equal(config_set.name, 'invalid-project-without-config-files'); |
| + }); |
| + |
| + test('checks that isLoading property is true by default', function() { |
| + assert.equal(config_set.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'); |
| + config_set._onGotConfigFiles(request.response.event); |
|
Sergey Berezin
2017/07/10 23:53:33
nit: IMHO it's OK for this CL to call the event ex
ayanaadylova
2017/07/11 00:23:21
Done.
|
| + assert.equal(config_set.isLoading, false); |
| + assert.equal(config_set.files.length, 0); |
| + assert.equal(config_set.lastImportAttempt.success, false); |
| + assert.equal(config_set.location, |
| + "https://chromium.googlesource.com/invalid-project-without-config-files"); |
| + }); |
| + |
| + }); |
| + |
| + </script> |
| + </body> |
| +</html> |