blob: 063714ece9a8c55171f77710f161b567d8e95277 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2019 The Chromium Authors
Copybara854996b2021-09-07 19:36:02 +00002// 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 {MrRelatedIssues} from './mr-related-issues.js';
7
8
9let element;
10
11describe('mr-related-issues', () => {
12 beforeEach(() => {
13 element = document.createElement('mr-related-issues');
14 document.body.appendChild(element);
15 });
16
17 afterEach(() => {
18 document.body.removeChild(element);
19 });
20
21 it('initializes', () => {
22 assert.instanceOf(element, MrRelatedIssues);
23 });
24
25 it('dialog closes when issueRef changes', async () => {
26 element.issueRef = {projectName: 'chromium', localId: 22};
27 await element.updateComplete;
28
29 const dialog = element.shadowRoot.querySelector('chops-dialog');
30
31 element.open();
32 await element.updateComplete;
33
34 assert.isTrue(dialog.opened);
35
36 element.issueRef = {projectName: 'chromium', localId: 23};
37 await element.updateComplete;
38
39 assert.isFalse(dialog.opened);
40 });
41
42 it('computes blocked on table rows', () => {
43 element.projectName = 'proj';
44 element.sortedBlockedOn = [
45 {projectName: 'proj', localId: 1, statusRef: {meansOpen: true},
46 summary: 'Issue 1'},
47 {projectName: 'proj', localId: 2, statusRef: {meansOpen: true},
48 summary: 'Issue 2'},
49 {projectName: 'proj', localId: 3,
50 summary: 'Issue 3'},
51 {projectName: 'proj2', localId: 4,
52 summary: 'Issue 4 on another project'},
53 {extIdentifier: 'b/123456', statusRef: {meansOpen: true}},
54 {extIdentifier: 'b/987654', statusRef: {meansOpen: false},
55 summary: 'FedRef with a summary'},
56 {projectName: 'proj', localId: 5, statusRef: {meansOpen: false},
57 summary: 'Issue 5'},
58 {projectName: 'proj2', localId: 6, statusRef: {meansOpen: false},
59 summary: 'Issue 6 on another project'},
60 ];
61 assert.deepEqual(element._rows, [
62 {
63 draggable: true,
64 cells: [
65 {
66 type: 'issue',
67 issue: {projectName: 'proj', localId: 1, statusRef: {meansOpen: true},
68 summary: 'Issue 1'},
69 isClosed: false,
70 },
71 {
72 type: 'text',
73 content: 'Issue 1',
74 },
75 ],
76 },
77 {
78 draggable: true,
79 cells: [
80 {
81 type: 'issue',
82 issue: {projectName: 'proj', localId: 2, statusRef: {meansOpen: true},
83 summary: 'Issue 2'},
84 isClosed: false,
85 },
86 {
87 type: 'text',
88 content: 'Issue 2',
89 },
90 ],
91 },
92 {
93 draggable: true,
94 cells: [
95 {
96 type: 'issue',
97 issue: {projectName: 'proj', localId: 3,
98 summary: 'Issue 3'},
99 isClosed: false,
100 },
101 {
102 type: 'text',
103 content: 'Issue 3',
104 },
105 ],
106 },
107 {
108 draggable: true,
109 cells: [
110 {
111 type: 'issue',
112 issue: {projectName: 'proj2', localId: 4,
113 summary: 'Issue 4 on another project'},
114 isClosed: false,
115 },
116 {
117 type: 'text',
118 content: 'Issue 4 on another project',
119 },
120 ],
121 },
122 {
123 draggable: false,
124 cells: [
125 {
126 type: 'issue',
127 issue: {
128 extIdentifier: 'b/123456',
129 statusRef: {meansOpen: true},
130 },
131 isClosed: false,
132 },
133 {
134 type: 'text',
135 content: '(not available)',
136 },
137 ],
138 },
139 {
140 draggable: false,
141 cells: [
142 {
143 type: 'issue',
144 issue: {
145 extIdentifier: 'b/987654',
146 statusRef: {meansOpen: false},
147 summary: 'FedRef with a summary',
148 },
149 isClosed: true,
150 },
151 {
152 type: 'text',
153 content: 'FedRef with a summary',
154 },
155 ],
156 },
157 {
158 draggable: false,
159 cells: [
160 {
161 type: 'issue',
162 issue: {projectName: 'proj', localId: 5,
163 statusRef: {meansOpen: false},
164 summary: 'Issue 5'},
165 isClosed: true,
166 },
167 {
168 type: 'text',
169 content: 'Issue 5',
170 },
171 ],
172 },
173 {
174 draggable: false,
175 cells: [
176 {
177 type: 'issue',
178 issue: {projectName: 'proj2', localId: 6,
179 statusRef: {meansOpen: false},
180 summary: 'Issue 6 on another project'},
181 isClosed: true,
182 },
183 {
184 type: 'text',
185 content: 'Issue 6 on another project',
186 },
187 ],
188 },
189 ]);
190 });
191});