🔢 Shared with me filters (#79)
✨ feat: shared with me filters 🐛 Fix try to access the service with init 🌐 feat: shared with me i18n 🌐russian translation --------- Co-authored-by: Anton SHEPILOV <ashepilov@linagora.com>
This commit is contained in:
@@ -171,7 +171,7 @@ describe("the Drive feature", () => {
|
||||
});
|
||||
|
||||
it("did search for an item and check that all the fields for 'shared_with_me' view", async () => {
|
||||
jest.setTimeout(10000);
|
||||
jest.setTimeout(20000);
|
||||
//given:: user uploaded one doc and give permission to another user
|
||||
const oneUser = await TestHelpers.getInstance(platform, true);
|
||||
const anotherUser = await TestHelpers.getInstance(platform, true);
|
||||
@@ -187,7 +187,7 @@ describe("the Drive feature", () => {
|
||||
});
|
||||
await oneUser.updateDocument(doc.id, doc);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
//when:: user search for a doc
|
||||
const searchResponse = await anotherUser.searchDocument({ view: "shared_with_me" });
|
||||
@@ -211,6 +211,34 @@ describe("the Drive feature", () => {
|
||||
expect(actual.shared_by?.first_name).toEqual(oneUser.user.first_name);
|
||||
});
|
||||
|
||||
it("'shared_with_me' shouldn't return files uploaded by me", async () => {
|
||||
jest.setTimeout(20000);
|
||||
//given:: user uploaded one doc and give permission to another user
|
||||
const oneUser = await TestHelpers.getInstance(platform, true);
|
||||
const anotherUser = await TestHelpers.getInstance(platform, true);
|
||||
const doc = await oneUser.uploadRandomFileAndCreateDocument();
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
//give permissions to the file
|
||||
doc.access_info.entities.push({
|
||||
type: "user",
|
||||
id: anotherUser.user.id,
|
||||
level: "read",
|
||||
grantor: null,
|
||||
});
|
||||
await oneUser.updateDocument(doc.id, doc);
|
||||
//another user also uploaded several files
|
||||
await anotherUser.uploadRandomFileAndCreateDocument();
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
//when:: user search for a doc
|
||||
const searchResponse = await anotherUser.sharedWithMeDocuments({});
|
||||
|
||||
//then::
|
||||
expect(searchResponse.entities?.length).toEqual(1);
|
||||
const actual = searchResponse.entities[0];
|
||||
})
|
||||
|
||||
it("did search for an item that doesn't exist", async () => {
|
||||
await createItem();
|
||||
|
||||
|
||||
+12
-10
@@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
import { describe } from "@jest/globals";
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { DriveFileDTOBuilder } from "../../../../../../../src/services/documents/web/dto/drive-file-dto-builder";
|
||||
import { DriveFileDTOBuilder } from "../../../../../../../src/services/documents/services/drive-file-dto-builder";
|
||||
import { ListResult } from "../../../../../../../src/core/platform/framework/api/crud-service";
|
||||
import { DriveFile } from "../../../../../../../src/services/documents/entities/drive-file";
|
||||
import { CompanyExecutionContext } from "../../../../../../../src/services/applications/web/types";
|
||||
@@ -9,13 +9,11 @@ import { UserServiceImpl } from "../../../../../../../src/services/user/services
|
||||
|
||||
describe("Drive File DTO Builder Test", () => {
|
||||
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
|
||||
|
||||
it("The dto object will contain selected fields with the data ", async () => {
|
||||
//given
|
||||
const fields = ["id", "name"];
|
||||
const file = newFile("file_id", "file_name");
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
|
||||
//when
|
||||
|
||||
@@ -37,9 +35,9 @@ describe("Drive File DTO Builder Test", () => {
|
||||
//given
|
||||
const fields = ["id", "name"];
|
||||
const file = newFile("file_id", "file_name", "file_parent_id");
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
|
||||
//when
|
||||
|
||||
let transformedFiles = await subj.build(
|
||||
new ListResult<DriveFile>("drive_files", [file]),
|
||||
context,
|
||||
@@ -56,9 +54,10 @@ describe("Drive File DTO Builder Test", () => {
|
||||
it("When there is no fields set then whole object should be copied", async () => {
|
||||
//given
|
||||
const file = newFile("file_id", "file_name", "file_parent_id");
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
|
||||
|
||||
//when
|
||||
|
||||
let transformedFiles = await subj.build(
|
||||
new ListResult<DriveFile>("drive_files", [file]),
|
||||
context
|
||||
@@ -77,6 +76,8 @@ describe("Drive File DTO Builder Test", () => {
|
||||
//given
|
||||
const file = newFile("file_id", "file_name");
|
||||
let fields = ["id", "name", "unknown_property"];
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
|
||||
|
||||
//when
|
||||
let transformedFiles = await subj.build(
|
||||
@@ -98,8 +99,9 @@ describe("Drive File DTO Builder Test", () => {
|
||||
let file_creator = newUser();
|
||||
const file = newFile("file_id", "file_name", "parent_id", file_creator.id);
|
||||
let fields = ["id", "name", "created_by"];
|
||||
subj.usersService = mock<UserServiceImpl>();
|
||||
subj.usersService.list = jest.fn().mockReturnValue(new ListResult("users", [file_creator]));
|
||||
const usersService = mock<UserServiceImpl>() as UserServiceImpl;
|
||||
const subj = new DriveFileDTOBuilder()
|
||||
subj.fetchUsers = jest.fn().mockReturnValue([file_creator]);
|
||||
|
||||
//when
|
||||
let transformedFiles = await subj.build(
|
||||
@@ -122,8 +124,8 @@ describe("Drive File DTO Builder Test", () => {
|
||||
let file_shared_by = newUser();
|
||||
const file = newFile("file_id", "file_name", "parent_id", null, file_shared_by.id);
|
||||
let fields = ["id", "name", "shared_by"];
|
||||
subj.usersService = mock<UserServiceImpl>();
|
||||
subj.usersService.list = jest.fn().mockReturnValue(new ListResult("users", [file_shared_by]));
|
||||
const subj = new DriveFileDTOBuilder();
|
||||
subj.fetchUsers = jest.fn().mockReturnValue([file_shared_by]);
|
||||
|
||||
//when
|
||||
let transformedFiles = await subj.build(
|
||||
|
||||
Reference in New Issue
Block a user