116 lines
3.4 KiB
HTML
116 lines
3.4 KiB
HTML
<!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="../../plugins/gr-plugin-host/gr-plugin-host.html">
|
|
<link rel="import" href="gr-change-metadata.html">
|
|
|
|
<script>void(0);</script>
|
|
|
|
<test-fixture id="element">
|
|
<template>
|
|
<gr-change-metadata></gr-change-metadata>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<test-fixture id="plugin-host">
|
|
<template>
|
|
<gr-plugin-host></gr-plugin-host>
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
suite('gr-change-metadata integration tests', () => {
|
|
let sandbox;
|
|
let element;
|
|
|
|
const sectionSelectors = [
|
|
'section.assignee',
|
|
'section.labelStatus',
|
|
'section.strategy',
|
|
'section.topic',
|
|
];
|
|
|
|
const getStyle = function(selector, name) {
|
|
return window.getComputedStyle(
|
|
Polymer.dom(element.root).querySelector(selector))[name];
|
|
};
|
|
|
|
setup(() => {
|
|
sandbox = sinon.sandbox.create();
|
|
stub('gr-change-metadata', {
|
|
_computeShowLabelStatus() { return true; },
|
|
_computeShowReviewersByState() { return true; },
|
|
ready() {
|
|
this.change = {labels: []};
|
|
this.serverConfig = {};
|
|
},
|
|
});
|
|
});
|
|
|
|
teardown(() => {
|
|
Gerrit._pluginsPending = -1;
|
|
Gerrit._allPluginsPromise = undefined;
|
|
sandbox.restore();
|
|
});
|
|
|
|
suite('by default', () => {
|
|
setup(done => {
|
|
element = fixture('element');
|
|
flush(done);
|
|
});
|
|
|
|
for (const sectionSelector of sectionSelectors) {
|
|
test(sectionSelector + ' does not have display: none', () => {
|
|
assert.notEqual(getStyle(sectionSelector, 'display'), 'none');
|
|
});
|
|
}
|
|
});
|
|
|
|
suite('with plugin style', () => {
|
|
setup(done => {
|
|
const pluginHost = fixture('plugin-host');
|
|
pluginHost.config = {
|
|
js_resource_paths: [],
|
|
html_resource_paths: [
|
|
new URL('test/plugin.html', window.location.href).toString(),
|
|
],
|
|
};
|
|
element = fixture('element');
|
|
const importSpy = sandbox.spy(element.$.externalStyle, '_import');
|
|
Gerrit.awaitPluginsLoaded().then(() => {
|
|
Promise.all(importSpy.returnValues).then(() => {
|
|
flush(done);
|
|
});
|
|
});
|
|
});
|
|
|
|
for (const sectionSelector of sectionSelectors) {
|
|
test(sectionSelector + ' may have display: none', () => {
|
|
assert.equal(getStyle(sectionSelector, 'display'), 'none');
|
|
});
|
|
}
|
|
});
|
|
});
|
|
</script>
|