🐛 User is not able to delete or move files that was share with him (#392)

This commit is contained in:
Anton Shepilov
2024-02-29 10:43:39 +01:00
committed by GitHub
parent 4f372adddc
commit cb3dcb13ca
6 changed files with 38 additions and 38 deletions
@@ -366,5 +366,13 @@ export default class UserApi {
return deserialize<UserQuota>(UserQuotaMockClass, response.body);
}
async delete(id: string) {
return await this.platform.app.inject({
method: "DELETE",
url: `${UserApi.DOC_URL}/companies/${this.platform.workspace.company_id}/item/${id}`,
headers: { "authorization": `Bearer ${this.jwt}` },
});
}
}
@@ -6,7 +6,6 @@ import UserApi from "../common/user-api";
describe("The Documents Browser Window and API", () => {
let platform: TestPlatform;
let currentUser: UserApi;
let dbService: TestDbService;
beforeEach(async () => {
platform = await init({
@@ -27,7 +26,6 @@ describe("The Documents Browser Window and API", () => {
],
});
currentUser = await UserApi.getInstance(platform);
dbService = await TestDbService.getInstance(platform, true);
});
afterAll(async () => {
@@ -130,7 +128,6 @@ describe("The Documents Browser Window and API", () => {
});
it("Should return ALL the files that was share by user at one", async () => {
const sharedWIthMeFolder = "shared_with_me";
const oneUser = await UserApi.getInstance(platform, true, {companyRole: "admin"});
const anotherUser = await UserApi.getInstance(platform, true, {companyRole: "admin"});
@@ -152,6 +149,27 @@ describe("The Documents Browser Window and API", () => {
//then file become searchable
expect((await anotherUser.browseDocuments("shared_with_me", {pagination: {limitStr: 100}})).children).toHaveLength(1);
});
it("User should be able to delete file that was shared with him with right permissions", async () => {
const oneUser = await UserApi.getInstance(platform, true, {companyRole: "admin"});
const anotherUser = await UserApi.getInstance(platform, true, {companyRole: "admin"});
let files = await oneUser.uploadAllFilesOneByOne("user_" + oneUser.user.id);
await new Promise(r => setTimeout(r, 5000));
let toDeleteDoc = files[2];
toDeleteDoc.access_info.entities.push({
type: "user",
id: anotherUser.user.id,
level: "manage",
grantor: null,
});
await oneUser.updateDocument(toDeleteDoc.id, toDeleteDoc);
const response = await anotherUser.delete(toDeleteDoc.id);
expect(response.statusCode).toBe(200);
});
});
});