diff --git a/src/constants/index.ts b/src/constants/index.ts index 00726838d..2564dd3ca 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -565,7 +565,6 @@ export const MAIL_SENSITIVITY_HEADER = { companyConfidential: 'Company-Confidential' } as const; -export const MAIL_SENSITIVITY_HEADER_VALUES = ['Personal', 'Private', 'Company-Confidential']; - export const SENSITIVITY_VALUES = ['Private', 'Company-Confidential'] as const; export const VALID_MAIL_AUTHENTICATION_HEADERS = ['dkim', 'spf', 'dmarc'] as const; +export const CONV_ACTION_CONSTRAINS = '-stdj'; diff --git a/src/store/actions/conv-action.ts b/src/store/actions/conv-action.ts index 8ebb9fecf..54446654a 100644 --- a/src/store/actions/conv-action.ts +++ b/src/store/actions/conv-action.ts @@ -6,6 +6,7 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; import { soapFetch } from '@zextras/carbonio-shell-ui'; import { isNil } from 'lodash'; + import { omitBy } from '../../commons/utils'; import type { ConvActionParameters, @@ -16,8 +17,8 @@ import type { export const convAction = createAsyncThunk( 'convAction', - async ({ ids, operation, parent, tagName }) => { - const { action } = (await soapFetch('ConvAction', { + async ({ ids, operation, parent, tagName, constrains }) => { + const { action } = await soapFetch('ConvAction', { _jsns: 'urn:zimbraMail', action: omitBy( @@ -25,11 +26,12 @@ export const convAction = createAsyncThunk { diff --git a/src/ui-actions/tests/move-conv-msg.test.tsx b/src/ui-actions/tests/move-conv-msg.test.tsx index 023fdc8d9..a68ba56ce 100644 --- a/src/ui-actions/tests/move-conv-msg.test.tsx +++ b/src/ui-actions/tests/move-conv-msg.test.tsx @@ -14,10 +14,17 @@ import { getFolder } from '../../carbonio-ui-commons/store/zustand/folder'; import { createSoapAPIInterceptor } from '../../carbonio-ui-commons/test/mocks/network/msw/create-api-interceptor'; import { populateFoldersStore } from '../../carbonio-ui-commons/test/mocks/store/folders'; import { makeListItemsVisible, setupTest } from '../../carbonio-ui-commons/test/test-setup'; -import { API_REQUEST_STATUS } from '../../constants'; +import { API_REQUEST_STATUS, CONV_ACTION_CONSTRAINS } from '../../constants'; +import { generateConversation } from '../../tests/generators/generateConversation'; import { generateMessage } from '../../tests/generators/generateMessage'; import { generateStore } from '../../tests/generators/store'; -import { MailMessage, MsgActionRequest, MsgActionResponse } from '../../types'; +import { + ConvActionRequest, + ConvActionResponse, + MailMessage, + MsgActionRequest, + MsgActionResponse +} from '../../types'; import MoveConvMessage from '../move-conv-msg'; describe('MoveConvMsg', () => { @@ -224,5 +231,87 @@ describe('MoveConvMsg', () => { expect(requestParameter.action.f).toBeUndefined(); expect(requestParameter.action.tn).toBeUndefined(); }); + + it('should call conv action api with default constrains when user clicks confirm', async () => { + populateFoldersStore({ view: FOLDER_VIEW.conversation }); + + const { children: inboxChildren } = getFolder(FOLDERS.INBOX) ?? {}; + const sourceFolderId = inboxChildren?.[0].id ?? ''; + const destinationFolder = FOLDERS.SENT; + + const conversation = generateConversation({ + folderId: sourceFolderId, + isSingleMessageConversation: false + }); + const msgIdsInConversation = conversation.messages.map((msg) => msg.id); + + const store = generateStore({ + conversations: { + currentFolder: sourceFolderId, + expandedStatus: { + [conversation.id]: API_REQUEST_STATUS.fulfilled + }, + searchedInFolder: {}, + conversations: { + [conversation.id]: conversation + }, + searchRequestStatus: API_REQUEST_STATUS.fulfilled + } + }); + + const interceptor = createSoapAPIInterceptor( + 'ConvAction', + { + action: { + id: conversation.id, + op: 'move' + } + } + ); + + const component = ( + + ); + + const { user } = setupTest(component, { store }); + makeListItemsVisible(); + + const inboxFolderListItem = await screen.findByTestId( + `folder-accordion-item-${destinationFolder}`, + {}, + { timeout: 10000 } + ); + + act(() => { + jest.advanceTimersByTime(1000); + }); + + await act(async () => { + await user.click(inboxFolderListItem); + }); + + const button = screen.getByRole('button', { + name: /Move/ + }); + + await act(async () => { + await user.click(button); + }); + + const requestParameter = await interceptor; + expect(requestParameter.action.id).toBe(msgIdsInConversation.join(',')); + expect(requestParameter.action.op).toBe('move'); + expect(requestParameter.action.l).toBe(destinationFolder); + expect(requestParameter.action.tcon).toBe(CONV_ACTION_CONSTRAINS); + expect(requestParameter.action.tn).toBeUndefined(); + }); }); }); diff --git a/src/views/sidebar/accordion-custom-component.tsx b/src/views/sidebar/accordion-custom-component.tsx index 541ba6e19..9946cd6e1 100644 --- a/src/views/sidebar/accordion-custom-component.tsx +++ b/src/views/sidebar/accordion-custom-component.tsx @@ -37,7 +37,7 @@ import { FOLDERS } from '../../carbonio-ui-commons/constants/folders'; import { isSystemFolder } from '../../carbonio-ui-commons/helpers/folders'; import type { Folder } from '../../carbonio-ui-commons/types/folder'; import type { DragEnterAction, OnDropActionProps } from '../../carbonio-ui-commons/types/sidebar'; -import { LIST_LIMIT } from '../../constants'; +import { CONV_ACTION_CONSTRAINS, LIST_LIMIT } from '../../constants'; import { isDraft, isSpam } from '../../helpers/folders'; import { parseMessageSortingOptions } from '../../helpers/sorting'; import { useAppDispatch } from '../../hooks/redux'; @@ -147,7 +147,8 @@ const AccordionCustomComponent: FC<{ item: Folder }> = ({ item }) => { convAction({ operation: `move`, ids: convMsgsIds, - parent: item.id + parent: item.id, + constrains: CONV_ACTION_CONSTRAINS }) ).then((res) => { if (res.type.includes('fulfilled')) {