feat(assistant): complete controlled management attachments and native schedules
This commit is contained in:
1 parent
d0bc4b0da2
commit
8341986067
119 files changed
+20519
-1618
No files matched your search
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
const { test } = require('node:test'),
|
||||
assert = require('node:assert/strict'),
|
||||
{ createCanvas } = require('@napi-rs/canvas');
|
||||
const { parse } = require('../../src/modules/assistant/attachments.cjs');
|
||||
test(
|
||||
'image attachment validates pixels and type and remains image data rather than text',
|
||||
{ timeout: 15000 },
|
||||
async () => {
|
||||
const canvas = createCanvas(40, 20);
|
||||
canvas.getContext('2d').fillRect(0, 0, 40, 20);
|
||||
const bytes = canvas.toBuffer('image/png'),
|
||||
file = await parse({ name: 'evidence.png', data: bytes.toString('base64') });
|
||||
assert.equal(file.kind, 'image');
|
||||
assert.equal(file.mediaType, 'image/png');
|
||||
assert.equal(file.width, 40);
|
||||
assert.ok(file.imageData.length);
|
||||
assert.equal(file.characters, 0);
|
||||
await assert.rejects(
|
||||
parse({ name: 'fake.png', data: Buffer.from('fake image').toString('base64') }),
|
||||
);
|
||||
const huge = Buffer.from(bytes);
|
||||
huge.writeUInt32BE(100000, 16);
|
||||
await assert.rejects(parse({ name: 'huge.png', data: huge.toString('base64') }));
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user