Fix tests.

This commit is contained in:
Dessalines 2024-03-15 15:25:32 -04:00
parent 8c73b8d24e
commit 71d8fef10e

View file

@ -26,6 +26,8 @@ import {
} from "./shared"; } from "./shared";
const downloadFileSync = require("download-file-sync"); const downloadFileSync = require("download-file-sync");
const imageFetchLimit = 50;
beforeAll(setupLogins); beforeAll(setupLogins);
afterAll(() => { afterAll(() => {
@ -53,8 +55,13 @@ test("Upload image and delete it", async () => {
expect(listMediaRes.images.length).toBe(1); expect(listMediaRes.images.length).toBe(1);
// Ensure that it also comes back with the admin all images // Ensure that it also comes back with the admin all images
const listAllMediaRes = await alphaImage.listAllMedia(); const listAllMediaRes = await alphaImage.listAllMedia({
expect(listAllMediaRes.images.length).toBe(1); limit: imageFetchLimit,
});
// This number comes from all the previous thumbnails fetched in other tests.
const previousThumbnails = 30;
expect(listAllMediaRes.images.length).toBe(previousThumbnails);
// The deleteUrl is a combination of the endpoint, delete token, and alias // The deleteUrl is a combination of the endpoint, delete token, and alias
let firstImage = listMediaRes.images[0]; let firstImage = listMediaRes.images[0];
@ -78,8 +85,10 @@ test("Upload image and delete it", async () => {
expect(deletedListMediaRes.images.length).toBe(0); expect(deletedListMediaRes.images.length).toBe(0);
// Ensure that the admin shows its deleted // Ensure that the admin shows its deleted
const deletedListAllMediaRes = await alphaImage.listAllMedia(); const deletedListAllMediaRes = await alphaImage.listAllMedia({
expect(deletedListAllMediaRes.images.length).toBe(0); limit: imageFetchLimit,
});
expect(deletedListAllMediaRes.images.length).toBe(previousThumbnails - 1);
}); });
test("Purge user, uploaded image removed", async () => { test("Purge user, uploaded image removed", async () => {