copy paste images in admin
This commit is contained in:
1 parent
bef622b61f
commit
42ca51d58b
9 files changed
+189
-13
No files matched your search
@@ -229,6 +229,36 @@ test('journey, profile and homelab', async () => {
|
||||
assert.equal(publicStore.get().pages.homelab.de.lead, 'Was läuft');
|
||||
});
|
||||
|
||||
test('images pasted into a text are saved next to it', async () => {
|
||||
const paste = async (url, file, name = 'bild', token = csrf) => {
|
||||
const body = new FormData();
|
||||
body.set('_csrf', token);
|
||||
body.set('bild', new Blob([file]), name);
|
||||
return request(url, { method: 'POST', body });
|
||||
};
|
||||
|
||||
let res = await paste('/admin/projekte/alpha/bild', await image('png'));
|
||||
assert.equal(res.status, 200);
|
||||
assert.deepEqual(await res.json(), { src: 'bild.png' });
|
||||
assert.equal((await sharp(path.join(dataDir, 'projects/alpha/bild.png')).metadata()).width, 2400);
|
||||
assert.deepEqual(await (await paste('/admin/projekte/alpha/bild', await image('png'))).json(), { src: 'bild-2.png' });
|
||||
|
||||
res = await paste('/admin/seiten/bild', await image('jpeg'), 'Rack Foto.jpg');
|
||||
assert.deepEqual(await res.json(), { src: 'images/rack-foto.jpg' });
|
||||
res = await request('/admin/homelab', {
|
||||
method: 'POST',
|
||||
body: form({ visible: 'on', 'body[de]': 'Mein Rack:\n\n' }),
|
||||
});
|
||||
assert.equal(res.status, 303);
|
||||
assert.match(publicStore.get().pages.homelab.de.html, /<img src="\/media\/pages\/images\/rack-foto\.jpg\?w=1600&[^"]+" srcset=/);
|
||||
|
||||
res = await paste('/admin/seiten/bild', 'not an image', 'virus.exe');
|
||||
assert.equal(res.status, 422);
|
||||
assert.match((await res.json()).error, /kein Bild/);
|
||||
assert.equal((await paste('/admin/projekte/gibts-nicht/bild', await image('png'))).status, 404);
|
||||
assert.equal((await paste('/admin/seiten/bild', await image('png'), 'bild', 'falsch')).status, 403);
|
||||
});
|
||||
|
||||
test('clients are counted by address, IPv6 by /64', () => {
|
||||
assert.equal(clientKey('79.221.147.164'), '79.221.147.164');
|
||||
assert.equal(clientKey('::ffff:192.168.178.20'), '192.168.178.20');
|
||||
|
||||
Reference in new issue
Block a user