mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 11:08:04 +00:00 
			
		
		
		
	 c35edc9c49
			
		
	
	c35edc9c49
	
	
	
		
			
			# Pull Request Template ## Description This PR includes, 1. **Sort Accounts List** – Orders the accounts list alphabetically for better organization. 2. **Add Missing Translations in Automation** – Includes missing translations for actions, events, and conditions dropdown. 3. **Fix Missing Translation in Macros** – Adds missing translations in the macros action select dropdown. 4. Translate "Automation System" Username – Ensures the "Automation System" username is properly translated. Fixes: https://linear.app/chatwoot/issue/CW-4198/issues-[converso] ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
		
			
				
	
	
		
			77 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import {
 | |
|   emptyMacro,
 | |
|   resolveActionName,
 | |
|   resolveLabels,
 | |
|   resolveTeamIds,
 | |
|   getFileName,
 | |
|   resolveAgents,
 | |
| } from '../../routes/dashboard/settings/macros/macroHelper';
 | |
| import { MACRO_ACTION_TYPES } from '../../routes/dashboard/settings/macros/constants';
 | |
| import { teams, labels, files, agents } from './macrosFixtures';
 | |
| 
 | |
| describe('#emptyMacro', () => {
 | |
|   const defaultMacro = {
 | |
|     name: '',
 | |
|     actions: [
 | |
|       {
 | |
|         action_name: 'assign_team',
 | |
|         action_params: [],
 | |
|       },
 | |
|     ],
 | |
|     visibility: 'global',
 | |
|   };
 | |
|   it('returns the default macro', () => {
 | |
|     expect(emptyMacro).toEqual(defaultMacro);
 | |
|   });
 | |
| });
 | |
| 
 | |
| describe('#resolveActionName', () => {
 | |
|   it('resolve action name from key and return the correct label', () => {
 | |
|     expect(resolveActionName(MACRO_ACTION_TYPES[0].key)).toEqual(
 | |
|       MACRO_ACTION_TYPES[0].label
 | |
|     );
 | |
|     expect(resolveActionName(MACRO_ACTION_TYPES[1].key)).toEqual(
 | |
|       MACRO_ACTION_TYPES[1].label
 | |
|     );
 | |
|     expect(resolveActionName(MACRO_ACTION_TYPES[1].key)).not.toEqual(
 | |
|       MACRO_ACTION_TYPES[0].label
 | |
|     );
 | |
|     expect(resolveActionName('change_priority')).toEqual('CHANGE_PRIORITY'); // Translated
 | |
|   });
 | |
| });
 | |
| 
 | |
| describe('#resolveTeamIds', () => {
 | |
|   it('resolves team names from ids, and returns a joined string', () => {
 | |
|     const resolvedTeams = '⚙️ sales team, 🤷♂️ fayaz';
 | |
|     expect(resolveTeamIds(teams, [1, 2])).toEqual(resolvedTeams);
 | |
|   });
 | |
| });
 | |
| 
 | |
| describe('#resolveLabels', () => {
 | |
|   it('resolves labels names from ids and returns a joined string', () => {
 | |
|     const resolvedLabels = 'sales, billing';
 | |
|     expect(resolveLabels(labels, ['sales', 'billing'])).toEqual(resolvedLabels);
 | |
|   });
 | |
| });
 | |
| 
 | |
| describe('#resolveAgents', () => {
 | |
|   it('resolves agents names from ids and returns a joined string', () => {
 | |
|     const resolvedAgents = 'John Doe';
 | |
|     expect(resolveAgents(agents, [1])).toEqual(resolvedAgents);
 | |
|   });
 | |
| });
 | |
| 
 | |
| describe('#getFileName', () => {
 | |
|   it('returns the correct file name from the list of files', () => {
 | |
|     expect(getFileName(files[0].blob_id, 'send_attachment', files)).toEqual(
 | |
|       files[0].filename
 | |
|     );
 | |
|     expect(getFileName(files[1].blob_id, 'send_attachment', files)).toEqual(
 | |
|       files[1].filename
 | |
|     );
 | |
|     expect(getFileName(files[0].blob_id, 'wrong_action', files)).toEqual('');
 | |
|     expect(getFileName(null, 'send_attachment', files)).toEqual('');
 | |
|     expect(getFileName(files[0].blob_id, 'send_attachment', [])).toEqual('');
 | |
|   });
 | |
| });
 |