mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Implement granularity and date range filtering on insights (#14841)
This commit is contained in:
committed by
GitHub
parent
5ff073bd7b
commit
28596a633e
@@ -1,3 +1,5 @@
|
||||
import type { InsightsDateRange } from '@n8n/api-types';
|
||||
|
||||
import { Telemetry } from '@/telemetry';
|
||||
import { mockInstance } from '@test/mocking';
|
||||
|
||||
@@ -11,6 +13,7 @@ let agents: Record<string, SuperAgentTest> = {};
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['insights', 'license', 'auth'],
|
||||
enabledFeatures: ['feat:insights:viewSummary', 'feat:insights:viewDashboard'],
|
||||
quotas: { 'quota:insights:maxHistoryDays': 365 },
|
||||
});
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -49,6 +52,54 @@ describe('GET /insights routes return 403 for dashboard routes when summary lice
|
||||
);
|
||||
});
|
||||
|
||||
describe('GET /insights routes return 403 if date range outside license limits', () => {
|
||||
beforeAll(() => {
|
||||
testServer.license.setDefaults({ quotas: { 'quota:insights:maxHistoryDays': 3 } });
|
||||
});
|
||||
|
||||
test('Call should throw forbidden for default week insights', async () => {
|
||||
const authAgent = agents.admin;
|
||||
await authAgent.get('/insights/summary').expect(403);
|
||||
await authAgent.get('/insights/by-time').expect(403);
|
||||
await authAgent.get('/insights/by-workflow').expect(403);
|
||||
});
|
||||
|
||||
test('Call should throw forbidden for daily data without viewHourlyData enabled', async () => {
|
||||
const authAgent = agents.admin;
|
||||
await authAgent.get('/insights/summary?dateRange=day').expect(403);
|
||||
await authAgent.get('/insights/by-time?dateRange=day').expect(403);
|
||||
await authAgent.get('/insights/by-workflow?dateRange=day').expect(403);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /insights routes return 200 if date range inside license limits', () => {
|
||||
beforeAll(() => {
|
||||
testServer.license.setDefaults({
|
||||
features: [
|
||||
'feat:insights:viewSummary',
|
||||
'feat:insights:viewDashboard',
|
||||
'feat:insights:viewHourlyData',
|
||||
],
|
||||
quotas: { 'quota:insights:maxHistoryDays': 365 },
|
||||
});
|
||||
});
|
||||
|
||||
test.each<InsightsDateRange['key']>([
|
||||
'day',
|
||||
'week',
|
||||
'2weeks',
|
||||
'month',
|
||||
'quarter',
|
||||
'6months',
|
||||
'year',
|
||||
])('Call should work for date range %s', async (dateRange) => {
|
||||
const authAgent = agents.admin;
|
||||
await authAgent.get(`/insights/summary?dateRange=${dateRange}`).expect(200);
|
||||
await authAgent.get(`/insights/by-time?dateRange=${dateRange}`).expect(200);
|
||||
await authAgent.get(`/insights/by-workflow?dateRange=${dateRange}`).expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /insights/by-workflow', () => {
|
||||
beforeAll(() => {
|
||||
testServer.license.setDefaults({
|
||||
|
||||
Reference in New Issue
Block a user