Skip to content

Commit e5a0b02

Browse files
authored
Automtically expand stages that have reviews in progress. (#4671)
1 parent f5cd015 commit e5a0b02

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

client-src/elements/chromedash-feature-detail.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ import {GateDict} from './chromedash-gate-chip';
3636
import {Process, ProgressItem} from './chromedash-gate-column';
3737
import {
3838
DEPRECATED_FIELDS,
39+
GATE_ACTIVE_REVIEW_STATES,
40+
GATE_FINISHED_REVIEW_STATES,
41+
GATE_PREPARING,
3942
GATE_TEAM_ORDER,
4043
GATE_TYPES,
4144
STAGE_PSA_SHIPPING,
@@ -74,7 +77,7 @@ export const DETAILS_STYLES = [
7477

7578
const LONG_TEXT = 60;
7679

77-
class ChromedashFeatureDetail extends LitElement {
80+
export class ChromedashFeatureDetail extends LitElement {
7881
@property({type: String})
7982
appTitle = '';
8083
@property({attribute: false})
@@ -522,6 +525,19 @@ class ChromedashFeatureDetail extends LitElement {
522525
`;
523526
}
524527

528+
hasActiveGates(feStage) {
529+
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
530+
return gatesForStage.some(g => GATE_ACTIVE_REVIEW_STATES.includes(g.state));
531+
}
532+
533+
hasMixedGates(feStage) {
534+
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
535+
return (
536+
gatesForStage.some(g => GATE_FINISHED_REVIEW_STATES.includes(g.state)) &&
537+
gatesForStage.some(g => GATE_PREPARING == g.state)
538+
);
539+
}
540+
525541
renderGateChips(feStage) {
526542
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
527543
gatesForStage.sort(
@@ -646,7 +662,10 @@ class ChromedashFeatureDetail extends LitElement {
646662
</section>
647663
`;
648664
const defaultOpen =
649-
this.feature.is_enterprise_feature || feStage.id == this.openStage;
665+
this.feature.is_enterprise_feature ||
666+
feStage.id == this.openStage ||
667+
this.hasActiveGates(feStage) ||
668+
this.hasMixedGates(feStage);
650669
return this.renderSection(name, content, isActive, defaultOpen);
651670
}
652671

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import {assert, fixture} from '@open-wc/testing';
2+
import {html} from 'lit';
3+
import {ChromedashFeatureDetail} from './chromedash-feature-detail';
4+
import {
5+
GATE_PREPARING,
6+
GATE_REVIEW_REQUESTED,
7+
VOTE_OPTIONS,
8+
} from './form-field-enums';
9+
10+
describe('chromedash-feature-detail', () => {
11+
const stageNoGates = {id: 1};
12+
const stagePreparing = {id: 2};
13+
const stageActive = {id: 3};
14+
const stageMixed = {id: 4};
15+
const stageResolved = {id: 5};
16+
17+
const gates = [
18+
{stage_id: stagePreparing.id, state: GATE_PREPARING},
19+
{stage_id: stageActive.id, state: GATE_PREPARING},
20+
{stage_id: stageActive.id, state: GATE_REVIEW_REQUESTED},
21+
{stage_id: stageMixed.id, state: GATE_PREPARING},
22+
{stage_id: stageMixed.id, state: VOTE_OPTIONS.APPROVED[0]},
23+
{stage_id: stageResolved.id, state: VOTE_OPTIONS.APPROVED[0]},
24+
];
25+
26+
const feature = {
27+
id: 123456789,
28+
is_enterprise_feature: false,
29+
stages: [],
30+
};
31+
32+
it('renders with mimial data', async () => {
33+
const component = await fixture(
34+
html`<chromedash-feature-detail
35+
.feature=${feature}
36+
></chromedash-feature-detail>`
37+
);
38+
assert.exists(component);
39+
assert.instanceOf(component, ChromedashFeatureDetail);
40+
});
41+
42+
it('can identify active gates', async () => {
43+
const component: ChromedashFeatureDetail = (await fixture(
44+
html`<chromedash-feature-detail
45+
.feature=${feature}
46+
.gates=${gates}
47+
></chromedash-feature-detail>`
48+
)) as ChromedashFeatureDetail;
49+
assert.isFalse(component.hasActiveGates(stageNoGates));
50+
assert.isFalse(component.hasActiveGates(stagePreparing));
51+
assert.isTrue(component.hasActiveGates(stageActive));
52+
assert.isFalse(component.hasActiveGates(stageMixed));
53+
assert.isFalse(component.hasActiveGates(stageResolved));
54+
});
55+
56+
it('can identify mixed gates', async () => {
57+
const component: ChromedashFeatureDetail = (await fixture(
58+
html`<chromedash-feature-detail
59+
.feature=${feature}
60+
.gates=${gates}
61+
></chromedash-feature-detail>`
62+
)) as ChromedashFeatureDetail;
63+
assert.isFalse(component.hasMixedGates(stageNoGates));
64+
assert.isFalse(component.hasMixedGates(stagePreparing));
65+
assert.isFalse(component.hasMixedGates(stageActive));
66+
assert.isTrue(component.hasMixedGates(stageMixed));
67+
assert.isFalse(component.hasMixedGates(stageResolved));
68+
});
69+
});

0 commit comments

Comments
 (0)