mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-02 19:11:39 +02:00
Fix grpcurl copy for rendered template tags
This commit is contained in:
@@ -11,7 +11,7 @@ export const plugin: PluginDefinition = {
|
|||||||
async onSelect(ctx, args) {
|
async onSelect(ctx, args) {
|
||||||
const rendered_request = await ctx.grpcRequest.render({
|
const rendered_request = await ctx.grpcRequest.render({
|
||||||
grpcRequest: args.grpcRequest,
|
grpcRequest: args.grpcRequest,
|
||||||
purpose: 'preview',
|
purpose: 'send',
|
||||||
});
|
});
|
||||||
const data = await convert(rendered_request, args.protoFiles);
|
const data = await convert(rendered_request, args.protoFiles);
|
||||||
await ctx.clipboard.copyText(data);
|
await ctx.clipboard.copyText(data);
|
||||||
@@ -103,7 +103,7 @@ export async function convert(request: Partial<GrpcRequest>, allProtoFiles: stri
|
|||||||
|
|
||||||
// Add form params
|
// Add form params
|
||||||
if (request.message) {
|
if (request.message) {
|
||||||
xs.push('-d', `${quote(JSON.stringify(JSON.parse(request.message)))}`);
|
xs.push('-d', quote(request.message));
|
||||||
xs.push(NEWLINE);
|
xs.push(NEWLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,26 @@ describe('exporter-curl', () => {
|
|||||||
[
|
[
|
||||||
`grpcurl -import-path '/'`,
|
`grpcurl -import-path '/'`,
|
||||||
`-proto '/foo.proto'`,
|
`-proto '/foo.proto'`,
|
||||||
`-d '{"foo":"bar","baz":1}'`,
|
`-d '{\n "foo": "bar",\n "baz": 1\n}'`,
|
||||||
|
'yaak.app',
|
||||||
|
].join(' \\\n '),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Sends data with unresolved template tags', async () => {
|
||||||
|
expect(
|
||||||
|
await convert(
|
||||||
|
{
|
||||||
|
url: 'https://yaak.app',
|
||||||
|
message: '{"timestamp": ${[ faker "timestamp" ]}, "foo": "bar"}',
|
||||||
|
},
|
||||||
|
['/foo.proto'],
|
||||||
|
),
|
||||||
|
).toEqual(
|
||||||
|
[
|
||||||
|
`grpcurl -import-path '/'`,
|
||||||
|
`-proto '/foo.proto'`,
|
||||||
|
`-d '{"timestamp": \${[ faker "timestamp" ]}, "foo": "bar"}'`,
|
||||||
'yaak.app',
|
'yaak.app',
|
||||||
].join(' \\\n '),
|
].join(' \\\n '),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user