From 78b68f6ea2d06424afc8e8f1da0f9831b487bdbf Mon Sep 17 00:00:00 2001 From: Shane Ardell Date: Mon, 4 Nov 2024 18:55:15 -0600 Subject: [PATCH] NIFI-13951: add warn policy to dropdown selection (#9478) --- .../edit-flow-analysis-rule.component.spec.ts | 15 +++++++++++++++ .../edit-flow-analysis-rule.component.ts | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.spec.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.spec.ts index 044cf7f349..784a5b2fdc 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.spec.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.spec.ts @@ -16,6 +16,8 @@ */ 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 { 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 { MockComponent } from 'ng-mocks'; import { ContextErrorBanner } from '../../../../../ui/common/context-error-banner/context-error-banner.component'; +import { HarnessLoader } from '@angular/cdk/testing'; describe('EditFlowAnalysisRule', () => { let component: EditFlowAnalysisRule; let fixture: ComponentFixture; + let loader: HarnessLoader; const data: EditFlowAnalysisRuleDialogRequest = { id: 'd5142be7-018c-1000-7105-2b1163fe0355', @@ -110,10 +114,21 @@ describe('EditFlowAnalysisRule', () => { }); fixture = TestBed.createComponent(EditFlowAnalysisRule); component = fixture.componentInstance; + loader = TestbedHarnessEnvironment.loader(fixture); fixture.detectChanges(); }); it('should create', () => { 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'); + }); + }); + }); + }); }); diff --git a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.ts b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.ts index fa5d8da2fb..fb63dd2957 100644 --- a/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.ts +++ b/nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/settings/ui/flow-analysis-rules/edit-flow-analysis-rule/edit-flow-analysis-rule.component.ts @@ -92,6 +92,11 @@ export class EditFlowAnalysisRule extends TabbedDialog { text: 'Enforce', value: 'ENFORCE', 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({ name: new FormControl(request.flowAnalysisRule.component.name, 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 }), comments: new FormControl(request.flowAnalysisRule.component.comments) });