mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(editor): Display value of selected matching column in RMC (#7298)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
parent
a040770a27
commit
3aac22b4c1
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue