✨ Share with me endpoint (#77)
* 🛠️ remove babel from dependencies * 🛠️ removes some of the redundant dependencies + versions update * ✨ separate endpoint for "shared with me"
This commit is contained in:
@@ -73,11 +73,11 @@ export default class TestHelpers {
|
||||
|
||||
const filesUploadRaw = await this.platform.app.inject({
|
||||
method: "POST",
|
||||
url: `${url}/companies/${this.platform.workspace.company_id}/files?thumbnail_sync=1`,
|
||||
url: `${url}/companies/${this.platform.workspace.company_id}/files?thumbnail_sync=0`,
|
||||
...form,
|
||||
});
|
||||
|
||||
const filesUpload: ResourceUpdateResponse<File> = deserialize(
|
||||
const filesUpload: ResourceUpdateResponse<File> = deserialize<ResourceUpdateResponse<File>>(
|
||||
ResourceUpdateResponse,
|
||||
filesUploadRaw.body,
|
||||
);
|
||||
@@ -188,5 +188,22 @@ export default class TestHelpers {
|
||||
response.body)
|
||||
};
|
||||
|
||||
async sharedWithMeDocuments (
|
||||
payload: Record<string, any>
|
||||
){
|
||||
const response = await this.platform.app.inject({
|
||||
method: "POST",
|
||||
url: `${TestHelpers.DOC_URL}/companies/${this.platform.workspace.company_id}/shared-with-me`,
|
||||
headers: {
|
||||
authorization: `Bearer ${this.jwt}`,
|
||||
},
|
||||
payload,
|
||||
});
|
||||
|
||||
return deserialize<SearchResultMockClass>(
|
||||
SearchResultMockClass,
|
||||
response.body)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ describe("the Drive feature", () => {
|
||||
});
|
||||
currentUser = await TestHelpers.getInstance(platform);
|
||||
dbService = await TestDbService.getInstance(platform, true);
|
||||
});
|
||||
}, 300000000);
|
||||
|
||||
afterAll(async () => {
|
||||
await platform?.tearDown();
|
||||
@@ -294,7 +294,6 @@ describe("the Drive feature", () => {
|
||||
});
|
||||
|
||||
it("did search a file shared by another user", async () => {
|
||||
jest.setTimeout(30000);
|
||||
//given:
|
||||
const oneUser = await TestHelpers.getInstance(platform, true);
|
||||
const anotherUser = await TestHelpers.getInstance(platform, true);
|
||||
@@ -304,7 +303,7 @@ describe("the Drive feature", () => {
|
||||
await new Promise(r => setTimeout(r, 5000));
|
||||
|
||||
//then:: files are not searchable for user without permissions
|
||||
expect((await anotherUser.searchDocument({})).entities).toHaveLength(0);
|
||||
expect((await anotherUser.sharedWithMeDocuments({})).entities).toHaveLength(0);
|
||||
|
||||
//and searchable for user that have
|
||||
expect((await oneUser.searchDocument({})).entities).toHaveLength(TestHelpers.ALL_FILES.length);
|
||||
@@ -320,8 +319,8 @@ describe("the Drive feature", () => {
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
|
||||
//then file become searchable
|
||||
expect((await anotherUser.searchDocument({})).entities).toHaveLength(1);
|
||||
});
|
||||
expect((await anotherUser.sharedWithMeDocuments({})).entities).toHaveLength(1);
|
||||
}, 30000000);
|
||||
|
||||
it("did search a file by file owner", async () => {
|
||||
jest.setTimeout(30000);
|
||||
@@ -387,7 +386,6 @@ describe("the Drive feature", () => {
|
||||
});
|
||||
|
||||
it("did search order by name", async () => {
|
||||
jest.setTimeout(10000);
|
||||
const user = await TestHelpers.getInstance(platform, true);
|
||||
// given:: all the sample files uploaded and documents for them created
|
||||
await user.uploadAllFilesAndCreateDocuments();
|
||||
@@ -404,7 +402,7 @@ describe("the Drive feature", () => {
|
||||
|
||||
//then all the files are sorted properly by name
|
||||
expect(documents.entities.map(e => e.name)).toEqual(TestHelpers.ALL_FILES.sort());
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
it("did search order by name desc", async () => {
|
||||
jest.setTimeout(10000);
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("The Tag feature", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const tagResult: ResourceCreateResponse<Tag> = deserialize(
|
||||
const tagResult: ResourceCreateResponse<Tag> = deserialize<ResourceCreateResponse<Tag>>(
|
||||
ResourceCreateResponse,
|
||||
createTag.body,
|
||||
);
|
||||
@@ -98,7 +98,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(createTag.statusCode).toBe(401);
|
||||
|
||||
const tagResult: ResourceCreateResponse<Tag> = deserialize(
|
||||
const tagResult: ResourceCreateResponse<Tag> = deserialize<ResourceCreateResponse<Tag>>(
|
||||
ResourceCreateResponse,
|
||||
createTag.body,
|
||||
);
|
||||
@@ -121,7 +121,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(getTag.statusCode).toBe(200);
|
||||
|
||||
const getResult: ResourceGetResponse<Tag> = deserialize(ResourceGetResponse, getTag.body);
|
||||
const getResult: ResourceGetResponse<Tag> = deserialize<ResourceGetResponse<Tag>>(ResourceGetResponse, getTag.body);
|
||||
expect(getResult.resource).toBeDefined();
|
||||
expect(getResult.resource.name).toBe("test0");
|
||||
expect(getResult.resource.colour).toBe("#000000");
|
||||
@@ -144,7 +144,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(getTag.statusCode).toBe(200);
|
||||
|
||||
const getResult: ResourceGetResponse<Tag> = deserialize(ResourceGetResponse, getTag.body);
|
||||
const getResult: ResourceGetResponse<Tag> = deserialize<ResourceGetResponse<Tag>>(ResourceGetResponse, getTag.body);
|
||||
expect(getResult.resource).toBe(null);
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(updateTag.statusCode).toBe(201);
|
||||
|
||||
const tagUpdatedResult: ResourceCreateResponse<Tag> = deserialize(
|
||||
const tagUpdatedResult: ResourceCreateResponse<Tag> = deserialize<ResourceCreateResponse<Tag>>(
|
||||
ResourceCreateResponse,
|
||||
updateTag.body,
|
||||
);
|
||||
@@ -210,7 +210,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(createTag.statusCode).toBe(401);
|
||||
|
||||
const tagResult: ResourceCreateResponse<Tag> = deserialize(
|
||||
const tagResult: ResourceCreateResponse<any> = deserialize(
|
||||
ResourceCreateResponse,
|
||||
createTag.body,
|
||||
);
|
||||
@@ -236,7 +236,7 @@ describe("The Tag feature", () => {
|
||||
});
|
||||
expect(listTag.statusCode).toBe(200);
|
||||
|
||||
const tagResult: ResourceListResponse<Tag> = deserialize(ResourceListResponse, listTag.body);
|
||||
const tagResult: ResourceListResponse<any> = deserialize(ResourceListResponse, listTag.body);
|
||||
expect(tagResult.resources).toBeDefined();
|
||||
for (const tag of tagResult.resources) {
|
||||
expect(tag.name).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user