mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Allow $secrets
to resolve on credentials (#10093)
This commit is contained in:
parent
dd54390b0a
commit
bf57f38d1c
|
@ -7,7 +7,7 @@
|
||||||
[$style.highlight]: highlight,
|
[$style.highlight]: highlight,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span v-html="simplyText"></span>
|
<span data-test-id="parameter-input-hint" v-html="simplyText"></span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { renderComponent } from '@/__tests__/render';
|
||||||
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
|
import ParameterInputWrapper from './ParameterInputWrapper.vue';
|
||||||
|
|
||||||
|
describe('ParameterInputWrapper.vue', () => {
|
||||||
|
test('should resolve expression', async () => {
|
||||||
|
const { getByTestId } = renderComponent(ParameterInputWrapper, {
|
||||||
|
pinia: createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
ndv: {
|
||||||
|
activeNodeName: 'testNode',
|
||||||
|
input: { nodeName: 'inputNode' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
props: {
|
||||||
|
parameter: {
|
||||||
|
name: 'test',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
path: 'params.test',
|
||||||
|
modelValue: '={{ $secrets.infisical.password }}',
|
||||||
|
isForCredential: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: {
|
||||||
|
$workflowHelpers: {
|
||||||
|
resolveExpression: vi.fn(() => 'topSecret'),
|
||||||
|
},
|
||||||
|
$ndvStore: {
|
||||||
|
activeNode: vi.fn(() => ({ test: 'test' })),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(getByTestId('parameter-input-hint')).toHaveTextContent('[ERROR: ]');
|
||||||
|
});
|
||||||
|
});
|
|
@ -177,6 +177,8 @@ const evaluatedExpression = computed<Result<unknown, Error>>(() => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.isForCredential) opts.additionalKeys = resolvedAdditionalExpressionData.value;
|
||||||
|
|
||||||
return { ok: true, result: workflowHelpers.resolveExpression(value, undefined, opts) };
|
return { ok: true, result: workflowHelpers.resolveExpression(value, undefined, opts) };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { ok: false, error };
|
return { ok: false, error };
|
||||||
|
|
|
@ -293,14 +293,13 @@ export const useExpressionEditor = ({
|
||||||
// e.g. credential modal
|
// e.g. credential modal
|
||||||
result.resolved = Expression.resolveWithoutWorkflow(resolvable, toValue(additionalData));
|
result.resolved = Expression.resolveWithoutWorkflow(resolvable, toValue(additionalData));
|
||||||
} else {
|
} else {
|
||||||
let opts;
|
let opts: Record<string, unknown> = { additionalKeys: toValue(additionalData) };
|
||||||
if (ndvStore.isInputParentOfActiveNode) {
|
if (ndvStore.isInputParentOfActiveNode) {
|
||||||
opts = {
|
opts = {
|
||||||
targetItem: target ?? undefined,
|
targetItem: target ?? undefined,
|
||||||
inputNodeName: ndvStore.ndvInputNodeName,
|
inputNodeName: ndvStore.ndvInputNodeName,
|
||||||
inputRunIndex: ndvStore.ndvInputRunIndex,
|
inputRunIndex: ndvStore.ndvInputRunIndex,
|
||||||
inputBranchIndex: ndvStore.ndvInputBranchIndex,
|
inputBranchIndex: ndvStore.ndvInputBranchIndex,
|
||||||
additionalKeys: toValue(additionalData),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
result.resolved = workflowHelpers.resolveExpression('=' + resolvable, undefined, opts);
|
result.resolved = workflowHelpers.resolveExpression('=' + resolvable, undefined, opts);
|
||||||
|
|
Loading…
Reference in a new issue