Skip to content

Commit 8ef703a

Browse files
author
MargeBot
committed
Merge branch 'fix/send-with-error-modals' into 'main'
Fix crashing SendWithErrorModals with only one CTA See merge request web/clients!16844
2 parents f25bef4 + c656f3b commit 8ef703a

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { render } from '@testing-library/react';
2+
3+
import { MIME_TYPES } from '@proton/shared/lib/constants';
4+
import {
5+
ENCRYPTION_PREFERENCES_ERROR_TYPES,
6+
EncryptionPreferencesError,
7+
} from '@proton/shared/lib/mail/encryptionPreferences';
8+
import { PACKAGE_TYPE } from '@proton/shared/lib/mail/mailSettings';
9+
import { veventBuilder } from '@proton/testing/index';
10+
import noop from '@proton/utils/noop';
11+
12+
import { INVITE_ACTION_TYPES } from '../../../interfaces/Invite';
13+
import SendWithErrorsConfirmationModal from './SendWithErrorsConfirmationModal';
14+
15+
const sendPreferencesMap = {
16+
error: new EncryptionPreferencesError(ENCRYPTION_PREFERENCES_ERROR_TYPES.EMAIL_ADDRESS_ERROR, 'error'),
17+
isInternal: false,
18+
encrypt: false,
19+
sign: false,
20+
pgpScheme: PACKAGE_TYPE.SEND_CLEAR,
21+
mimeType: MIME_TYPES.PLAINTEXT,
22+
publicKeys: [],
23+
hasApiKeys: false,
24+
hasPinnedKeys: false,
25+
encryptionDisabled: false,
26+
};
27+
28+
describe('SendWithErrorsConfirmationModal', () => {
29+
it('works with only one CTA', () => {
30+
const vevent = veventBuilder({});
31+
render(
32+
<SendWithErrorsConfirmationModal
33+
sendPreferencesMap={{
34+
'[email protected]': sendPreferencesMap,
35+
}}
36+
inviteActions={{ selfAddress: undefined, type: INVITE_ACTION_TYPES.DECLINE_INVITATION }}
37+
vevent={vevent}
38+
cancelVevent={vevent}
39+
onClose={noop}
40+
onConfirm={noop}
41+
isOpen={true}
42+
/>
43+
);
44+
});
45+
});

applications/calendar/src/app/containers/calendar/confirmationModals/SendWithErrorsConfirmationModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const SendWithErrorsConfirmationModal = ({
124124
onSubmit={handleConfirm}
125125
onClose={onClose}
126126
open={isOpen}
127-
buttons={[submit as JSX.Element, close as JSX.Element]}
127+
buttons={[submit, close].filter(Boolean) as [JSX.Element] | [JSX.Element, JSX.Element]}
128128
>
129129
<div className="mb-4">{warningText}</div>
130130
<ul>{Object.keys(errorMap).map(renderEmailRow)}</ul>

0 commit comments

Comments
 (0)