mirror of
https://github.com/strapi/strapi.git
synced 2025-10-28 08:32:08 +00:00
add e2e test to check image dimensions are populated
This commit is contained in:
parent
c69ac511f4
commit
0fbcd89ec8
42
packages/core/upload/tests/admin/image-dimension.test.e2e.js
Normal file
42
packages/core/upload/tests/admin/image-dimension.test.e2e.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const { createTestBuilder } = require('../../../../../test/helpers/builder');
|
||||||
|
const { createStrapiInstance } = require('../../../../../test/helpers/strapi');
|
||||||
|
const { createAuthRequest } = require('../../../../../test/helpers/request');
|
||||||
|
|
||||||
|
const builder = createTestBuilder();
|
||||||
|
let strapi;
|
||||||
|
let rq;
|
||||||
|
|
||||||
|
describe('Dimensions are populated when uploading an image', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
strapi = await createStrapiInstance();
|
||||||
|
rq = await createAuthRequest({ strapi });
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await strapi.destroy();
|
||||||
|
await builder.cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each([['.jpg'], ['.png'], ['.webp'], ['.tiff'], ['.svg'], ['.gif']])(
|
||||||
|
'Dimensions are populated for %s',
|
||||||
|
async ext => {
|
||||||
|
const res = await rq({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/upload',
|
||||||
|
formData: { files: fs.createReadStream(path.join(__dirname, `../utils/strapi${ext}`)) },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.statusCode).toBe(200);
|
||||||
|
expect(res.body[0]).toMatchObject({
|
||||||
|
width: 256,
|
||||||
|
height: 256,
|
||||||
|
ext,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
BIN
packages/core/upload/tests/utils/strapi.gif
Normal file
BIN
packages/core/upload/tests/utils/strapi.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
packages/core/upload/tests/utils/strapi.jpg
Normal file
BIN
packages/core/upload/tests/utils/strapi.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
packages/core/upload/tests/utils/strapi.png
Normal file
BIN
packages/core/upload/tests/utils/strapi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
8
packages/core/upload/tests/utils/strapi.svg
Normal file
8
packages/core/upload/tests/utils/strapi.svg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg width="256px" height="256px" viewBox="0 -2 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||||
|
<g fill="#8E75FF">
|
||||||
|
<path d="M249.868148,1.42108547e-14 L81.6129672,1.42108547e-14 L81.6129672,84.3619834 L164.402564,84.3619834 C167.35201,84.3619834 169.744773,86.7547464 169.744773,89.7041929 L169.744773,171.351123 L255.210366,171.351123 L255.210366,5.3519758 C255.212951,3.93344238 254.651257,2.57212016 253.649118,1.56814827 C252.646978,0.56417638 251.286684,1.42108547e-14 249.868148,1.42108547e-14 Z"></path>
|
||||||
|
<path d="M81.6032009,0 L81.6032009,84.3619834 L2.67132424,84.3619834 C1.58669272,84.3600599 0.610497706,83.7036101 0.199569944,82.6998335 C-0.211357818,81.6960568 0.0242672254,80.5435101 0.796179436,79.7815516 L81.6032009,0 L81.6032009,0 Z M174.295906,251.220572 C173.527464,251.975341 172.381399,252.195816 171.387771,251.780027 C170.394142,251.364238 169.746654,250.393242 169.744773,249.316128 L169.744773,171.351123 L255.210357,171.351123 L174.295906,251.210806 L174.295906,251.220572 L174.295906,251.220572 Z" opacity="0.405"></path>
|
||||||
|
<path d="M81.6032009,84.3619834 L167.078552,84.3619834 C168.543508,84.3619834 169.744773,85.5534817 169.744773,87.028205 L169.744773,171.351123 L86.9551767,171.351123 C84.0047559,171.351123 81.6129672,168.959334 81.6129672,166.008913 L81.6129672,84.3619834 L81.6032009,84.3619834 L81.6032009,84.3619834 Z" fill-rule="nonzero" opacity="0.405"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
BIN
packages/core/upload/tests/utils/strapi.tiff
Normal file
BIN
packages/core/upload/tests/utils/strapi.tiff
Normal file
Binary file not shown.
BIN
packages/core/upload/tests/utils/strapi.webp
Normal file
BIN
packages/core/upload/tests/utils/strapi.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
Loading…
x
Reference in New Issue
Block a user