Github user tiborm commented on a diff in the pull request: https://github.com/apache/metron/pull/1142#discussion_r208695454 --- Diff: metron-interface/metron-alerts/src/app/pcap/pcap-filters/pcap-filters.component.spec.ts --- @@ -331,13 +337,60 @@ describe('PcapFiltersComponent', () => { validValues.forEach((value) => { const els = getFieldWithSubmit('ip-dest-port'); + expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value); + expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value); + + setFieldValue(els.field, value); + expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value); expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled with ' + value); + tearDown(els.field); + }); + }); + + + it('should disable the form if the ip source field is invalid', () => { + const invalidValues = [ + 'tst', + 0o0, + 0, + '111.111.111', + '222.222.222.222.222', + '333.333.333.333', + ]; + + invalidValues.forEach((value) => { + const els = getFieldWithSubmit('ip-src-addr'); + expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid without ' + value); + expect(isSubmitDisabled(els.submit)).toBe(false, 'the submit button should be enabled without ' + value); + setFieldValue(els.field, value); - expect(isFieldInvalid(els.field)).toBe(false, 'the field should be valid with ' + value); + + expect(isFieldInvalid(els.field)).toBe(true, 'the field should be invalid with ' + value); + expect(isSubmitDisabled(els.submit)).toBe(true, 'the submit button should be disabled with ' + value); + tearDown(els.field); + }); + }); + + it('should keep the form enabled if the ip source field is valid', () => { + const invalidValues = [ --- End diff -- Fixed. Thanks!
---