mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
Merge 4ccc8ab638 into 7fdd98aa72
This commit is contained in:
commit
c94d4354ca
|
|
@ -83,6 +83,56 @@ describe('Test Discord > prepareEmbeds', () => {
|
|||
|
||||
expect(result).toEqual(embeds);
|
||||
});
|
||||
|
||||
it('should wrap string image URLs but preserve object format', () => {
|
||||
const executeFunction = {};
|
||||
|
||||
// Test with string URL (should be wrapped)
|
||||
const embedsWithStringUrl = [
|
||||
{
|
||||
description: 'Test embed',
|
||||
image: 'https://example.com/image.png',
|
||||
},
|
||||
];
|
||||
|
||||
const resultString = prepareEmbeds.call(
|
||||
executeFunction as unknown as IExecuteFunctions,
|
||||
embedsWithStringUrl,
|
||||
);
|
||||
|
||||
expect(resultString).toEqual([
|
||||
{
|
||||
description: 'Test embed',
|
||||
image: {
|
||||
url: 'https://example.com/image.png',
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
// Test with already formatted object (should NOT be wrapped again)
|
||||
const embedsWithObject = [
|
||||
{
|
||||
description: 'Test embed',
|
||||
image: {
|
||||
url: 'https://example.com/image.png',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const resultObject = prepareEmbeds.call(
|
||||
executeFunction as unknown as IExecuteFunctions,
|
||||
embedsWithObject,
|
||||
);
|
||||
|
||||
expect(resultObject).toEqual([
|
||||
{
|
||||
description: 'Test embed',
|
||||
image: {
|
||||
url: 'https://example.com/image.png',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > checkAccessToGuild', () => {
|
||||
|
|
|
|||
|
|
@ -157,9 +157,11 @@ export function prepareEmbeds(this: IExecuteFunctions, embeds: IDataObject[]) {
|
|||
};
|
||||
}
|
||||
if (embedReturnData.image) {
|
||||
embedReturnData.image = {
|
||||
url: embedReturnData.image,
|
||||
};
|
||||
if (typeof embedReturnData.image === 'string') {
|
||||
embedReturnData.image = {
|
||||
url: embedReturnData.image,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return embedReturnData;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user