Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,168 changes: 1,139 additions & 29 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"pg": "^8.14.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"sqlite3": "^5.1.7",
"starknet": "^6.24.1",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.21"
Expand Down
9 changes: 9 additions & 0 deletions src/analytics/analytics-breakdown.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import { AnalyticsModule } from './analytics.module';
import { AnalyticsEvent } from './entities/analytics-event.entity';
import { TimeFilterModule } from '../timefilter/timefilter.module';
import { AnalyticsController } from './analytics.controller';

Check failure on line 10 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'AnalyticsController' is defined but never used
import { AnalyticsService } from './providers/analytics.service';

Check failure on line 11 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'AnalyticsService' is defined but never used
import { AnalyticsExportService } from './providers/analytics-export.service';

Check failure on line 12 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'AnalyticsExportService' is defined but never used
import { AnalyticsBreakdownService } from './providers/analytics-breakdown.service';

Check failure on line 13 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'AnalyticsBreakdownService' is defined but never used

describe('Analytics Breakdown Integration', () => {
let app: INestApplication;
Expand Down Expand Up @@ -34,6 +38,11 @@
);
});

const mockAnalyticsBreakdownService = {

Check failure on line 41 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

'mockAnalyticsBreakdownService' is assigned a value but never used
getBreakdown: jest.fn(),
};


beforeEach(async () => {
// Clear database before each test
await analyticsRepository.clear();
Expand Down Expand Up @@ -80,7 +89,7 @@
});

describe('GET /analytics/breakdown', () => {
it('should return analytics breakdown by event type', async () => {

Check warning on line 92 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
const response = await request(app.getHttpServer())
.get('/analytics/breakdown')
.expect(200);
Expand All @@ -89,19 +98,19 @@
expect(response.body).toHaveProperty('totalEvents');
expect(response.body).toHaveProperty('uniqueEventTypes');
expect(response.body).toHaveProperty('dateRange');

Check failure on line 101 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe member access .totalEvents on an `any` value
expect(response.body.totalEvents).toBe(5);

Check failure on line 102 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe member access .uniqueEventTypes on an `any` value
expect(response.body.uniqueEventTypes).toBe(4);

Check failure on line 104 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe member access .breakdown on an `any` value

Check failure on line 104 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe assignment of an `any` value
const breakdown = response.body.breakdown;
expect(Array.isArray(breakdown)).toBe(true);

Check failure on line 106 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe member access .length on an `any` value
expect(breakdown.length).toBe(4);

// Check that event types are ordered by count descending

Check warning on line 109 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `number | bigint`
expect(breakdown[0].count).toBeGreaterThanOrEqual(breakdown[1].count);
});

it('should include friendly display names', async () => {

Check warning on line 113 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
const response = await request(app.getHttpServer())
.get('/analytics/breakdown')
.expect(200);
Expand All @@ -124,7 +133,7 @@
.expect(200);

const breakdown = response.body.breakdown;
const totalEvents = response.body.totalEvents;

Check warning on line 136 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`

breakdown.forEach(item => {
const expectedPercentage = Math.round((item.count / totalEvents) * 100 * 10) / 10;
Expand All @@ -146,7 +155,7 @@
.expect(200);

// Should only include events from Jan 1-2
expect(response.body.totalEvents).toBe(3); // question_view (2) + answer_submit (1)

Check warning on line 158 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
});

it('should filter by user ID', async () => {
Expand All @@ -159,7 +168,7 @@

// Should only include events for user 123
expect(response.body.totalEvents).toBe(3); // question_view, answer_submit, streak_milestone
});

Check warning on line 171 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`

it('should handle empty results', async () => {
const response = await request(app.getHttpServer())
Expand All @@ -171,7 +180,7 @@

expect(response.body.totalEvents).toBe(0);
expect(response.body.uniqueEventTypes).toBe(0);
expect(response.body.breakdown).toEqual([]);

Check warning on line 183 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
});

it('should return 400 for invalid date format', async () => {
Expand All @@ -184,7 +193,7 @@
});
});

describe('GET /analytics/breakdown/top', () => {

Check warning on line 196 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
it('should return top event types with default limit', async () => {
const response = await request(app.getHttpServer())
.get('/analytics/breakdown/top')
Expand All @@ -195,7 +204,7 @@
});

it('should return top event types with custom limit', async () => {
const response = await request(app.getHttpServer())

Check warning on line 207 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
.get('/analytics/breakdown/top')
.query({ limit: 3 })
.expect(200);
Expand All @@ -204,7 +213,7 @@
});

it('should clamp limit to minimum value', async () => {
const response = await request(app.getHttpServer())

Check warning on line 216 in src/analytics/analytics-breakdown.integration.spec.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Unsafe argument of type `any` assigned to a parameter of type `App`
.get('/analytics/breakdown/top')
.query({ limit: 0 })
.expect(200);
Expand Down
284 changes: 0 additions & 284 deletions src/analytics/analytics.controller.breakdown.spec.ts

This file was deleted.

Loading
Loading