Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Refactor files e2e test #462

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default class S3ConnectorService implements StorageConnectorAPI {
let err = null;
for (let i = 0; i <= tries; i++) {
try {
console.log("🚀🚀 reading s3 object: ", path);
const stat = await this.client.statObject(this.minioConfiguration.bucket, path);
if (stat?.size > 0) {
break;
Expand Down
4 changes: 2 additions & 2 deletions tdrive/backend/node/src/services/files/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}/${
entity.user_id || "anonymous"
}/${entity.id}`;
}
};
12 changes: 5 additions & 7 deletions tdrive/backend/node/test/e2e/files/files.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import "reflect-metadata";
import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
import { init, TestPlatform } from "../setup";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import S3ConnectorService from "../../../src/core/platform/services/storage/connectors/S3/s3-service";
import { getFilePath } from "../../../src/services/files/services";
import UserApi from "../common/user-api";

describe("The Files feature", () => {
Expand Down Expand Up @@ -33,15 +31,15 @@ describe("The Files feature", () => {

it("Download file should return 500 if file doesn't exists", async () => {
//given file
const filesUpload = await helpers.uploadRandomFile();
expect(filesUpload.id).toBeTruthy();
const fileUpload = await helpers.uploadRandomFile();
expect(fileUpload.id).toBeTruthy();
// 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);
//when try to download the file
const fileDownloadResponse = await platform.app.inject({
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"
expect(fileDownloadResponse).toBeTruthy();
Expand Down
Loading