feat: label reports overview (#11194)

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Shivam Mishra
2025-06-11 14:35:46 +05:30
committed by GitHub
parent c0d9533b3a
commit 35f06f30e7
19 changed files with 1095 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ vi.mock('dashboard/api/summaryReports', () => ({
getInboxReports: vi.fn(),
getAgentReports: vi.fn(),
getTeamReports: vi.fn(),
getLabelReports: vi.fn(),
},
}));
@@ -25,10 +26,12 @@ describe('Summary Reports Store', () => {
inboxSummaryReports: [],
agentSummaryReports: [],
teamSummaryReports: [],
labelSummaryReports: [],
uiFlags: {
isFetchingInboxSummaryReports: false,
isFetchingAgentSummaryReports: false,
isFetchingTeamSummaryReports: false,
isFetchingLabelSummaryReports: false,
},
});
});
@@ -39,6 +42,7 @@ describe('Summary Reports Store', () => {
inboxSummaryReports: [{ id: 1 }],
agentSummaryReports: [{ id: 2 }],
teamSummaryReports: [{ id: 3 }],
labelSummaryReports: [{ id: 4 }],
uiFlags: { isFetchingInboxSummaryReports: true },
};
@@ -54,6 +58,10 @@ describe('Summary Reports Store', () => {
expect(store.getters.getTeamSummaryReports(state)).toEqual([{ id: 3 }]);
});
it('should return label summary reports', () => {
expect(store.getters.getLabelSummaryReports(state)).toEqual([{ id: 4 }]);
});
it('should return UI flags', () => {
expect(store.getters.getUIFlags(state)).toEqual({
isFetchingInboxSummaryReports: true,
@@ -86,6 +94,14 @@ describe('Summary Reports Store', () => {
expect(state.teamSummaryReports).toEqual(data);
});
it('should set label summary report', () => {
const state = { ...initialState };
const data = [{ id: 4 }];
store.mutations.setLabelSummaryReport(state, data);
expect(state.labelSummaryReports).toEqual(data);
});
it('should merge UI flags with existing flags', () => {
const state = {
uiFlags: { flag1: true, flag2: false },
@@ -185,5 +201,29 @@ describe('Summary Reports Store', () => {
});
});
});
describe('fetchLabelSummaryReports', () => {
it('should fetch label reports successfully', async () => {
const params = { labelId: 789 };
const mockResponse = {
data: [{ label_id: 789, label_name: 'Test Label' }],
};
SummaryReportsAPI.getLabelReports.mockResolvedValue(mockResponse);
await store.actions.fetchLabelSummaryReports({ commit }, params);
expect(commit).toHaveBeenCalledWith('setUIFlags', {
isFetchingLabelSummaryReports: true,
});
expect(SummaryReportsAPI.getLabelReports).toHaveBeenCalledWith(params);
expect(commit).toHaveBeenCalledWith('setLabelSummaryReport', [
{ labelId: 789, labelName: 'Test Label' },
]);
expect(commit).toHaveBeenCalledWith('setUIFlags', {
isFetchingLabelSummaryReports: false,
});
});
});
});
});