diff --git a/ui/src/app/metadata/provider/component/provider-wizard-summary.component.spec.ts b/ui/src/app/metadata/provider/component/provider-wizard-summary.component.spec.ts
new file mode 100644
index 000000000..d951464ad
--- /dev/null
+++ b/ui/src/app/metadata/provider/component/provider-wizard-summary.component.spec.ts
@@ -0,0 +1,94 @@
+import { Component, ViewChild } from '@angular/core';
+import { TestBed, async, ComponentFixture } from '@angular/core/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { StoreModule, Store, combineReducers } from '@ngrx/store';
+
+import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
+
+import { ProviderWizardSummaryComponent } from './provider-wizard-summary.component';
+import * as fromRoot from '../reducer';
+import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-schema-form';
+import * as fromWizard from '../../../wizard/reducer';
+import { Wizard } from '../../../wizard/model';
+import { MetadataProvider } from '../../domain/model';
+import { SummaryPropertyComponent } from './summary-property.component';
+import { SCHEMA } from '../../../../testing/form-schema.stub';
+import { MetadataProviderWizard } from '../model';
+
+@Component({
+ template: `
+
+ `
+})
+class TestHostComponent {
+ @ViewChild(ProviderWizardSummaryComponent)
+ public componentUnderTest: ProviderWizardSummaryComponent;
+
+ private _summary;
+
+ get summary(): { definition: Wizard, schema: { [id: string]: any }, model: any } {
+ return this._summary;
+ }
+
+ set summary(summary: { definition: Wizard, schema: { [id: string]: any }, model: any }) {
+ this._summary = summary;
+ }
+}
+
+describe('Provider Wizard Summary Component', () => {
+
+ let fixture: ComponentFixture;
+ let instance: TestHostComponent;
+ let app: ProviderWizardSummaryComponent;
+ let store: Store;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ NgbDropdownModule.forRoot(),
+ RouterTestingModule,
+ SchemaFormModule.forRoot(),
+ StoreModule.forRoot({
+ provider: combineReducers(fromRoot.reducers),
+ wizard: combineReducers(fromWizard.reducers)
+ })
+ ],
+ declarations: [
+ ProviderWizardSummaryComponent,
+ SummaryPropertyComponent,
+ TestHostComponent
+ ],
+ providers: [
+ { provide: WidgetRegistry, useClass: DefaultWidgetRegistry }
+ ]
+ }).compileComponents();
+
+ store = TestBed.get(Store);
+ spyOn(store, 'dispatch');
+
+ fixture = TestBed.createComponent(TestHostComponent);
+ instance = fixture.componentInstance;
+ app = instance.componentUnderTest;
+ fixture.detectChanges();
+ }));
+
+ it('should instantiate the component', async(() => {
+ expect(app).toBeTruthy();
+ }));
+
+ describe('ngOnChanges', () => {
+ it('should set columns and sections if summary is provided', () => {
+ instance.summary = {
+ model: {
+ name: 'foo',
+ '@type': 'MetadataProvider'
+ },
+ schema: SCHEMA,
+ definition: MetadataProviderWizard
+ };
+ fixture.detectChanges();
+ expect(app.sections).toBeDefined();
+ expect(app.columns).toBeDefined();
+ });
+ });
+});
diff --git a/ui/src/app/metadata/provider/component/provider-wizard-summary.component.ts b/ui/src/app/metadata/provider/component/provider-wizard-summary.component.ts
index ad4d6fc68..822e51337 100644
--- a/ui/src/app/metadata/provider/component/provider-wizard-summary.component.ts
+++ b/ui/src/app/metadata/provider/component/provider-wizard-summary.component.ts
@@ -58,7 +58,7 @@ export class ProviderWizardSummaryComponent implements OnChanges {
id: step.id,
index: step.index,
label: step.label,
- properties: getStepProperties(schemas[step.id], def.translate ? def.translate.formatter(model) : model)
+ properties: getStepProperties(schemas[step.id], def.translate.formatter(model))
})
);
diff --git a/ui/src/app/metadata/provider/component/summary-property.component.spec.ts b/ui/src/app/metadata/provider/component/summary-property.component.spec.ts
new file mode 100644
index 000000000..8a0fe498b
--- /dev/null
+++ b/ui/src/app/metadata/provider/component/summary-property.component.spec.ts
@@ -0,0 +1,75 @@
+import { Component, ViewChild } from '@angular/core';
+import { TestBed, async, ComponentFixture } from '@angular/core/testing';
+import { RouterTestingModule } from '@angular/router/testing';
+import { StoreModule, Store, combineReducers } from '@ngrx/store';
+
+import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
+
+import { SummaryPropertyComponent } from './summary-property.component';
+import * as fromRoot from '../reducer';
+import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-schema-form';
+import * as fromWizard from '../../../wizard/reducer';
+import { Wizard } from '../../../wizard/model';
+import { MetadataProvider } from '../../domain/model';
+import { Property } from '../model/property';
+
+@Component({
+ template: `
+
+ `
+})
+class TestHostComponent {
+ @ViewChild(SummaryPropertyComponent)
+ public componentUnderTest: SummaryPropertyComponent;
+
+ private _property;
+
+ get property(): Property {
+ return this._property;
+ }
+
+ set property(prop: Property) {
+ this._property = prop;
+ }
+}
+
+describe('Summary Property Component', () => {
+
+ let fixture: ComponentFixture;
+ let instance: TestHostComponent;
+ let app: SummaryPropertyComponent;
+ let store: Store;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ NgbDropdownModule.forRoot(),
+ RouterTestingModule,
+ SchemaFormModule.forRoot(),
+ StoreModule.forRoot({
+ provider: combineReducers(fromRoot.reducers),
+ wizard: combineReducers(fromWizard.reducers)
+ })
+ ],
+ declarations: [
+ SummaryPropertyComponent,
+ TestHostComponent
+ ],
+ providers: [
+ { provide: WidgetRegistry, useClass: DefaultWidgetRegistry }
+ ]
+ }).compileComponents();
+
+ store = TestBed.get(Store);
+ spyOn(store, 'dispatch');
+
+ fixture = TestBed.createComponent(TestHostComponent);
+ instance = fixture.componentInstance;
+ app = instance.componentUnderTest;
+ fixture.detectChanges();
+ }));
+
+ it('should instantiate the component', async(() => {
+ expect(app).toBeTruthy();
+ }));
+});
diff --git a/ui/src/app/metadata/provider/container/provider-wizard-step.component.spec.ts b/ui/src/app/metadata/provider/container/provider-wizard-step.component.spec.ts
index 6e93c612b..eac91d512 100644
--- a/ui/src/app/metadata/provider/container/provider-wizard-step.component.spec.ts
+++ b/ui/src/app/metadata/provider/container/provider-wizard-step.component.spec.ts
@@ -9,6 +9,8 @@ import { ProviderWizardStepComponent } from './provider-wizard-step.component';
import * as fromRoot from '../reducer';
import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-schema-form';
import * as fromWizard from '../../../wizard/reducer';
+import { SCHEMA } from '../../../../testing/form-schema.stub';
+import { MetadataProviderWizard } from '../model';
@Component({
template: `
@@ -59,4 +61,38 @@ describe('Provider Wizard Step Component', () => {
it('should instantiate the component', async(() => {
expect(app).toBeTruthy();
}));
+
+ describe('resetSelectedType method', () => {
+ it('should dispatch a SetDefinition action if the type has changed', () => {
+ app.resetSelectedType({ value: { name: 'foo', '@type': 'FileBackedHttpMetadataResolver' } }, SCHEMA, MetadataProviderWizard);
+ expect(store.dispatch).toHaveBeenCalled();
+ });
+
+ it('should NOT dispatch a SetDefinition action if the type hasn\'t changed', () => {
+ app.resetSelectedType({ value: { name: 'foo', '@type': 'MetadataProvider' } }, SCHEMA, MetadataProviderWizard);
+ expect(store.dispatch).not.toHaveBeenCalled();
+ });
+
+ it('should NOT dispatch a SetDefinition action if the type isn\'t found', () => {
+ app.resetSelectedType({ value: { name: 'foo', '@type': 'FooProvider' } }, SCHEMA, MetadataProviderWizard);
+ expect(store.dispatch).not.toHaveBeenCalled();
+ });
+
+ it('should return changes and definition if no type supplied', () => {
+ app.resetSelectedType({ value: { name: 'foo' } }, SCHEMA, MetadataProviderWizard);
+ expect(store.dispatch).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('updateStatus method', () => {
+ it('should dispatch an UpdateStatus action', () => {
+ app.updateStatus({value: { name: 'notfound'} });
+ expect(store.dispatch).toHaveBeenCalled();
+ });
+
+ it('should NOT dispatch a SetDefinition action if the type hasn\'t changed', () => {
+ app.updateStatus({ value: null });
+ expect(store.dispatch).toHaveBeenCalled();
+ });
+ });
});
diff --git a/ui/src/app/metadata/provider/container/provider-wizard-step.component.ts b/ui/src/app/metadata/provider/container/provider-wizard-step.component.ts
index 248542173..7d09b8ec1 100644
--- a/ui/src/app/metadata/provider/container/provider-wizard-step.component.ts
+++ b/ui/src/app/metadata/provider/container/provider-wizard-step.component.ts
@@ -1,6 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
-import { withLatestFrom, map, distinctUntilChanged } from 'rxjs/operators';
+import { withLatestFrom, map, distinctUntilChanged, skipWhile } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import * as fromProvider from '../reducer';
@@ -86,44 +86,47 @@ export class ProviderWizardStepComponent implements OnDestroy {
},
definition
})),
- map(({ model, definition }) => definition && definition.translate ? definition.translate.formatter(model) : model)
+ skipWhile(({ model, definition }) => !definition || !model),
+ map(({ model, definition }) => definition.translate.formatter(model))
);
this.valueChangeEmitted$.pipe(
withLatestFrom(this.schema$, this.definition$),
- map(([changes, schema, definition]) => {
- const type = changes.value['@type'];
- if (type && type !== definition.type) {
- const newDefinition = MetadataProviderTypes.find(def => def.type === type);
- if (newDefinition) {
- this.store.dispatch(new SetDefinition({
- ...MetadataProviderWizard,
- ...newDefinition,
- steps: [
- ...MetadataProviderWizard.steps,
- ...newDefinition.steps
- ]
- }));
- changes = { value: pick(Object.keys(schema.properties))(changes.value) };
- }
- }
- return { changes: changes.value, definition };
- }),
- map(({ changes, definition }) => definition.translate ? definition.translate.parser(changes) : changes)
+ map(([changes, schema, definition]) => this.resetSelectedType(changes, schema, definition)),
+ skipWhile(({ changes, definition }) => !definition || !changes),
+ map(({ changes, definition }) => definition.translate.parser(changes))
)
.subscribe(changes => this.store.dispatch(new UpdateProvider(changes)));
- this.statusChangeEmitted$.pipe(
- distinctUntilChanged()
- ).subscribe(errors => {
- console.log(!(errors.value));
- const status = { [this.currentPage]: !(errors.value) ? 'VALID' : 'INVALID' };
- this.store.dispatch(new UpdateStatus(status));
- });
+ this.statusChangeEmitted$.pipe(distinctUntilChanged()).subscribe(errors => this.updateStatus(errors));
this.store.select(fromWizard.getWizardIndex).subscribe(i => this.currentPage = i);
}
+ resetSelectedType(changes: any, schema: any, definition: any): { changes: any, definition: any } {
+ const type = changes.value['@type'];
+ if (type && type !== definition.type) {
+ const newDefinition = MetadataProviderTypes.find(def => def.type === type);
+ if (newDefinition) {
+ this.store.dispatch(new SetDefinition({
+ ...MetadataProviderWizard,
+ ...newDefinition,
+ steps: [
+ ...MetadataProviderWizard.steps,
+ ...newDefinition.steps
+ ]
+ }));
+ changes = { value: pick(Object.keys(schema.properties))(changes.value) };
+ }
+ }
+ return { changes: changes.value, definition };
+ }
+
+ updateStatus(errors: any): void {
+ const status = { [this.currentPage]: !(errors.value) ? 'VALID' : 'INVALID' };
+ this.store.dispatch(new UpdateStatus(status));
+ }
+
ngOnDestroy() {
this.valueChangeSubject.complete();
}
diff --git a/ui/src/app/metadata/provider/container/provider-wizard.component.ts b/ui/src/app/metadata/provider/container/provider-wizard.component.ts
index 793f491da..ee18b72b0 100644
--- a/ui/src/app/metadata/provider/container/provider-wizard.component.ts
+++ b/ui/src/app/metadata/provider/container/provider-wizard.component.ts
@@ -76,9 +76,7 @@ export class ProviderWizardComponent implements OnDestroy {
}
next(): void {
- if (this.nextStep) {
- this.store.dispatch(new SetIndex(this.nextStep.id));
- }
+ this.store.dispatch(new SetIndex(this.nextStep.id));
}
previous(): void {
diff --git a/ui/src/app/metadata/provider/model/provider.form.ts b/ui/src/app/metadata/provider/model/provider.form.ts
index 133de467f..698d20134 100644
--- a/ui/src/app/metadata/provider/model/provider.form.ts
+++ b/ui/src/app/metadata/provider/model/provider.form.ts
@@ -4,7 +4,11 @@ import { Metadata } from '../../domain/domain.type';
export const MetadataProviderWizard: Wizard = {
label: 'MetadataProvider',
- type: '@MetadataProvider',
+ type: 'MetadataProvider',
+ translate: {
+ parser: changes => changes,
+ formatter: model => model
+ },
steps: [
{
id: 'new',
diff --git a/ui/src/app/metadata/provider/reducer/collection.reducer.spec.ts b/ui/src/app/metadata/provider/reducer/collection.reducer.spec.ts
index 1631c189f..4204ebe65 100644
--- a/ui/src/app/metadata/provider/reducer/collection.reducer.spec.ts
+++ b/ui/src/app/metadata/provider/reducer/collection.reducer.spec.ts
@@ -13,7 +13,7 @@ const snapshot: fromProvider.CollectionState = {
loaded: false
};
-describe('Provider Reducer', () => {
+describe('Provider Collection Reducer', () => {
describe('undefined action', () => {
it('should return the default state', () => {
const result = reducer(snapshot, {} as any);
diff --git a/ui/src/app/metadata/provider/reducer/editor.reducer.spec.ts b/ui/src/app/metadata/provider/reducer/editor.reducer.spec.ts
index e69de29bb..d1b58da34 100644
--- a/ui/src/app/metadata/provider/reducer/editor.reducer.spec.ts
+++ b/ui/src/app/metadata/provider/reducer/editor.reducer.spec.ts
@@ -0,0 +1,18 @@
+import { reducer, initialState as snapshot } from './editor.reducer';
+import { EditorActionTypes, ClearEditor } from '../action/editor.action';
+
+describe('Provider Editor Reducer', () => {
+ describe('undefined action', () => {
+ it('should return the default state', () => {
+ const result = reducer(snapshot, {} as any);
+
+ expect(result).toEqual(snapshot);
+ });
+ });
+
+ describe(`${EditorActionTypes.CLEAR}`, () => {
+ it('should reset to initial state', () => {
+ expect(reducer(snapshot, new ClearEditor())).toEqual(snapshot);
+ });
+ });
+});
diff --git a/ui/src/app/metadata/provider/reducer/entity.reducer.spec.ts b/ui/src/app/metadata/provider/reducer/entity.reducer.spec.ts
new file mode 100644
index 000000000..3079a99cd
--- /dev/null
+++ b/ui/src/app/metadata/provider/reducer/entity.reducer.spec.ts
@@ -0,0 +1,18 @@
+import { reducer, initialState as snapshot } from './entity.reducer';
+import { EntityActionTypes, ClearProvider } from '../action/entity.action';
+
+describe('Provider Editor Reducer', () => {
+ describe('undefined action', () => {
+ it('should return the default state', () => {
+ const result = reducer(snapshot, {} as any);
+
+ expect(result).toEqual(snapshot);
+ });
+ });
+
+ describe(`${EntityActionTypes.CLEAR_PROVIDER}`, () => {
+ it('should reset to initial state', () => {
+ expect(reducer(snapshot, new ClearProvider())).toEqual(snapshot);
+ });
+ });
+});
diff --git a/ui/src/app/wizard/guard/step-exists.guard.ts b/ui/src/app/wizard/guard/step-exists.guard.ts
deleted file mode 100644
index cd382ee14..000000000
--- a/ui/src/app/wizard/guard/step-exists.guard.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Injectable } from '@angular/core';
-import {
- CanActivate,
- Router,
- ActivatedRouteSnapshot,
- RouterStateSnapshot
-} from '@angular/router';
-import { Store } from '@ngrx/store';
-import { Observable, of } from 'rxjs';
-import { map, tap } from 'rxjs/operators';
-
-import * as fromWizard from '../reducer';
-
-@Injectable()
-export class StepExistsGuard implements CanActivate {
- constructor(
- private store: Store,
- private router: Router
- ) { }
-
- canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable {
- this.store.select(fromWizard.getWizardDefinition).pipe(
- map(current => !!current)
- ).subscribe(defined => console.log(defined));
- return of(true);
- }
-}
-
-// !isDefined ? this.router.navigate(['metadata/provider/wizard/new']) : isDefined
diff --git a/ui/src/app/wizard/model/wizard.ts b/ui/src/app/wizard/model/wizard.ts
index b95f18cd9..8b5fe344e 100644
--- a/ui/src/app/wizard/model/wizard.ts
+++ b/ui/src/app/wizard/model/wizard.ts
@@ -2,7 +2,7 @@ export interface Wizard {
label: string;
type: string;
steps: WizardStep[];
- translate?: {
+ translate: {
parser(changes: Partial, schema?: any),
formatter(changes: Partial, schema?: any)
};
diff --git a/ui/src/app/wizard/reducer/index.spec.ts b/ui/src/app/wizard/reducer/index.spec.ts
new file mode 100644
index 000000000..78ff09441
--- /dev/null
+++ b/ui/src/app/wizard/reducer/index.spec.ts
@@ -0,0 +1,91 @@
+import * as selectors from './';
+import { FileBackedHttpMetadataProviderWizard } from '../../metadata/provider/model';
+
+describe('wizard index selectors', () => {
+ describe('getSchema method', () => {
+ it('should return the schema by index name', () => {
+ expect(
+ selectors.getSchema('common', FileBackedHttpMetadataProviderWizard)
+ ).toBe(FileBackedHttpMetadataProviderWizard.steps[0].schema);
+ });
+ it('should return nothing if no schema is found', () => {
+ expect(
+ selectors.getSchema('common', null)
+ ).toBeFalsy();
+ });
+ });
+ describe('getPreviousFn method', () => {
+ it('should return the previous step', () => {
+ expect(
+ selectors.getPreviousFn('reloading', FileBackedHttpMetadataProviderWizard)
+ ).toBe(FileBackedHttpMetadataProviderWizard.steps[0]);
+ });
+ it('should return null if the index is the first step', () => {
+ expect(
+ selectors.getPreviousFn('common', FileBackedHttpMetadataProviderWizard)
+ ).toBeFalsy();
+ });
+ it('should return nothing if no schema is found', () => {
+ expect(
+ selectors.getPreviousFn('common', null)
+ ).toBeFalsy();
+ });
+ });
+
+ describe('getNextFn method', () => {
+ it('should return the previous step', () => {
+ expect(
+ selectors.getNextFn('common', FileBackedHttpMetadataProviderWizard)
+ ).toBe(FileBackedHttpMetadataProviderWizard.steps[1]);
+ });
+ it('should return null if the index is the last step', () => {
+ expect(
+ selectors.getNextFn('summary', FileBackedHttpMetadataProviderWizard)
+ ).toBeFalsy();
+ });
+ it('should return nothing if no schema is found', () => {
+ expect(
+ selectors.getNextFn('common', null)
+ ).toBeFalsy();
+ });
+ });
+
+ describe('getCurrentFn method', () => {
+ it('should return the current step', () => {
+ expect(
+ selectors.getCurrentFn('common', FileBackedHttpMetadataProviderWizard)
+ ).toBe(FileBackedHttpMetadataProviderWizard.steps[0]);
+ });
+ it('should return nothing if no schema is found', () => {
+ expect(
+ selectors.getCurrentFn('common', null)
+ ).toBeFalsy();
+ });
+ });
+
+ describe('getLastFn method', () => {
+ it('should return the last step', () => {
+ expect(
+ selectors.getLastFn('summary', FileBackedHttpMetadataProviderWizard)
+ ).toBe(FileBackedHttpMetadataProviderWizard.steps.find(step => step.id === 'summary'));
+ });
+ it('should return nothing if no definition is provided', () => {
+ expect(
+ selectors.getLastFn('common', null)
+ ).toBeFalsy();
+ });
+ it('should return nothing if no schema is found', () => {
+ expect(
+ selectors.getLastFn('common', FileBackedHttpMetadataProviderWizard)
+ ).toBeFalsy();
+ });
+ });
+
+ describe('getModelFn method', () => {
+ it('should return the model', () => {
+ const step = FileBackedHttpMetadataProviderWizard.steps.find(s => s.id === 'filters');
+ console.log(step);
+ expect(selectors.getModelFn(step)).toEqual({ metadataFilters: [] });
+ });
+ });
+});
diff --git a/ui/src/app/wizard/reducer/index.ts b/ui/src/app/wizard/reducer/index.ts
index 77fbefbef..7e3db4c01 100644
--- a/ui/src/app/wizard/reducer/index.ts
+++ b/ui/src/app/wizard/reducer/index.ts
@@ -56,8 +56,8 @@ export const getLastFn = (index: string, wizard: Wizard) => {
};
export const getModelFn = (currentStep: WizardStep) => {
- const model = (currentStep && currentStep.initialValues) || [];
- return model.reduce((m, property) => m[property.key] = property.value, {});
+ const model = (currentStep && currentStep.initialValues) ? currentStep.initialValues : [];
+ return model.reduce((m, property) => ({...m, [property.key]: property.value }), {});
};
export const getPrevious = createSelector(getWizardIndex, getWizardDefinition, getPreviousFn);
diff --git a/ui/src/app/wizard/reducer/wizard.reducer.spec.ts b/ui/src/app/wizard/reducer/wizard.reducer.spec.ts
new file mode 100644
index 000000000..c922c226d
--- /dev/null
+++ b/ui/src/app/wizard/reducer/wizard.reducer.spec.ts
@@ -0,0 +1,74 @@
+import { reducer, initialState as snapshot } from './wizard.reducer';
+import * as selectors from './wizard.reducer';
+import { WizardActionTypes, ClearWizard, AddSchema, SetDisabled, SetDefinition, SetIndex, UpdateDefinition } from '../action/wizard.action';
+import { SCHEMA } from '../../../testing/form-schema.stub';
+import { MetadataProviderWizard, FileBackedHttpMetadataProviderWizard } from '../../metadata/provider/model';
+
+
+
+describe('Wizard Reducer', () => {
+ describe('undefined action', () => {
+ it('should return the default state', () => {
+ const result = reducer(snapshot, {} as any);
+
+ expect(result).toEqual(snapshot);
+ });
+ });
+
+ describe(`${WizardActionTypes.CLEAR}`, () => {
+ it('should reset to initial state', () => {
+ expect(reducer(snapshot, new ClearWizard())).toEqual(snapshot);
+ });
+ });
+
+ describe(`${WizardActionTypes.ADD_SCHEMA}`, () => {
+ it('should add the payload to the schema collection', () => {
+ expect(reducer(snapshot, new AddSchema({id: 'foo', schema: SCHEMA })).schemaCollection).toEqual({ 'foo': SCHEMA });
+ });
+ });
+
+ describe(`${WizardActionTypes.SET_DISABLED}`, () => {
+ it('should set the disabled property on the wizard', () => {
+ expect(reducer(snapshot, new SetDisabled(true)).disabled).toBe(true);
+ expect(reducer(snapshot, new SetDisabled(false)).disabled).toBe(false);
+ });
+ });
+
+ describe(`${WizardActionTypes.SET_DEFINITION}`, () => {
+ it('should set the definition property on the wizard', () => {
+ expect(reducer(snapshot, new SetDefinition(MetadataProviderWizard)).definition).toBe(MetadataProviderWizard);
+ });
+ });
+
+ describe(`${WizardActionTypes.SET_INDEX}`, () => {
+ it('should set the definition property on the wizard', () => {
+ expect(reducer(snapshot, new SetIndex(MetadataProviderWizard.steps[0].id)).index).toBe('new');
+ });
+ });
+
+ describe(`${WizardActionTypes.SET_INDEX}`, () => {
+ let state = reducer(snapshot, new SetDefinition(MetadataProviderWizard));
+ it('should set the definition property on the wizard', () => {
+ expect(reducer(state, new UpdateDefinition(FileBackedHttpMetadataProviderWizard))).toEqual({
+ ...state,
+ definition: {
+ ...MetadataProviderWizard,
+ ...FileBackedHttpMetadataProviderWizard,
+ steps: [
+ ...MetadataProviderWizard.steps,
+ ...FileBackedHttpMetadataProviderWizard.steps
+ ]
+ }
+ });
+ });
+ });
+
+ describe('selector functions', () => {
+ it('should return pieces of state', () => {
+ expect(selectors.getCollection(snapshot)).toEqual(snapshot.schemaCollection);
+ expect(selectors.getDefinition(snapshot)).toEqual(snapshot.definition);
+ expect(selectors.getDisabled(snapshot)).toEqual(snapshot.disabled);
+ expect(selectors.getIndex(snapshot)).toEqual(snapshot.index);
+ });
+ });
+});
diff --git a/ui/src/app/wizard/wizard.module.ts b/ui/src/app/wizard/wizard.module.ts
index 6664ec16a..8612649b6 100644
--- a/ui/src/app/wizard/wizard.module.ts
+++ b/ui/src/app/wizard/wizard.module.ts
@@ -5,7 +5,6 @@ import { EffectsModule } from '@ngrx/effects';
import { WizardComponent } from './component/wizard.component';
import { reducers } from './reducer';
-import { StepExistsGuard } from './guard/step-exists.guard';
@NgModule({
declarations: [
@@ -23,9 +22,7 @@ export class WizardModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: RootWizardModule,
- providers: [
- StepExistsGuard
- ]
+ providers: []
};
}
}
diff --git a/ui/src/testing/form-schema.stub.ts b/ui/src/testing/form-schema.stub.ts
new file mode 100644
index 000000000..c91f63bf1
--- /dev/null
+++ b/ui/src/testing/form-schema.stub.ts
@@ -0,0 +1,48 @@
+export const SCHEMA = {
+ 'title': 'MetadataResolver',
+ 'type': 'object',
+ 'widget': {
+ 'id': 'fieldset'
+ },
+ 'properties': {
+ 'name': {
+ 'title': 'Metadata Provider Name (Dashboard Display Only)',
+ 'description': 'Metadata Provider Name (Dashboard Display Only)',
+ 'type': 'string',
+ 'widget': {
+ 'id': 'string',
+ 'help': 'Must be unique.'
+ }
+ },
+ '@type': {
+ 'title': 'Metadata Provider Type',
+ 'description': 'Metadata Provider Type',
+ 'ui:placeholder': 'Select a metadata provider type',
+ 'type': 'string',
+ 'widget': {
+ 'id': 'select'
+ },
+ 'oneOf': [
+ {
+ 'enum': [
+ 'FileBackedHttpMetadataResolver'
+ ],
+ 'description': 'FileBackedHttpMetadataProvider'
+ }
+ ]
+ }
+ },
+ 'required': [
+ 'name',
+ '@type'
+ ],
+ 'fieldsets': [
+ {
+ 'type': 'section',
+ 'fields': [
+ 'name',
+ '@type'
+ ]
+ }
+ ]
+};