Skip to content

Commit

Permalink
Automtically expand stages that have reviews in progress. (#4671)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobbins authored Jan 7, 2025
1 parent f5cd015 commit e5a0b02
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 2 deletions.
23 changes: 21 additions & 2 deletions client-src/elements/chromedash-feature-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import {GateDict} from './chromedash-gate-chip';
import {Process, ProgressItem} from './chromedash-gate-column';
import {
DEPRECATED_FIELDS,
GATE_ACTIVE_REVIEW_STATES,
GATE_FINISHED_REVIEW_STATES,
GATE_PREPARING,
GATE_TEAM_ORDER,
GATE_TYPES,
STAGE_PSA_SHIPPING,
Expand Down Expand Up @@ -74,7 +77,7 @@ export const DETAILS_STYLES = [

const LONG_TEXT = 60;

class ChromedashFeatureDetail extends LitElement {
export class ChromedashFeatureDetail extends LitElement {
@property({type: String})
appTitle = '';
@property({attribute: false})
Expand Down Expand Up @@ -522,6 +525,19 @@ class ChromedashFeatureDetail extends LitElement {
`;
}

hasActiveGates(feStage) {
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
return gatesForStage.some(g => GATE_ACTIVE_REVIEW_STATES.includes(g.state));
}

hasMixedGates(feStage) {
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
return (
gatesForStage.some(g => GATE_FINISHED_REVIEW_STATES.includes(g.state)) &&
gatesForStage.some(g => GATE_PREPARING == g.state)
);
}

renderGateChips(feStage) {
const gatesForStage = this.gates.filter(g => g.stage_id == feStage.id);
gatesForStage.sort(
Expand Down Expand Up @@ -646,7 +662,10 @@ class ChromedashFeatureDetail extends LitElement {
</section>
`;
const defaultOpen =
this.feature.is_enterprise_feature || feStage.id == this.openStage;
this.feature.is_enterprise_feature ||
feStage.id == this.openStage ||
this.hasActiveGates(feStage) ||
this.hasMixedGates(feStage);
return this.renderSection(name, content, isActive, defaultOpen);
}

Expand Down
69 changes: 69 additions & 0 deletions client-src/elements/chromedash-feature-detail_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {assert, fixture} from '@open-wc/testing';
import {html} from 'lit';
import {ChromedashFeatureDetail} from './chromedash-feature-detail';
import {
GATE_PREPARING,
GATE_REVIEW_REQUESTED,
VOTE_OPTIONS,
} from './form-field-enums';

describe('chromedash-feature-detail', () => {
const stageNoGates = {id: 1};
const stagePreparing = {id: 2};
const stageActive = {id: 3};
const stageMixed = {id: 4};
const stageResolved = {id: 5};

const gates = [
{stage_id: stagePreparing.id, state: GATE_PREPARING},
{stage_id: stageActive.id, state: GATE_PREPARING},
{stage_id: stageActive.id, state: GATE_REVIEW_REQUESTED},
{stage_id: stageMixed.id, state: GATE_PREPARING},
{stage_id: stageMixed.id, state: VOTE_OPTIONS.APPROVED[0]},
{stage_id: stageResolved.id, state: VOTE_OPTIONS.APPROVED[0]},
];

const feature = {
id: 123456789,
is_enterprise_feature: false,
stages: [],
};

it('renders with mimial data', async () => {
const component = await fixture(
html`<chromedash-feature-detail
.feature=${feature}
></chromedash-feature-detail>`
);
assert.exists(component);
assert.instanceOf(component, ChromedashFeatureDetail);
});

it('can identify active gates', async () => {
const component: ChromedashFeatureDetail = (await fixture(
html`<chromedash-feature-detail
.feature=${feature}
.gates=${gates}
></chromedash-feature-detail>`
)) as ChromedashFeatureDetail;
assert.isFalse(component.hasActiveGates(stageNoGates));
assert.isFalse(component.hasActiveGates(stagePreparing));
assert.isTrue(component.hasActiveGates(stageActive));
assert.isFalse(component.hasActiveGates(stageMixed));
assert.isFalse(component.hasActiveGates(stageResolved));
});

it('can identify mixed gates', async () => {
const component: ChromedashFeatureDetail = (await fixture(
html`<chromedash-feature-detail
.feature=${feature}
.gates=${gates}
></chromedash-feature-detail>`
)) as ChromedashFeatureDetail;
assert.isFalse(component.hasMixedGates(stageNoGates));
assert.isFalse(component.hasMixedGates(stagePreparing));
assert.isFalse(component.hasMixedGates(stageActive));
assert.isTrue(component.hasMixedGates(stageMixed));
assert.isFalse(component.hasMixedGates(stageResolved));
});
});

0 comments on commit e5a0b02

Please sign in to comment.