Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
Dave Borowitz | 8cdc76b | 2018-03-26 10:04:27 -0400 | [diff] [blame] | 3 | @license |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 4 | Copyright (C) 2017 The Android Open Source Project |
| 5 | |
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | you may not use this file except in compliance with the License. |
| 8 | You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, software |
| 13 | distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | See the License for the specific language governing permissions and |
| 16 | limitations under the License. |
| 17 | --> |
| 18 | |
| 19 | <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| 20 | <title>gr-change-status</title> |
Ole Rehmsen | 6290935 | 2019-05-16 16:10:33 +0200 | [diff] [blame] | 21 | <script src="/test/common-test-setup.js"></script> |
| 22 | <script src="/bower_components/webcomponentsjs/custom-elements-es5-adapter.js"></script> |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 23 | |
Ole Rehmsen | ecf0b78 | 2019-05-16 11:29:39 +0200 | [diff] [blame] | 24 | <script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script> |
Ole Rehmsen | 3164074 | 2019-05-16 11:24:47 +0200 | [diff] [blame] | 25 | <script src="/bower_components/web-component-tester/browser.js"></script> |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 26 | <link rel="import" href="../../../test/common-test-setup.html"/> |
| 27 | <link rel="import" href="gr-change-status.html"> |
| 28 | |
| 29 | <script>void(0);</script> |
| 30 | |
| 31 | <test-fixture id="basic"> |
| 32 | <template> |
| 33 | <gr-change-status></gr-change-status> |
| 34 | </template> |
| 35 | </test-fixture> |
| 36 | |
| 37 | <script> |
Dhruv Srivastava | fe186da | 2019-11-12 08:41:10 -0800 | [diff] [blame] | 38 | const WIP_TOOLTIP = 'This change isn\'t ready to be reviewed or submitted. ' + |
| 39 | 'It will not appear on dashboards unless you are CC\'ed or assigned, ' + |
| 40 | 'and email notifications will be silenced until the review is started.'; |
| 41 | |
| 42 | const MERGE_CONFLICT_TOOLTIP = 'This change has merge conflicts. ' + |
| 43 | 'Download the patch and run "git rebase master". ' + |
| 44 | 'Upload a new patchset after resolving all merge conflicts.'; |
| 45 | |
| 46 | const PRIVATE_TOOLTIP = 'This change is only visible to its owner and ' + |
| 47 | 'current reviewers (or anyone with "View Private Changes" permission).'; |
| 48 | |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 49 | suite('gr-change-status tests', () => { |
| 50 | let element; |
| 51 | let sandbox; |
| 52 | |
| 53 | setup(() => { |
| 54 | element = fixture('basic'); |
| 55 | sandbox = sinon.sandbox.create(); |
| 56 | }); |
| 57 | |
| 58 | teardown(() => { |
| 59 | sandbox.restore(); |
| 60 | }); |
| 61 | |
| 62 | test('WIP', () => { |
| 63 | element.status = 'WIP'; |
| 64 | assert.equal(element.$$('.chip').innerText, 'Work in Progress'); |
Dhruv Srivastava | fe186da | 2019-11-12 08:41:10 -0800 | [diff] [blame] | 65 | assert.equal(element.tooltipText, WIP_TOOLTIP); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 66 | assert.isTrue(element.classList.contains('wip')); |
| 67 | }); |
| 68 | |
Kasper Nilsson | e15afc9 | 2018-02-27 14:22:21 -0800 | [diff] [blame] | 69 | test('WIP flat', () => { |
| 70 | element.flat = true; |
| 71 | element.status = 'WIP'; |
| 72 | assert.equal(element.$$('.chip').innerText, 'WIP'); |
| 73 | assert.isDefined(element.tooltipText); |
| 74 | assert.isTrue(element.classList.contains('wip')); |
| 75 | assert.isTrue(element.hasAttribute('flat')); |
| 76 | }); |
| 77 | |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 78 | test('merged', () => { |
| 79 | element.status = 'Merged'; |
| 80 | assert.equal(element.$$('.chip').innerText, element.status); |
Becky Siegel | 97de738 | 2018-01-26 14:56:43 -0800 | [diff] [blame] | 81 | assert.equal(element.tooltipText, ''); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 82 | assert.isTrue(element.classList.contains('merged')); |
| 83 | }); |
| 84 | |
| 85 | test('abandoned', () => { |
| 86 | element.status = 'Abandoned'; |
| 87 | assert.equal(element.$$('.chip').innerText, element.status); |
Becky Siegel | 97de738 | 2018-01-26 14:56:43 -0800 | [diff] [blame] | 88 | assert.equal(element.tooltipText, ''); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 89 | assert.isTrue(element.classList.contains('abandoned')); |
| 90 | }); |
| 91 | |
| 92 | test('merge conflict', () => { |
| 93 | element.status = 'Merge Conflict'; |
| 94 | assert.equal(element.$$('.chip').innerText, element.status); |
Dhruv Srivastava | fe186da | 2019-11-12 08:41:10 -0800 | [diff] [blame] | 95 | assert.equal(element.tooltipText, MERGE_CONFLICT_TOOLTIP); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 96 | assert.isTrue(element.classList.contains('merge-conflict')); |
| 97 | }); |
| 98 | |
| 99 | test('private', () => { |
| 100 | element.status = 'Private'; |
| 101 | assert.equal(element.$$('.chip').innerText, element.status); |
Dhruv Srivastava | fe186da | 2019-11-12 08:41:10 -0800 | [diff] [blame] | 102 | assert.equal(element.tooltipText, PRIVATE_TOOLTIP); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 103 | assert.isTrue(element.classList.contains('private')); |
| 104 | }); |
Wyatt Allen | f3c7bf1 | 2017-10-27 13:15:11 -0700 | [diff] [blame] | 105 | |
Becky Siegel | 020e1be | 2017-12-22 12:57:11 -0800 | [diff] [blame] | 106 | test('active', () => { |
| 107 | element.status = 'Active'; |
| 108 | assert.equal(element.$$('.chip').innerText, element.status); |
Becky Siegel | 97de738 | 2018-01-26 14:56:43 -0800 | [diff] [blame] | 109 | assert.equal(element.tooltipText, ''); |
Becky Siegel | 020e1be | 2017-12-22 12:57:11 -0800 | [diff] [blame] | 110 | assert.isTrue(element.classList.contains('active')); |
| 111 | }); |
| 112 | |
| 113 | test('ready to submit', () => { |
| 114 | element.status = 'Ready to submit'; |
| 115 | assert.equal(element.$$('.chip').innerText, element.status); |
Becky Siegel | 97de738 | 2018-01-26 14:56:43 -0800 | [diff] [blame] | 116 | assert.equal(element.tooltipText, ''); |
Becky Siegel | 020e1be | 2017-12-22 12:57:11 -0800 | [diff] [blame] | 117 | assert.isTrue(element.classList.contains('ready-to-submit')); |
| 118 | }); |
| 119 | |
Wyatt Allen | f3c7bf1 | 2017-10-27 13:15:11 -0700 | [diff] [blame] | 120 | test('updating status removes the previous class', () => { |
| 121 | element.status = 'Private'; |
| 122 | assert.isTrue(element.classList.contains('private')); |
| 123 | assert.isFalse(element.classList.contains('wip')); |
| 124 | |
| 125 | element.status = 'WIP'; |
| 126 | assert.isFalse(element.classList.contains('private')); |
| 127 | assert.isTrue(element.classList.contains('wip')); |
| 128 | }); |
Becky Siegel | 53a184a | 2017-10-24 17:23:42 -0700 | [diff] [blame] | 129 | }); |
| 130 | </script> |