NIFI-13951: add warn policy to dropdown selection (#9478)

This commit is contained in:
Shane Ardell 2024-11-04 18:55:15 -06:00 committed by GitHub
parent 103710038a
commit 78b68f6ea2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -16,6 +16,8 @@
*/ */
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatSelectHarness } from '@angular/material/select/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { EditFlowAnalysisRule } from './edit-flow-analysis-rule.component'; import { EditFlowAnalysisRule } from './edit-flow-analysis-rule.component';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
@ -26,10 +28,12 @@ import { ClusterConnectionService } from '../../../../../service/cluster-connect
import 'codemirror/addon/hint/show-hint'; import 'codemirror/addon/hint/show-hint';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { ContextErrorBanner } from '../../../../../ui/common/context-error-banner/context-error-banner.component'; import { ContextErrorBanner } from '../../../../../ui/common/context-error-banner/context-error-banner.component';
import { HarnessLoader } from '@angular/cdk/testing';
describe('EditFlowAnalysisRule', () => { describe('EditFlowAnalysisRule', () => {
let component: EditFlowAnalysisRule; let component: EditFlowAnalysisRule;
let fixture: ComponentFixture<EditFlowAnalysisRule>; let fixture: ComponentFixture<EditFlowAnalysisRule>;
let loader: HarnessLoader;
const data: EditFlowAnalysisRuleDialogRequest = { const data: EditFlowAnalysisRuleDialogRequest = {
id: 'd5142be7-018c-1000-7105-2b1163fe0355', id: 'd5142be7-018c-1000-7105-2b1163fe0355',
@ -110,10 +114,21 @@ describe('EditFlowAnalysisRule', () => {
}); });
fixture = TestBed.createComponent(EditFlowAnalysisRule); fixture = TestBed.createComponent(EditFlowAnalysisRule);
component = fixture.componentInstance; component = fixture.componentInstance;
loader = TestbedHarnessEnvironment.loader(fixture);
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('Settings Tab', () => {
it('should default to selecting enforcementPolicy value passed in as data', () => {
loader.getAllHarnesses(MatSelectHarness).then((selectHarnesses) => {
selectHarnesses[0].getValueText().then((option) => {
expect(option).toBe('Enforce');
});
});
});
});
}); });

View File

@ -92,6 +92,11 @@ export class EditFlowAnalysisRule extends TabbedDialog {
text: 'Enforce', text: 'Enforce',
value: 'ENFORCE', value: 'ENFORCE',
description: 'Treat violations of this rule as errors the correction of which is mandatory.' description: 'Treat violations of this rule as errors the correction of which is mandatory.'
},
{
text: 'Warn',
value: 'WARN',
description: 'Treat violations of this rule as warnings the correction of which is optional.'
} }
]; ];
@ -121,7 +126,10 @@ export class EditFlowAnalysisRule extends TabbedDialog {
this.editFlowAnalysisRuleForm = this.formBuilder.group({ this.editFlowAnalysisRuleForm = this.formBuilder.group({
name: new FormControl(request.flowAnalysisRule.component.name, Validators.required), name: new FormControl(request.flowAnalysisRule.component.name, Validators.required),
state: new FormControl(request.flowAnalysisRule.component.state === 'STOPPED', Validators.required), state: new FormControl(request.flowAnalysisRule.component.state === 'STOPPED', Validators.required),
enforcementPolicy: new FormControl('ENFORCE', Validators.required), enforcementPolicy: new FormControl(
request.flowAnalysisRule.component.enforcementPolicy,
Validators.required
),
properties: new FormControl({ value: properties, disabled: this.readonly }), properties: new FormControl({ value: properties, disabled: this.readonly }),
comments: new FormControl(request.flowAnalysisRule.component.comments) comments: new FormControl(request.flowAnalysisRule.component.comments)
}); });