blob: 7ed57c7343df982fa0043a6f0e0a696ebf6cbbb1 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2022 The Chromium Authors
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +02002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6import {MrMigratedBanner} from './mr-migrated-banner.js';
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +02007import {migratedTypes} from 'shared/issue-fields.js';
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +02008
9let element;
10
11describe('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ínez9f9ade52022-10-10 23:20:11 +020038 it('shows element when migratedId and migratedType is set', async () => {
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020039 element.migratedId = '1234';
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +020040 element.migratedType = migratedTypes.BUGANIZER_TYPE
Adrià Vilanova Martínezde942802022-07-15 14:06:55 +020041 await element.updateComplete;
42
43 assert.isFalse(element.hasAttribute('hidden'));
44 });
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +020045
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ínezf19ea432024-01-23 20:20:52 +010063});