Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function makeProp(overrides: Partial<ConnectorPropertyDescriptor> = {}): Connect
};
}

function makeAllowable(value: string, displayName: string = value): AllowableValue {
function makeAllowable(value: string, displayName: string = value, description?: string): AllowableValue {
return {
allowableValue: { value, displayName },
allowableValue: { value, displayName, description },
canRead: true
};
}
Expand Down Expand Up @@ -289,8 +289,24 @@ describe('ConnectorPropertyInput', () => {
});

expect(inputComponent.selectOptions).toEqual([
{ value: 'v1', label: 'Value One' },
{ value: 'v2', label: 'Value Two' }
{ value: 'v1', label: 'Value One', description: undefined },
{ value: 'v2', label: 'Value Two', description: undefined }
]);
});

it('includes allowable value descriptions in select options when present', async () => {
const { inputComponent } = await setup({
property: makeProp({
allowableValues: [
makeAllowable('v1', 'Value One', 'First option description'),
makeAllowable('v2', 'Value Two', 'Second option description')
]
})
});

expect(inputComponent.selectOptions).toEqual([
{ value: 'v1', label: 'Value One', description: 'First option description' },
{ value: 'v2', label: 'Value Two', description: 'Second option description' }
]);
});

Expand All @@ -309,8 +325,27 @@ describe('ConnectorPropertyInput', () => {
fixture.detectChanges();

expect(inputComponent.selectOptions).toEqual([
{ value: 'dyn-1', label: 'Dynamic 1' },
{ value: 'dyn-2', label: 'Dynamic 2' }
{ value: 'dyn-1', label: 'Dynamic 1', description: undefined },
{ value: 'dyn-2', label: 'Dynamic 2', description: undefined }
]);
});

it('includes descriptions from dynamic allowable values state', async () => {
const { inputComponent, host, fixture } = await setup({
property: makeProp({ allowableValuesFetchable: true })
});

host.dynamicAllowableValuesState.set({
loading: false,
error: null,
values: [makeAllowable('dyn-1', 'Dynamic 1', 'Fetched option description')]
});
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();

expect(inputComponent.selectOptions).toEqual([
{ value: 'dyn-1', label: 'Dynamic 1', description: 'Fetched option description' }
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ export class ConnectorPropertyInput implements ControlValueAccessor, DoCheck, On

const options: SearchableSelectOption<string>[] = allowableValues.map((av) => ({
value: av.allowableValue.value,
label: av.allowableValue.displayName
label: av.allowableValue.displayName,
description: av.allowableValue.description
}));

// Surface saved values that are no longer in the loaded allowable list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export interface AllowableValue {
allowableValue: {
displayName: string;
value: string;
description?: string;
};
canRead: boolean;
}
Expand Down
Loading