Skip to content

Commit

Permalink
fix(editor): Display value of selected matching column in RMC (#7298)
Browse files Browse the repository at this point in the history
Github issue / Community forum post (link here to close automatically):
  • Loading branch information
elsmr authored Oct 4, 2023
1 parent a040770 commit 3aac22b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ const {
pluralFieldWordCapitalized,
} = useNodeSpecificationValues(props.typeOptions);
const initialValue = computed<string | string[]>(() => {
return resourceMapperTypeOptions.value?.multiKeyMatch === true
? props.initialValue
: props.initialValue[0];
});
// Depending on the mode (multiple/singe key column), the selected value can be a string or an array of strings
const state = reactive({
selected: props.initialValue as string[] | string,
selected: initialValue.value,
});
watch(
() => props.initialValue,
() => {
state.selected =
resourceMapperTypeOptions.value?.multiKeyMatch === true
? props.initialValue
: props.initialValue[0];
state.selected = initialValue.value;
},
);
Expand Down
42 changes: 42 additions & 0 deletions packages/editor-ui/src/components/__tests__/ResourceMapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,46 @@ describe('ResourceMapper.vue', () => {
await waitAllPromises();
expect(fetchFieldsSpy).not.toHaveBeenCalled();
});

it('renders initially selected matching column properly', async () => {
const { getByTestId } = renderComponent(
{
props: {
node: {
parameters: {
columns: {
mappingMode: 'autoMapInputData',
matchingColumns: ['name'],
schema: [
{
id: 'name',
displayName: 'name',
canBeUsedToMatch: true,
},
{
id: 'email',
displayName: 'email',
canBeUsedToMatch: true,
},
],
},
},
},
parameter: {
typeOptions: {
resourceMapper: {
supportAutoMap: true,
mode: 'upsert',
multiKeyMatch: false,
},
},
},
},
},
{ merge: true },
);
await waitAllPromises();

expect(getByTestId('matching-column-select').querySelector('input')).toHaveValue('name');
});
});

0 comments on commit 3aac22b

Please sign in to comment.