mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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,
|
||||
}"
|
||||
>
|
||||
<span v-html="simplyText"></span>
|
||||
<span data-test-id="parameter-input-hint" v-html="simplyText"></span>
|
||||
</div>
|
||||
<div
|
||||
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) };
|
||||
} catch (error) {
|
||||
return { ok: false, error };
|
||||
|
|
|
@ -293,14 +293,13 @@ export const useExpressionEditor = ({
|
|||
// e.g. credential modal
|
||||
result.resolved = Expression.resolveWithoutWorkflow(resolvable, toValue(additionalData));
|
||||
} else {
|
||||
let opts;
|
||||
let opts: Record<string, unknown> = { additionalKeys: toValue(additionalData) };
|
||||
if (ndvStore.isInputParentOfActiveNode) {
|
||||
opts = {
|
||||
targetItem: target ?? undefined,
|
||||
inputNodeName: ndvStore.ndvInputNodeName,
|
||||
inputRunIndex: ndvStore.ndvInputRunIndex,
|
||||
inputBranchIndex: ndvStore.ndvInputBranchIndex,
|
||||
additionalKeys: toValue(additionalData),
|
||||
};
|
||||
}
|
||||
result.resolved = workflowHelpers.resolveExpression('=' + resolvable, undefined, opts);
|
||||
|
|
Loading…
Reference in a new issue