ref: files e2e test
This commit is contained in:
@@ -46,7 +46,6 @@ export default class S3ConnectorService implements StorageConnectorAPI {
|
|||||||
let err = null;
|
let err = null;
|
||||||
for (let i = 0; i <= tries; i++) {
|
for (let i = 0; i <= tries; i++) {
|
||||||
try {
|
try {
|
||||||
console.log("🚀🚀 reading s3 object: ", path);
|
|
||||||
const stat = await this.client.statObject(this.minioConfiguration.bucket, path);
|
const stat = await this.client.statObject(this.minioConfiguration.bucket, path);
|
||||||
if (stat?.size > 0) {
|
if (stat?.size > 0) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -461,8 +461,8 @@ export class FileServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getFilePath(entity: File): string {
|
export const getFilePath = (entity: File): string => {
|
||||||
return `${gr.platformServices.storage.getHomeDir()}/files/${entity.company_id}/${
|
return `${gr.platformServices.storage.getHomeDir()}/files/${entity.company_id}/${
|
||||||
entity.user_id || "anonymous"
|
entity.user_id || "anonymous"
|
||||||
}/${entity.id}`;
|
}/${entity.id}`;
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
|
import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
|
||||||
import { init, TestPlatform } from "../setup";
|
import { init, TestPlatform } from "../setup";
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
import { getFilePath } from "../../../src/services/files/services";
|
||||||
// @ts-ignore
|
|
||||||
import S3ConnectorService from "../../../src/core/platform/services/storage/connectors/S3/s3-service";
|
|
||||||
import UserApi from "../common/user-api";
|
import UserApi from "../common/user-api";
|
||||||
|
|
||||||
describe("The Files feature", () => {
|
describe("The Files feature", () => {
|
||||||
@@ -33,15 +31,15 @@ describe("The Files feature", () => {
|
|||||||
|
|
||||||
it("Download file should return 500 if file doesn't exists", async () => {
|
it("Download file should return 500 if file doesn't exists", async () => {
|
||||||
//given file
|
//given file
|
||||||
const filesUpload = await helpers.uploadRandomFile();
|
const fileUpload = await helpers.uploadRandomFile();
|
||||||
expect(filesUpload.id).toBeTruthy();
|
expect(fileUpload.id).toBeTruthy();
|
||||||
// expect(platform.storage.getConnector()).toBeInstanceOf(S3ConnectorService);
|
// expect(platform.storage.getConnector()).toBeInstanceOf(S3ConnectorService);
|
||||||
const path = `tdrive/files/${platform.workspace.company_id}/${platform.currentUser.id}/${filesUpload.id}/chunk1`;
|
const path = `${getFilePath(fileUpload)}/chunk1`;
|
||||||
await platform.storage.getConnector().remove(path);
|
await platform.storage.getConnector().remove(path);
|
||||||
//when try to download the file
|
//when try to download the file
|
||||||
const fileDownloadResponse = await platform.app.inject({
|
const fileDownloadResponse = await platform.app.inject({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `${url}/companies/${platform.workspace.company_id}/files/${filesUpload.id}/download`,
|
url: `${url}/companies/${platform.workspace.company_id}/files/${fileUpload.id}/download`,
|
||||||
});
|
});
|
||||||
//then file should be not found with 404 error and "File not found message"
|
//then file should be not found with 404 error and "File not found message"
|
||||||
expect(fileDownloadResponse).toBeTruthy();
|
expect(fileDownloadResponse).toBeTruthy();
|
||||||
|
|||||||
Reference in New Issue
Block a user