feat: allow configuring attachment upload limit (#12835)
## Summary - add a configurable MAXIMUM_FILE_UPLOAD_SIZE installation setting and surface it through super admin and global config payloads - apply the configurable limit to attachment validations and shared upload helpers on dashboard and widget - introduce a reusable helper with unit tests for parsing the limit and extend attachment specs for configurability ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_6912644786b08326bc8dee9401af6d0a) --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: iamsivin <iamsivin@gmail.com>
This commit is contained in:
@@ -12,7 +12,11 @@ vi.mock('dashboard/composables', () => ({
|
||||
}));
|
||||
vi.mock('vue-i18n');
|
||||
vi.mock('activestorage');
|
||||
vi.mock('shared/helpers/FileHelper');
|
||||
vi.mock('shared/helpers/FileHelper', () => ({
|
||||
checkFileSizeLimit: vi.fn(),
|
||||
resolveMaximumFileUploadSize: vi.fn(value => Number(value) || 40),
|
||||
DEFAULT_MAXIMUM_FILE_UPLOAD_SIZE: 40,
|
||||
}));
|
||||
vi.mock('@chatwoot/utils');
|
||||
|
||||
describe('useFileUpload', () => {
|
||||
@@ -36,7 +40,9 @@ describe('useFileUpload', () => {
|
||||
getCurrentAccountId: { value: '123' },
|
||||
getCurrentUser: { value: { access_token: 'test-token' } },
|
||||
getSelectedChat: { value: { id: '456' } },
|
||||
'globalConfig/get': { value: { directUploadsEnabled: true } },
|
||||
'globalConfig/get': {
|
||||
value: { directUploadsEnabled: true, maximumFileUploadSize: 40 },
|
||||
},
|
||||
};
|
||||
return getterMap[getter];
|
||||
});
|
||||
@@ -86,7 +92,9 @@ describe('useFileUpload', () => {
|
||||
getCurrentAccountId: { value: '123' },
|
||||
getCurrentUser: { value: { access_token: 'test-token' } },
|
||||
getSelectedChat: { value: { id: '456' } },
|
||||
'globalConfig/get': { value: { directUploadsEnabled: false } },
|
||||
'globalConfig/get': {
|
||||
value: { directUploadsEnabled: false, maximumFileUploadSize: 40 },
|
||||
},
|
||||
};
|
||||
return getterMap[getter];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user