Skip to content

Commit

Permalink
fixup! fix(gv-policy-studio): allow to reset condition
Browse files Browse the repository at this point in the history
  • Loading branch information
gcusnieux committed Jun 22, 2021
1 parent e2d03d7 commit edc6965
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/policy-studio/gv-policy-studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,8 @@ 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;
}
const _values = Object.assign({}, this._createFlowFromSchema(), values);
const selectedFlowUpdated = Object.assign({}, selectedFlow, _values);
if (!deepEqual(selectedFlow, selectedFlowUpdated)) {
Object.assign(selectedFlow, selectedFlowUpdated, { _dirty: true });
this.isDirty = true;
Expand Down Expand Up @@ -1230,6 +1228,8 @@ export class GvPolicyStudio extends KeyboardElement(LitElement) {
}
if (entry.default !== undefined) {
property[key] = entry.default;
} else if (entry.type === 'string') {
property[key] = '';
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions stories/policy-studio/gv-policy-studio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import definition from '../resources/apim-definition.json';
import policies from '../resources/apim-policies.json';
import resourceTypes from '../resources/apim-resource-types.json';
import '../../src/policy-studio/gv-policy-studio';
import apimFlowSchema from '../resources/schemas/apim-flow.json';

describe('P O L I C Y S T U D I O', () => {
let page, component;
Expand Down Expand Up @@ -371,7 +372,9 @@ describe('P O L I C Y S T U D I O', () => {
}
});

test('should reset condition', async () => {
test('should reset field', async () => {
component.flowSchema = apimFlowSchema;

const _id = 'foobar';
const _stepId = 'foobar-step';
const step = { _id: _stepId, name: 'step', description: 'step description', configuration: {}, policy: 'api-key' };
Expand All @@ -385,7 +388,6 @@ describe('P O L I C Y S T U D I O', () => {
};
const values = {
_id,
name: 'Updated flow',
description: 'test',
pre: [step],
post: [],
Expand All @@ -398,7 +400,8 @@ describe('P O L I C Y S T U D I O', () => {

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

0 comments on commit edc6965

Please sign in to comment.