diff --git a/config-editor/config-editor-ui/package.json b/config-editor/config-editor-ui/package.json index 3d448ee4e..7c14c037f 100644 --- a/config-editor/config-editor-ui/package.json +++ b/config-editor/config-editor-ui/package.json @@ -1,6 +1,6 @@ { "name": "rule-editor.ui", - "version": "2.6.6-dev", + "version": "2.6.7-dev", "license": "MIT", "scripts": { "ng": "ng", diff --git a/config-editor/config-editor-ui/src/app/components/editor-view/editor-view.component.ts b/config-editor/config-editor-ui/src/app/components/editor-view/editor-view.component.ts index f690dd1b4..fe683f82c 100644 --- a/config-editor/config-editor-ui/src/app/components/editor-view/editor-view.component.ts +++ b/config-editor/config-editor-ui/src/app/components/editor-view/editor-view.component.ts @@ -75,9 +75,9 @@ export class EditorViewComponent implements OnInit, OnDestroy, AfterViewInit { this.editedConfig$.pipe(takeUntil(this.ngUnsubscribe)).subscribe((config: Config) => { this.configData = config.configData; this.testingEnabled = () => - this.editorService.metaDataMap.testing.perConfigTestEnabled && this.editorComponent.form.valid; + this.editorService.testSpecificationTesters.config_testing.length > 0 && this.editorComponent.form.valid; this.testCaseEnabled = () => - this.editorService.metaDataMap.testing.testCaseEnabled && this.editorComponent.form.valid && !config.isNew; + this.editorService.testSpecificationTesters.test_case_testing.length > 0 && this.editorComponent.form.valid && !config.isNew; }); } diff --git a/config-editor/config-editor-ui/src/app/components/release-dialog/release-dialog.component.ts b/config-editor/config-editor-ui/src/app/components/release-dialog/release-dialog.component.ts index 4c07655cb..5888e3161 100644 --- a/config-editor/config-editor-ui/src/app/components/release-dialog/release-dialog.component.ts +++ b/config-editor/config-editor-ui/src/app/components/release-dialog/release-dialog.component.ts @@ -91,7 +91,7 @@ export class ReleaseDialogComponent implements AfterViewChecked { } }); } - this.testEnabled = this.uiMetadata.testing.releaseTestEnabled; + this.testEnabled = this.service.testSpecificationTesters.release_testing.length > 0; this.environment = this.config.environment; this.service.configStore.initialRelease$.subscribe((d: Release) => { diff --git a/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.html b/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.html index eee87224d..af332886f 100644 --- a/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.html +++ b/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.html @@ -1,4 +1,7 @@ +
+ +

diff --git a/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.ts b/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.ts index 2897a8445..7ddb3db23 100644 --- a/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.ts +++ b/config-editor/config-editor-ui/src/app/components/testing/config-testing/config-testing.component.ts @@ -3,7 +3,7 @@ import { FormGroup } from '@angular/forms'; import { EditorService } from '@app/services/editor.service'; import { FormlyFieldConfig, FormlyFormOptions } from '@ngx-formly/core'; import { FormlyForm } from '@ngx-formly/core'; -import { ConfigTestResult, TestingType } from '../../../model/config-model'; +import { ConfigTestResult, TestingType, TestConfigSpec } from '../../../model/config-model'; import { take } from 'rxjs/operators'; import { FormlyJsonschema } from '@ngx-formly/core/json-schema'; import { SchemaService } from '@app/services/schema/schema.service'; @@ -24,16 +24,43 @@ export class ConfigTestingComponent implements OnInit { public isInvalid = false; public output: any; + private CONFIG_TESTER_KEY = "config_tester"; + configTestersFields: FormlyFieldConfig[] = [ + { + key: this.CONFIG_TESTER_KEY, + type: "enum", + templateOptions: { + label: "Config tester", + hintEnd: "The name of the config tester selected", + change: (field, $event) => { + this.updateConfigTester($event.value); + }, + options: [] + }, + }, + ]; + configTesterModel = {}; + formDropDown: FormGroup = new FormGroup({}); + private testConfigSpec: TestConfigSpec = undefined; + numTesters = 0; + constructor(private editorService: EditorService, private cd: ChangeDetectorRef) {} ngOnInit() { - if (this.editorService.metaDataMap.testing.perConfigTestEnabled) { - let schema = this.editorService.testSpecificationSchema; - this.editorService.configSchema.formatTitlesInSchema(schema, ''); - this.field = new FormlyJsonschema().toFieldConfig(schema, { map: SchemaService.renameDescription }); + this.numTesters = this.editorService.testSpecificationTesters.config_testing.length; + if (this.numTesters > 0) { + this.testConfigSpec = this.editorService.getTestConfig(this.editorService.testSpecificationTesters.config_testing[0]); + this.initSchema(); + this.initDropdown(); } } + initSchema() { + let schema = this.testConfigSpec.test_schema; + this.editorService.configSchema.formatTitlesInSchema(schema, ''); + this.field = new FormlyJsonschema().toFieldConfig(schema, { map: SchemaService.renameDescription }); + } + runTest() { this.editorService.configStore.testService .test(this.form.value, this.testingType) @@ -44,4 +71,26 @@ export class ConfigTestingComponent implements OnInit { this.cd.markForCheck(); }); } + + initDropdown() { + return this.configTestersFields.map(f => { + if (f.key === this.CONFIG_TESTER_KEY) { + f.defaultValue = this.editorService.testSpecificationTesters.config_testing[0]; + f.templateOptions.options = this.editorService.testSpecificationTesters.config_testing.map(testerName => { + return { value: testerName, label: testerName} + }) + } + }) + } + + updateConfigTester(testerName: string) { + const tester = this.editorService.getTestConfig(testerName); + if (tester !== undefined) { + this.testConfigSpec = tester; + if (this.testConfigSpec.config_testing) { + this.initSchema(); + } + } + } + } diff --git a/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.html b/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.html index cec237927..18f445aad 100644 --- a/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.html +++ b/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.html @@ -1,3 +1,6 @@ +
+ +

{{ testCase.test_case_name }} v{{ testCase.version }}

diff --git a/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.ts b/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.ts index 155b136f0..18b51931d 100644 --- a/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.ts +++ b/config-editor/config-editor-ui/src/app/components/testing/test-case-editor/test-case-editor.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit, OnDestroy } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { copyHiddenTestCaseFields, TestCaseWrapper } from '@app/model/test-case'; -import { Type } from '@app/model/config-model'; +import { Type, TestConfigSpec } from '@app/model/config-model'; import { FormlyFieldConfig } from '@ngx-formly/core'; import { cloneDeep } from 'lodash'; import { EditorService } from '@app/services/editor.service'; @@ -33,6 +33,26 @@ export class TestCaseEditorComponent implements OnInit, OnDestroy { testStoreService: TestStoreService; form: FormGroup = new FormGroup({}); private markHistoryChange = false; + private testConfigSpec: TestConfigSpec = undefined; + private TEST_CASE_TESTER_KEY = "test_case_tester"; + testCaseConfigTestersFields: FormlyFieldConfig[] = [ + { + key: this.TEST_CASE_TESTER_KEY, + type: "enum", + templateOptions: { + label: "Test case tester", + hintEnd: "The name of the test case tester selected", + change: (field, $event) => { + this.updateConfigTester($event.value); + }, + options: [] + }, + }, + ]; + testCaseConfigTesterModel = {}; + dropDownForm: FormGroup = new FormGroup({}); + numTesters = 0; + constructor( private appService: AppService, private editorService: EditorService, @@ -45,27 +65,11 @@ export class TestCaseEditorComponent implements OnInit, OnDestroy { } ngOnInit() { - if (this.editorService.metaDataMap.testing.testCaseEnabled) { - const subschema = cloneDeep(this.editorService.testSpecificationSchema); - const schema = cloneDeep(this.appService.testCaseSchema); - schema.properties.test_specification = subschema; - const schemaConverter = new FormlyJsonschema(); - this.editorService.configSchema.formatTitlesInSchema(schema, ''); - this.options = { - resetOnHide: false, - map: SchemaService.renameDescription, - }; - this.field = schemaConverter.toFieldConfig(schema, this.options); - - this.editedTestCase$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(testCaseWrapper => { - this.testCaseWrapper = testCaseWrapper; - if ( - testCaseWrapper && - !this.editorService.configSchema.areTestCasesEqual(testCaseWrapper.testCase, this.testCase) - ) { - this.testCase = cloneDeep(this.testCaseWrapper.testCase); - } - }); + this.numTesters = this.editorService.testSpecificationTesters.test_case_testing.length; + if (this.numTesters > 0) { + this.testConfigSpec = this.editorService.getTestConfig(this.editorService.testSpecificationTesters.test_case_testing[0]); + this.initSchema(); + this.initDropdown(); } this.form.valueChanges.pipe(debounceTime(300), takeUntil(this.ngUnsubscribe)).subscribe(() => { if (this.form.valid && !this.markHistoryChange) { @@ -74,6 +78,28 @@ export class TestCaseEditorComponent implements OnInit, OnDestroy { this.markHistoryChange = false; }); } + initSchema() { + const subschema = cloneDeep(this.testConfigSpec.test_schema); + const schema = cloneDeep(this.appService.testCaseSchema); + schema.properties.test_specification = subschema; + const schemaConverter = new FormlyJsonschema(); + this.editorService.configSchema.formatTitlesInSchema(schema, ''); + this.options = { + resetOnHide: false, + map: SchemaService.renameDescription, + }; + this.field = schemaConverter.toFieldConfig(schema, this.options); + + this.editedTestCase$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(testCaseWrapper => { + this.testCaseWrapper = testCaseWrapper; + if ( + testCaseWrapper && + !this.editorService.configSchema.areTestCasesEqual(testCaseWrapper.testCase, this.testCase) + ) { + this.testCase = cloneDeep(this.testCaseWrapper.testCase); + } + }); + } ngOnDestroy() { this.ngUnsubscribe.next(); @@ -150,4 +176,26 @@ export class TestCaseEditorComponent implements OnInit, OnDestroy { ret.testCase = copyHiddenTestCaseFields(cloneDeep(testCase), this.testCase); return ret; } + + initDropdown() { + return this.testCaseConfigTestersFields.map(f => { + if (f.key === this.TEST_CASE_TESTER_KEY) { + f.defaultValue = this.editorService.testSpecificationTesters.test_case_testing[0]; + f.templateOptions.options = this.editorService.testSpecificationTesters.test_case_testing.map(testerName => { + return { value: testerName, label: testerName} + }) + } + }) + } + + updateConfigTester(testerName: string) { + const tester = this.editorService.getTestConfig(testerName); + if (tester !== undefined) { + this.testConfigSpec = tester; + if (this.testConfigSpec.test_case_testing) { + this.initSchema(); + } + } + } + } diff --git a/config-editor/config-editor-ui/src/app/components/testing/test-centre/test-centre.component.ts b/config-editor/config-editor-ui/src/app/components/testing/test-centre/test-centre.component.ts index 74c2aa4a6..6070e3f08 100644 --- a/config-editor/config-editor-ui/src/app/components/testing/test-centre/test-centre.component.ts +++ b/config-editor/config-editor-ui/src/app/components/testing/test-centre/test-centre.component.ts @@ -40,7 +40,7 @@ export class TestCentreComponent implements OnInit, OnDestroy { } ngOnInit() { - if (this.editorService.metaDataMap.testing.testCaseEnabled) { + if (this.editorService.testSpecificationTesters.test_case_testing.length > 0) { this.testCases$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(testCases => { this.testCases = testCases; }); diff --git a/config-editor/config-editor-ui/src/app/model/config-model.ts b/config-editor/config-editor-ui/src/app/model/config-model.ts index 183cf90b2..e84998a73 100644 --- a/config-editor/config-editor-ui/src/app/model/config-model.ts +++ b/config-editor/config-editor-ui/src/app/model/config-model.ts @@ -291,3 +291,22 @@ export interface ErrorDialog { icon_name: string, icon_color: string, } + +export interface TestConfigSpec { + name: string; + test_schema: JSONSchema7; + config_testing: boolean; + test_case_testing: boolean; + release_testing: boolean; + incomplete_result: boolean; +} + +export interface TestConfigSpecTesters { + config_testers: TestConfigSpec[]; +} + +export interface TestSpecificationTesters { + config_testing: string[]; + test_case_testing: string[]; + release_testing: string[]; +} \ No newline at end of file diff --git a/config-editor/config-editor-ui/src/app/model/store-state.ts b/config-editor/config-editor-ui/src/app/model/store-state.ts index 91d7ec6e3..83b9a5911 100644 --- a/config-editor/config-editor-ui/src/app/model/store-state.ts +++ b/config-editor/config-editor-ui/src/app/model/store-state.ts @@ -1,6 +1,6 @@ import { Config, Release, FileHistory } from '.'; import { TestCaseMap, TestCaseWrapper } from './test-case'; -import { AdminConfig, ConfigManagerRow } from './config-model'; +import { AdminConfig, ConfigManagerRow, TestSpecificationTesters } from './config-model'; import { FilterConfig } from './ui-metadata-map'; export interface ConfigStoreState { @@ -22,4 +22,5 @@ export interface ConfigStoreState { isAnyFilterPresent: boolean; user: string; serviceFilterConfig: FilterConfig; + testSpecificationTesters: TestSpecificationTesters; } diff --git a/config-editor/config-editor-ui/src/app/services/config-loader.service.ts b/config-editor/config-editor-ui/src/app/services/config-loader.service.ts index 49e92a600..6266543b3 100644 --- a/config-editor/config-editor-ui/src/app/services/config-loader.service.ts +++ b/config-editor/config-editor-ui/src/app/services/config-loader.service.ts @@ -11,7 +11,8 @@ import { GitFiles, PullRequestInfo, SchemaInfo, - TestSchemaInfo, + TestConfigSpecTesters, + TestConfigSpec, AdminSchemaInfo, AdminConfig, AdminConfigGitFiles, @@ -79,10 +80,10 @@ export class ConfigLoaderService { })); } - getTestSpecificationSchema(): Observable { + getConfigTesters(): Observable { return this.http - .get(`${this.config.serviceRoot}api/v1/${this.serviceName}/configs/testschema`) - .pipe(map(x => x.test_schema)); + .get(`${this.config.serviceRoot}api/v1/${this.serviceName}/configs/testers`) + .pipe(map(result => result.config_testers)); } getSchema(): Observable { @@ -367,14 +368,14 @@ export class ConfigLoaderService { .pipe(map(x => x.test_case_result)); } - deleteConfig(configName: string): Observable { + deleteConfig(configName: string, testCaseIsEnabled: boolean): Observable { return this.http .post>( `${this.config.serviceRoot}api/v1/${this.serviceName}/configstore/configs/delete?configName=${configName}`, null ) - .pipe(map(result => { - if (!result.configs_files || (!result.test_cases_files && this.uiMetadata.testing.testCaseEnabled)) { + .pipe(map(result => { + if (!result.configs_files || (!result.test_cases_files && testCaseIsEnabled)) { throw new DOMException('bad format response when deleting config'); } const configAndTestCases = { diff --git a/config-editor/config-editor-ui/src/app/services/editor.service.ts b/config-editor/config-editor-ui/src/app/services/editor.service.ts index f9affc198..9d7ff4dc0 100644 --- a/config-editor/config-editor-ui/src/app/services/editor.service.ts +++ b/config-editor/config-editor-ui/src/app/services/editor.service.ts @@ -10,7 +10,7 @@ import { AppService } from './app.service'; import { mergeMap, map } from 'rxjs/operators'; import { ConfigSchemaService } from './schema/config-schema-service'; import { AdminSchemaService } from './schema/admin-schema.service'; -import { CheckboxEvent, FILTER_PARAM_KEY, ServiceSearch } from '@app/model/config-model'; +import { CheckboxEvent, FILTER_PARAM_KEY, ServiceSearch, TestConfigSpec, TestSpecificationTesters } from '@app/model/config-model'; import { SearchHistoryService } from './search-history.service'; import { ParamMap } from '@angular/router'; @@ -21,9 +21,10 @@ export class ServiceContext { adminSchema?: AdminSchemaService; configStore: ConfigStoreService; serviceName: string; - testSpecificationSchema?: JSONSchema7; adminMode: boolean; searchHistoryService?: SearchHistoryService; + testConfigSpec?: TestConfigSpec[]; + testSpecificationTesters?: TestSpecificationTesters; } @Injectable({ @@ -56,13 +57,15 @@ export class EditorService { get adminMode() { return this.serviceContext.adminMode; } - get testSpecificationSchema() { - return this.serviceContext.testSpecificationSchema; - } - get searchHistoryService() { return this.serviceContext.searchHistoryService; } + get testConfigSpec() { + return this.serviceContext.testConfigSpec; + } + get testSpecificationTesters() { + return this.serviceContext.testSpecificationTesters; + } constructor( private http: HttpClient, @@ -78,28 +81,24 @@ export class EditorService { } createConfigServiceContext(serviceName: string): Observable { - const [metaDataMap, user, configLoader, configStore] = this.initialiseContext(serviceName); - const testSpecificationFun = metaDataMap.testing.perConfigTestEnabled - ? configLoader.getTestSpecificationSchema() - : of({}); - const testCaseMapFun = metaDataMap.testing.testCaseEnabled ? configLoader.getTestCases() : of({}); + const [metaDataMap, user, configLoader, configStore] = this.initialiseContext(serviceName); - return configLoader - .getSchema() - .pipe( - mergeMap(schema => - forkJoin( - configLoader.getConfigs(), - configLoader.getRelease(), - of(schema), - testCaseMapFun, - testSpecificationFun - ) + return forkJoin(configLoader.getSchema(), configLoader.getConfigTesters()) + .pipe(mergeMap(([schema, testConfig]) => { + let testers: TestSpecificationTesters = this.getTestersPerType(testConfig); + return forkJoin( + configLoader.getConfigs(), + configLoader.getRelease(), + of(schema), + of(testConfig), + testers.config_testing.length > 0 ? configLoader.getTestCases() : of({}), + of(testers) ) - ) - .pipe(map(([configs, release, originalSchema, testCaseMap, testSpecSchema]) => { - if (configs && release && originalSchema && testCaseMap && testSpecSchema) { - configStore.initialise(configs, release, testCaseMap, user, metaDataMap); + })) + .pipe(map(([configs, release, originalSchema, testSpec, testCaseMap, testersType]) => { + if (configs && release && originalSchema && testSpec && testCaseMap && testersType) { + + configStore.initialise(configs, release, testCaseMap, user, metaDataMap, testersType); return { adminMode: false, configLoader, @@ -107,7 +106,8 @@ export class EditorService { configStore, metaDataMap, serviceName, - testSpecificationSchema: testSpecSchema, + testConfigSpec: testSpec, + testSpecificationTesters: testersType, searchHistoryService: new SearchHistoryService(this.config, serviceName), }; } @@ -151,6 +151,26 @@ export class EditorService { return filters; } + getTestConfig(name: string): TestConfigSpec { + return this.testConfigSpec.find(x => x.name === name); + } + + getTestersPerType(testConfig: TestConfigSpec[]): TestSpecificationTesters { + let testers: TestSpecificationTesters = {config_testing: [], test_case_testing: [], release_testing: []}; + testConfig.forEach((tester: TestConfigSpec) => { + if (tester.config_testing) { + testers.config_testing.push(tester.name); + } + if (tester.test_case_testing) { + testers.test_case_testing.push(tester.name); + } + if (tester.release_testing) { + testers.release_testing.push(tester.name); + } + }); + return testers; + } + onSaveSearch(currentParams: ParamMap): ServiceSearch[] { return this.serviceContext.searchHistoryService.addToSearchHistory(currentParams); } diff --git a/config-editor/config-editor-ui/src/app/services/store/config-store-state.builder.ts b/config-editor/config-editor-ui/src/app/services/store/config-store-state.builder.ts index 71a53ef85..a1afdb6be 100644 --- a/config-editor/config-editor-ui/src/app/services/store/config-store-state.builder.ts +++ b/config-editor/config-editor-ui/src/app/services/store/config-store-state.builder.ts @@ -4,7 +4,7 @@ import { moveItemInArray } from '@angular/cdk/drag-drop'; import { Config, Release, FileHistory } from '../../model'; import { TestCaseMap } from '@app/model/test-case'; import { TestCaseWrapper, TestCaseResult } from '../../model/test-case'; -import { AdminConfig, ConfigManagerRow, ConfigStatus, FILTER_DELIMITER } from '@app/model/config-model'; +import { AdminConfig, ConfigManagerRow, ConfigStatus, FILTER_DELIMITER, TestSpecificationTesters } from '@app/model/config-model'; import { FilterConfig, UiMetadata } from '@app/model/ui-metadata-map'; export class ConfigStoreStateBuilder { @@ -287,4 +287,9 @@ export class ConfigStoreStateBuilder { }, } } + + updateConfigTesters(testers: TestSpecificationTesters) { + this.state.testSpecificationTesters = testers; + return this; + } } diff --git a/config-editor/config-editor-ui/src/app/services/store/config-store.service.ts b/config-editor/config-editor-ui/src/app/services/store/config-store.service.ts index 171798e87..470bd55df 100644 --- a/config-editor/config-editor-ui/src/app/services/store/config-store.service.ts +++ b/config-editor/config-editor-ui/src/app/services/store/config-store.service.ts @@ -7,7 +7,7 @@ import { UiMetadata } from '../../model/ui-metadata-map'; import { ConfigLoaderService } from '../config-loader.service'; import { ConfigStoreStateBuilder } from './config-store-state.builder'; import { TestStoreService } from './test-store.service'; -import { AdminConfig, ConfigAndTestsToClone, ConfigToImport, ExistingConfigError, FILTER_PARAM_KEY, Importers, SEARCH_PARAM_KEY, Type } from '@app/model/config-model'; +import { AdminConfig, ConfigAndTestsToClone, ConfigToImport, ExistingConfigError, FILTER_PARAM_KEY, Importers, SEARCH_PARAM_KEY, Type, TestSpecificationTesters } from '@app/model/config-model'; import { ClipboardStoreService } from '../clipboard-store.service'; import { ConfigHistoryService } from '../config-history.service'; import { AppConfigService } from '../app-config.service'; @@ -33,6 +33,7 @@ const initialConfigStoreState: ConfigStoreState = { isAnyFilterPresent: false, serviceFilterConfig: undefined, user: undefined, + testSpecificationTesters: undefined, }; const initialPullRequestState: PullRequestInfo = { @@ -71,6 +72,7 @@ export class ConfigStoreService { public readonly isAnyFilterPresent$ = this.store.asObservable().pipe(map(x => x.isAnyFilterPresent)); public readonly serviceFilterConfig$ = this.store.asObservable().pipe(map(x => x.serviceFilterConfig)); public readonly serviceFilters$ = this.store.asObservable().pipe(map(x => x.serviceFilters)); + public readonly testSpecificationTesters$ = this.store.asObservable().pipe(map(x => x.testSpecificationTesters)); /*eslint-enable */ @@ -108,7 +110,8 @@ export class ConfigStoreService { release: any, testCaseMap: TestCaseMap, user: string, - uiMetadata: UiMetadata + uiMetadata: UiMetadata, + testers?: TestSpecificationTesters ) { const newState = new ConfigStoreStateBuilder(this.store.getValue()) .user(user) @@ -122,6 +125,7 @@ export class ConfigStoreService { .detectOutdatedConfigs() .reorderConfigsByRelease() .computeConfigManagerRowData() + .updateConfigTesters(testers) .build(); this.store.next(newState); @@ -225,7 +229,7 @@ export class ConfigStoreService { } reloadStoreAndRelease(): Observable { - const testCaseMapFun = this.metaDataMap.testing.testCaseEnabled ? this.configLoaderService.getTestCases() : of({}); + const testCaseMapFun = this.store.getValue().testSpecificationTesters.test_case_testing.length > 0 ? this.configLoaderService.getTestCases() : of({}); return forkJoin( this.configLoaderService.getConfigs(), this.configLoaderService.getRelease(), @@ -422,7 +426,8 @@ export class ConfigStoreService { } deleteConfig(configName: string): Observable { - return this.configLoaderService.deleteConfig(configName).pipe(map(data => { + const testCaseIsEnabled = this.store.getValue().testSpecificationTesters.test_case_testing.length > 0; + return this.configLoaderService.deleteConfig(configName, testCaseIsEnabled).pipe(map(data => { const newState = new ConfigStoreStateBuilder(this.store.getValue()) .testCaseMap(data.testCases) .configs(data.configs) diff --git a/config-editor/config-editor-ui/src/testing/store.ts b/config-editor/config-editor-ui/src/testing/store.ts index 87d462018..1b384fc3a 100644 --- a/config-editor/config-editor-ui/src/testing/store.ts +++ b/config-editor/config-editor-ui/src/testing/store.ts @@ -24,4 +24,5 @@ export const mockStore: ConfigStoreState = { isAnyFilterPresent: false, serviceFilterConfig: {}, user: "siembol", + testSpecificationTesters: undefined }; diff --git a/config/config-editor-ui/ui-bootstrap.json b/config/config-editor-ui/ui-bootstrap.json index 06e80f4dc..fef8c0933 100644 --- a/config/config-editor-ui/ui-bootstrap.json +++ b/config/config-editor-ui/ui-bootstrap.json @@ -13,12 +13,7 @@ "version": "rule_version", "author": "rule_author", "description": "rule_description", - "labelsFunc": "const ret = []; if (model.evaluators && model.evaluators.length > 0){for(const e of model.evaluators) {ret.push(e.evaluator_type);} } return ret;", - "testing": { - "perConfigTestEnabled": true, - "releaseTestEnabled": true, - "testCaseEnabled": false - } + "labelsFunc": "const ret = []; if (model.evaluators && model.evaluators.length > 0){for(const e of model.evaluators) {ret.push(e.evaluator_type);} } return ret;" }, "alert": { "release": { @@ -34,12 +29,7 @@ "version": "rule_version", "author": "rule_author", "description": "rule_description", - "labelsFunc": "const ret = ['SourceType:' + model.source_type]; if (model.tags !== undefined) { ret.push(...model.tags.map(t => t.tag_name + ':' + t.tag_value));} return ret;", - "testing": { - "perConfigTestEnabled": true, - "releaseTestEnabled": true, - "testCaseEnabled": true - } + "labelsFunc": "const ret = ['SourceType:' + model.source_type]; if (model.tags !== undefined) { ret.push(...model.tags.map(t => t.tag_name + ':' + t.tag_value));} return ret;" }, "correlationalert": { "release": { @@ -55,12 +45,7 @@ "version": "rule_version", "author": "rule_author", "description": "rule_description", - "labelsFunc": "const ret = []; if(model.correlation_attributes.length > 0) { for(const alert of model.correlation_attributes[0].alerts){ret.push(alert.alert);}} if(model.tags !== undefined) { ret.push(...model.tags.map(t => t.tag_name + ':' + t.tag_value));} return ret;", - "testing": { - "perConfigTestEnabled": false, - "releaseTestEnabled": false, - "testCaseEnabled": false - } + "labelsFunc": "const ret = []; if(model.correlation_attributes.length > 0) { for(const alert of model.correlation_attributes[0].alerts){ret.push(alert.alert);}} if(model.tags !== undefined) { ret.push(...model.tags.map(t => t.tag_name + ':' + t.tag_value));} return ret;" }, "parserconfig": { "release": { @@ -72,12 +57,7 @@ "version": "parser_version", "author": "parser_author", "description": "parser_description", - "labelsFunc": "const ret = []; if (model.parser_attributes) {ret.push(model.parser_attributes.parser_type);} if (model.parser_extractors && model.parser_extractors.length > 0){for(const p of model.parser_extractors) {ret.push(p.extractor_type)} } return ret;", - "testing": { - "perConfigTestEnabled": true, - "releaseTestEnabled": false, - "testCaseEnabled": true - } + "labelsFunc": "const ret = []; if (model.parser_attributes) {ret.push(model.parser_attributes.parser_type);} if (model.parser_extractors && model.parser_extractors.length > 0){for(const p of model.parser_extractors) {ret.push(p.extractor_type)} } return ret;" }, "parsingapp": { "release": { @@ -89,12 +69,7 @@ "version": "parsing_app_version", "author": "parsing_app_author", "description": "parsing_app_description", - "labelsFunc": "const ret = []; if (model.parsing_app_settings) {ret.push(model.parsing_app_settings.parsing_app_type); for(const topic of model.parsing_app_settings.input_topics){ ret.push(topic);}} return ret;", - "testing": { - "perConfigTestEnabled": false, - "releaseTestEnabled": false, - "testCaseEnabled": false - } + "labelsFunc": "const ret = []; if (model.parsing_app_settings) {ret.push(model.parsing_app_settings.parsing_app_type); for(const topic of model.parsing_app_settings.input_topics){ ret.push(topic);}} return ret;" }, "enrichment": { "release": { @@ -106,11 +81,6 @@ "version": "rule_version", "author": "rule_author", "description": "rule_description", - "labelsFunc": "const ret = []; if(model.source_type) {ret.push(model.source_type);} if(model.table_mapping) {if(model.table_mapping.table_name){ret.push(model.table_mapping.table_name);} if(model.table_mapping.joining_key){ret.push(model.table_mapping.joining_key);}} return ret;", - "testing": { - "perConfigTestEnabled": true, - "releaseTestEnabled": false, - "testCaseEnabled": true - } + "labelsFunc": "const ret = []; if(model.source_type) {ret.push(model.source_type);} if(model.table_mapping) {if(model.table_mapping.table_name){ret.push(model.table_mapping.table_name);} if(model.table_mapping.joining_key){ret.push(model.table_mapping.joining_key);}} return ret;" } }