Skip to content

Commit

Permalink
fix(gv-policy-studio): allow to reset condition
Browse files Browse the repository at this point in the history
Fixes #388
  • Loading branch information
leleueri committed Jun 22, 2021
1 parent e63174e commit e2d03d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/policy-studio/gv-policy-studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,9 @@ export class GvPolicyStudio extends KeyboardElement(LitElement) {
_onSubmitFlow({ detail: { values } }) {
const selectedFlow = this.getSelectedFlow();
const selectedFlowUpdated = Object.assign({}, selectedFlow, values);
if (!values.condition) {
selectedFlowUpdated.condition = null;
}
if (!deepEqual(selectedFlow, selectedFlowUpdated)) {
Object.assign(selectedFlow, selectedFlowUpdated, { _dirty: true });
this.isDirty = true;
Expand Down
30 changes: 30 additions & 0 deletions stories/policy-studio/gv-policy-studio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,35 @@ describe('P O L I C Y S T U D I O', () => {
]);
}
});

test('should reset condition', async () => {
const _id = 'foobar';
const _stepId = 'foobar-step';
const step = { _id: _stepId, name: 'step', description: 'step description', configuration: {}, policy: 'api-key' };
const flow = {
_id,
name: 'New flow',
description: 'test',
condition: '#method == "POST"',
pre: [step],
post: [],
};
const values = {
_id,
name: 'Updated flow',
description: 'test',
pre: [step],
post: [],
};
component.definition = { flows: [flow] };
await component._onSelectFlows({ detail: { flows: [flow._id] } });

// execute update
await component._onSubmitFlow({ detail: { values } });

expect(component.definition.flows.length).toEqual(1);
expect(component.definition.flows[0]._id).toEqual(_id);
expect(component.definition.flows[0].condition).toBeNull();
});
});
});

0 comments on commit e2d03d7

Please sign in to comment.