mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 11:08:04 +00:00 
			
		
		
		
	 9de8c27368
			
		
	
	9de8c27368
	
	
	
		
			
			Due to the pattern `**/specs/*.spec.js` defined in CircleCI, none of the frontend spec in the folders such as `specs/<domain-name>/getters.spec.js` were not executed in Circle CI. This PR fixes the issue, along with the following changes: - Use vitest instead of jest - Remove jest dependancies - Update tests to work with vitest --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
		
			
				
	
	
		
			105 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import SLAReportsAPI from '../slaReports';
 | |
| import ApiClient from '../ApiClient';
 | |
| 
 | |
| describe('#SLAReports API', () => {
 | |
|   it('creates correct instance', () => {
 | |
|     expect(SLAReportsAPI).toBeInstanceOf(ApiClient);
 | |
|     expect(SLAReportsAPI.apiVersion).toBe('/api/v1');
 | |
|     expect(SLAReportsAPI).toHaveProperty('get');
 | |
|     expect(SLAReportsAPI).toHaveProperty('getMetrics');
 | |
|   });
 | |
| 
 | |
|   describe('API calls', () => {
 | |
|     const originalAxios = window.axios;
 | |
|     const axiosMock = {
 | |
|       post: vi.fn(() => Promise.resolve()),
 | |
|       get: vi.fn(() => Promise.resolve()),
 | |
|       patch: vi.fn(() => Promise.resolve()),
 | |
|       delete: vi.fn(() => Promise.resolve()),
 | |
|     };
 | |
| 
 | |
|     beforeEach(() => {
 | |
|       window.axios = axiosMock;
 | |
|     });
 | |
| 
 | |
|     afterEach(() => {
 | |
|       window.axios = originalAxios;
 | |
|     });
 | |
| 
 | |
|     it('#get', () => {
 | |
|       SLAReportsAPI.get({
 | |
|         page: 1,
 | |
|         from: 1622485800,
 | |
|         to: 1623695400,
 | |
|         assigned_agent_id: 1,
 | |
|         inbox_id: 1,
 | |
|         team_id: 1,
 | |
|         sla_policy_id: 1,
 | |
|         label_list: ['label1'],
 | |
|       });
 | |
|       expect(axiosMock.get).toHaveBeenCalledWith('/api/v1/applied_slas', {
 | |
|         params: {
 | |
|           page: 1,
 | |
|           since: 1622485800,
 | |
|           until: 1623695400,
 | |
|           assigned_agent_id: 1,
 | |
|           inbox_id: 1,
 | |
|           team_id: 1,
 | |
|           sla_policy_id: 1,
 | |
|           label_list: ['label1'],
 | |
|         },
 | |
|       });
 | |
|     });
 | |
|     it('#getMetrics', () => {
 | |
|       SLAReportsAPI.getMetrics({
 | |
|         from: 1622485800,
 | |
|         to: 1623695400,
 | |
|         assigned_agent_id: 1,
 | |
|         inbox_id: 1,
 | |
|         team_id: 1,
 | |
|         sla_policy_id: 1,
 | |
|         label_list: ['label1'],
 | |
|       });
 | |
|       expect(axiosMock.get).toHaveBeenCalledWith(
 | |
|         '/api/v1/applied_slas/metrics',
 | |
|         {
 | |
|           params: {
 | |
|             since: 1622485800,
 | |
|             until: 1623695400,
 | |
|             assigned_agent_id: 1,
 | |
|             inbox_id: 1,
 | |
|             team_id: 1,
 | |
|             sla_policy_id: 1,
 | |
|             label_list: ['label1'],
 | |
|           },
 | |
|         }
 | |
|       );
 | |
|     });
 | |
|     it('#download', () => {
 | |
|       SLAReportsAPI.download({
 | |
|         from: 1622485800,
 | |
|         to: 1623695400,
 | |
|         assigned_agent_id: 1,
 | |
|         inbox_id: 1,
 | |
|         team_id: 1,
 | |
|         sla_policy_id: 1,
 | |
|         label_list: ['label1'],
 | |
|       });
 | |
|       expect(axiosMock.get).toHaveBeenCalledWith(
 | |
|         '/api/v1/applied_slas/download',
 | |
|         {
 | |
|           params: {
 | |
|             since: 1622485800,
 | |
|             until: 1623695400,
 | |
|             assigned_agent_id: 1,
 | |
|             inbox_id: 1,
 | |
|             team_id: 1,
 | |
|             sla_policy_id: 1,
 | |
|             label_list: ['label1'],
 | |
|           },
 | |
|         }
 | |
|       );
 | |
|     });
 | |
|   });
 | |
| });
 |