Files
gerrit/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_test.html
Wyatt Allen f3c7bf1560 Remove old class when status chip status is updated
The change view renders status chips in dom-repeat, which, by default,
will reuse and reconfigure instances when the data changes. However,
status chips only added classes when their status was configured, and
did not remove classes. As a result, a reused chip could contain classes
from other statuses. With this change, the chip removes the previous
class when the status is updated.

Bug: Issue 7592
Change-Id: I89354790307fddf5262d0407b3ecc60124df7a5b
2017-10-27 13:15:11 -07:00

94 lines
3.0 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-status</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="../../../test/common-test-setup.html"/>
<link rel="import" href="gr-change-status.html">
<script>void(0);</script>
<test-fixture id="basic">
<template>
<gr-change-status></gr-change-status>
</template>
</test-fixture>
<script>
suite('gr-change-status tests', () => {
let element;
let sandbox;
setup(() => {
element = fixture('basic');
sandbox = sinon.sandbox.create();
});
teardown(() => {
sandbox.restore();
});
test('WIP', () => {
element.status = 'WIP';
assert.equal(element.$$('.chip').innerText, 'Work in Progress');
assert.isDefined(element.tooltipText);
assert.isTrue(element.classList.contains('wip'));
});
test('merged', () => {
element.status = 'Merged';
assert.equal(element.$$('.chip').innerText, element.status);
assert.isUndefined(element.tooltipText);
assert.isTrue(element.classList.contains('merged'));
});
test('abandoned', () => {
element.status = 'Abandoned';
assert.equal(element.$$('.chip').innerText, element.status);
assert.isUndefined(element.tooltipText);
assert.isTrue(element.classList.contains('abandoned'));
});
test('merge conflict', () => {
element.status = 'Merge Conflict';
assert.equal(element.$$('.chip').innerText, element.status);
assert.isUndefined(element.tooltipText);
assert.isTrue(element.classList.contains('merge-conflict'));
});
test('private', () => {
element.status = 'Private';
assert.equal(element.$$('.chip').innerText, element.status);
assert.isDefined(element.tooltipText);
assert.isTrue(element.classList.contains('private'));
});
test('updating status removes the previous class', () => {
element.status = 'Private';
assert.isTrue(element.classList.contains('private'));
assert.isFalse(element.classList.contains('wip'));
element.status = 'WIP';
assert.isFalse(element.classList.contains('private'));
assert.isTrue(element.classList.contains('wip'));
});
});
</script>