Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {assert} from 'chai'; |
| 6 | import {MrMigratedBanner} from './mr-migrated-banner.js'; |
Adrià Vilanova Martínez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame] | 7 | import {migratedTypes} from 'shared/issue-fields.js'; |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 8 | |
| 9 | let element; |
| 10 | |
| 11 | describe('mr-migrated-banner', () => { |
| 12 | beforeEach(() => { |
| 13 | element = document.createElement('mr-migrated-banner'); |
| 14 | document.body.appendChild(element); |
| 15 | }); |
| 16 | |
| 17 | afterEach(() => { |
| 18 | document.body.removeChild(element); |
| 19 | }); |
| 20 | |
| 21 | it('initializes', () => { |
| 22 | assert.instanceOf(element, MrMigratedBanner); |
| 23 | }); |
| 24 | |
| 25 | it('hides element by default', async () => { |
| 26 | await element.updateComplete; |
| 27 | |
| 28 | assert.isTrue(element.hasAttribute('hidden')); |
| 29 | }); |
| 30 | |
| 31 | it('hides element when migratedId is empty', async () => { |
| 32 | element.migratedId = ''; |
| 33 | await element.updateComplete; |
| 34 | |
| 35 | assert.isTrue(element.hasAttribute('hidden')); |
| 36 | }); |
| 37 | |
Adrià Vilanova Martínez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame] | 38 | it('shows element when migratedId and migratedType is set', async () => { |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 39 | element.migratedId = '1234'; |
Adrià Vilanova Martínez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame] | 40 | element.migratedType = migratedTypes.BUGANIZER_TYPE |
Adrià Vilanova Martínez | de94280 | 2022-07-15 14:06:55 +0200 | [diff] [blame] | 41 | await element.updateComplete; |
| 42 | |
| 43 | assert.isFalse(element.hasAttribute('hidden')); |
| 44 | }); |
Adrià Vilanova Martínez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame] | 45 | |
| 46 | it('shows bugnizer link when migrate to bugnizer', async () => { |
| 47 | element.migratedId = '1234'; |
| 48 | element.migratedType = migratedTypes.BUGANIZER_TYPE |
| 49 | await element.updateComplete; |
| 50 | |
| 51 | const link = element.shadowRoot.querySelector('a'); |
| 52 | assert.include(link.textContent, 'b/1234'); |
| 53 | }); |
| 54 | |
| 55 | it('shows launch link when migrate to launch', async () => { |
| 56 | element.migratedId = '1234'; |
| 57 | element.migratedType = migratedTypes.LAUNCH_TYPE |
| 58 | await element.updateComplete; |
| 59 | |
| 60 | const link = element.shadowRoot.querySelector('p'); |
| 61 | assert.include(link.textContent, 'This issue has been migrated to Launch, see link in final comment below'); |
| 62 | }); |
Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 63 | }); |