Skip to content

Commit

Permalink
Merge branch 'feature/PB-35338_WP2-211-Folders-update-local-storage-s…
Browse files Browse the repository at this point in the history
…hould-handle-threshold-period-to-limit-the-number-of-API-request' into 'develop'

PB-35338 WP2-2.11 Folders update local storage should handle threshold period...

See merge request passbolt/passbolt-styleguide!1779
  • Loading branch information
Benj1er committed Sep 18, 2024
2 parents af42600 + c6c3091 commit 5ec1e49
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/shared/models/entity/folder/folderEntity.test.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@
*/
import {v4 as uuidv4} from "uuid";
import {ownerPermissionDto, readPermissionDto, updatePermissionDto} from "../permission/permissionEntity.test.data";
import {defaultPermissionsDtos} from "../permission/permissionCollection.test.data";

export const minimalFolderDto = (data = {}) => ({
name: 'Folder name',
...data
});

export const defaultFolderDto = (data = {}) => {
/**
* Build default folder dto.
* @param {object} data The data to override the default dto.
* @param {Object} [options]
* @param {boolean|integer} [options.withPermissions=0] Add permission default dtos.
* @returns {object}
*/
export const defaultFolderDto = (data = {}, options = {}) => {
const id = data?.id || uuidv4();

return {
const defaultData = {
id: id,
name: "Accounting",
created: "2020-02-01T00:00:00+00:00",
Expand All @@ -33,14 +41,16 @@ export const defaultFolderDto = (data = {}) => {
aco: 'Folder',
aco_foreign_key: id
}),
permissions: [ownerPermissionDto({
aco: 'Folder',
aco_foreign_key: id
})],
folder_parent_id: null,
personal: false,
...data
};

if (!data.permissions && options.withPermissions) {
defaultData.permissions = defaultPermissionsDtos(options.withPermissions, {aco: 'Folder', aco_foreign_key: id});
}

return defaultData;
};

export const folderWithReadPermissionDto = (data = {}) => {
Expand Down

0 comments on commit 5ec1e49

Please sign in to comment.