| <!DOCTYPE html> |
| <!-- |
| Copyright (C) 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <title>gr-change-metadata</title> |
| |
| <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> |
| <script src="../../../bower_components/web-component-tester/browser.js"></script> |
| |
| <link rel="import" href="../../../bower_components/iron-test-helpers/iron-test-helpers.html"> |
| <link rel="import" href="gr-change-metadata.html"> |
| |
| <test-fixture id="plugin"> |
| <template> |
| <script> |
| Gerrit.install(function(plugin) { |
| plugin.registerStyleModule('change-metadata', 'some-style'); |
| }, '', 'http://x/plugins/foo.js'); |
| </script> |
| </template> |
| </test-fixture> |
| |
| <test-fixture id="some-style"> |
| <template> |
| <dom-module id="some-style"> |
| <style> |
| :root { |
| --change-metadata-assignee: { |
| display: none; |
| } |
| --change-metadata-label-status: { |
| display: none; |
| } |
| --change-metadata-strategy: { |
| display: none; |
| } |
| --change-metadata-topic: { |
| display: none; |
| } |
| } |
| </style> |
| </dom-module> |
| </template> |
| </test-fixture> |
| |
| <test-fixture id="element"> |
| <template> |
| <gr-change-metadata></gr-change-metadata> |
| </template> |
| </test-fixture> |
| |
| <script> |
| suite('gr-change-metadata integration tests', function() { |
| var sandbox; |
| var plugin; |
| var element; |
| |
| var sectionSelectors = [ |
| 'section.assignee', |
| 'section.labelStatus', |
| 'section.strategy', |
| 'section.topic', |
| ]; |
| |
| var getStyle = function(selector, name) { |
| return window.getComputedStyle( |
| Polymer.dom(element.root).querySelector(selector))[name]; |
| }; |
| |
| setup(function() { |
| Gerrit._pluginsPending = 0; |
| sandbox = sinon.sandbox.create(); |
| stub('gr-change-metadata', { |
| _computeShowLabelStatus: function() { return true; }, |
| _computeShowReviewersByState: function() { return true; }, |
| ready: function() { |
| this.change = {labels:[]}; |
| this.serverConfig = {}; |
| }, |
| }); |
| }); |
| |
| teardown(function() { |
| sandbox.restore(); |
| }); |
| |
| suite('by default', function() { |
| setup(function(done) { |
| element = fixture('element'); |
| flush(done); |
| }); |
| |
| sectionSelectors.forEach(function(sectionSelector) { |
| test(sectionSelector + ' does not have display: none', function() { |
| assert.notEqual( |
| getStyle(sectionSelector, 'display'), 'none'); |
| }); |
| }); |
| }); |
| |
| suite('with plugin style', function() { |
| var styleEl; |
| |
| setup(function(done) { |
| styleEl = fixture('some-style'); |
| element = fixture('element'); |
| plugin = fixture('plugin'); |
| flush(done); |
| }); |
| |
| sectionSelectors.forEach(function(sectionSelector) { |
| test(sectionSelector + ' may have display: none', function() { |
| assert.equal( |
| getStyle(sectionSelector, 'display'), 'none'); |
| }); |
| }); |
| }); |
| }); |
| </script> |