diff --git a/__fixtures__/recipients.js b/__fixtures__/recipients.js new file mode 100644 index 00000000000..9513f86d28f --- /dev/null +++ b/__fixtures__/recipients.js @@ -0,0 +1,3 @@ +export default { + users: [{ label: 'bob', value: { shareType: 0, shareWith: 'bob', userType: 0 } }] +} diff --git a/__mocks__/sdk.js b/__mocks__/sdk.js index 04ca97bb4a1..7338e0b756f 100644 --- a/__mocks__/sdk.js +++ b/__mocks__/sdk.js @@ -6,6 +6,7 @@ import fixtureSharedViaLinksFiles from '../__fixtures__/sharedViaLinkFiles' import fixtureSharedWithMeFiles from '../__fixtures__/sharedWithMeFiles' import fixtureDeletedFiles from '../__fixtures__/deletedFiles' import fixturePublicFiles from '../__fixtures__/publicFiles' +import fixtureRecipients from '../__fixtures__/recipients' export default { files: { @@ -41,6 +42,64 @@ export default { list: path => fixturePublicFiles[path] }, shares: { - getShares: () => new Promise(resolve => resolve()) + getShares: () => Promise.resolve(), + getRecipients, + shareFileWithUser: (path, id, params) => + Promise.resolve({ + shareInfo: { + id: 1, + share_type: 0, + uid_owner: 'alice', // TODO: get user dynamically + displayname_owner: 'alice', // TODO: get user dynamically + permissions: params.permissions, + stime: new Date().getTime(), + expiration: params.expirationDate, + uid_file_owner: 'alice', // TODO: get user dynamically + displayname_file_owner: 'alice', // TODO: get user dynamically + path, + item_type: 'folder', // TODO: get item type dynamically + item_source: 10, + file_source: 10, + file_parent: 6, + file_target: path, + share_with: id, + share_with_displayname: id + } + }), + shareFileWithGroup: () => Promise.resolve(), + updateShare: (id, params) => { + const share = { + shareInfo: { + id, + share_type: 0, + uid_owner: 'alice', // TODO: get user dynamically + displayname_owner: 'alice', // TODO: get user dynamically + permissions: params.permissions, + stime: new Date().getTime(), + uid_file_owner: 'alice', // TODO: get user dynamically + displayname_file_owner: 'alice', // TODO: get user dynamically + path: '/Documents', // TODO: get path dynamically + item_type: 'folder', // TODO: get item type dynamically + item_source: 10, + file_source: 10, + file_parent: 6, + file_target: '/Documents', // TODO: get path dynamically + share_with: 'bob', // TODO: get user dynamically + share_with_displayname: 'bob' // TODO: get user dynamically + } + } + + if (params.expireDate) { + share.shareInfo.expiration = params.expireDate + } + + return Promise.resolve(share) + } } } + +function getRecipients(query) { + const users = fixtureRecipients.users.filter(user => user.label.includes(query)) + + return { exact: { users, groups: [], remotes: [] }, users: [], groups: [], remotes: [] } +} diff --git a/package.json b/package.json index ce738a6cd77..7f6f110fc27 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-typescript": "^8.2.5", "@testing-library/jest-dom": "^5.13.0", + "@testing-library/user-event": "^13.2.1", "@testing-library/vue": "^5.6.2", "@types/cucumber": "^7.0.0", "@types/jest": "^26.0.23", diff --git a/packages/web-app-files/src/components/SideBar/Shares/Collaborators/AutocompleteItem.vue b/packages/web-app-files/src/components/SideBar/Shares/Collaborators/AutocompleteItem.vue index 8ddfb21dd2d..5f3b3b32028 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/Collaborators/AutocompleteItem.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/Collaborators/AutocompleteItem.vue @@ -1,5 +1,9 @@