🤝 Shared with me (#71)

* 🚧 #46 Shared with me
  - added converter of DriveFile to dto with user information
  - updated version of jest to the latest for better compatibility with typescript and mocking class instances
  - added run configuration for unit tests

Co-authored-by: Romaric Mourgues <rmourgues@linagora.com>
This commit is contained in:
Anton Shepilov
2023-06-09 14:37:15 +02:00
committed by GitHub
parent f1bf507865
commit dfd25a234a
32 changed files with 3215 additions and 4560 deletions
@@ -16,7 +16,7 @@ describe("the public links feature", () => {
id: string;
name: string;
size: number;
added: string;
added: number;
parent_id: string;
company_id: string;
access_info: AccessInformation;
@@ -56,8 +56,8 @@ describe("the public links feature", () => {
});
afterAll(async () => {
await platform.tearDown();
await platform.app.close();
await platform?.tearDown();
platform = null;
});
const createItem = async (): Promise<DriveFileMockClass> => {
@@ -77,7 +77,7 @@ describe("the public links feature", () => {
let publicFile: DriveFileMockClass;
it("did create the drive item", async done => {
it("did create the drive item", async () => {
const result = await createItem();
publicFile = result;
@@ -85,11 +85,9 @@ describe("the public links feature", () => {
expect(result.name).toEqual("public file");
expect(result.added).toBeDefined();
expect(result.access_info).toBeDefined();
done?.();
});
it("unable to access non public file", async done => {
it("unable to access non public file", async () => {
const res = await platform.app.inject({
method: "GET",
url: `${url}/companies/${publicFile.company_id}/item/${publicFile.id}?public_token=${publicFile.access_info.public?.token}`,
@@ -97,11 +95,9 @@ describe("the public links feature", () => {
});
expect(res.statusCode).toBe(401);
done?.();
});
it("should access public file", async done => {
it("should access public file", async () => {
const res = await e2e_updateDocument(platform, publicFile.id, {
...publicFile,
access_info: {
@@ -124,11 +120,9 @@ describe("the public links feature", () => {
const resPublic = deserialize<DriveItemDetails>(FullDriveInfoMockClass, resPublicRaw.body);
expect(resPublicRaw.statusCode).toBe(200);
expect(resPublic.item?.id).toBe(publicFile.id);
done?.();
});
it("unable to access expired public file link", async done => {
it("unable to access expired public file link", async () => {
await e2e_updateDocument(platform, publicFile.id, {
...publicFile,
access_info: {
@@ -180,11 +174,9 @@ describe("the public links feature", () => {
},
},
});
done?.();
});
it("access public file link with password", async done => {
it("access public file link with password", async () => {
await e2e_updateDocument(platform, publicFile.id, {
...publicFile,
access_info: {
@@ -199,9 +191,7 @@ describe("the public links feature", () => {
let resPublicRaw = await platform.app.inject({
method: "GET",
url: `${url}/companies/${publicFile.company_id}/item/${publicFile.id}?public_token=${
publicFile.access_info.public?.token
}%2B${"abcdef"}`,
url: `${url}/companies/${publicFile.company_id}/item/${publicFile.id}?public_token=${publicFile.access_info.public?.token}%2Babcdef`,
headers: {},
});
let resPublic = deserialize<DriveItemDetails>(FullDriveInfoMockClass, resPublicRaw.body);
@@ -226,7 +216,5 @@ describe("the public links feature", () => {
},
},
});
done?.();
});
});