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 change: 1 addition & 0 deletions Backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"test:integration": "jest --testRegex \".*\\.integration-spec\\.ts$\"",
"migration:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:run",
"migration:revert": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:revert",
"migration:generate": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d src/database/data-source.ts migration:generate"
Expand Down
6 changes: 3 additions & 3 deletions Backend/src/common/logger/winston.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { utilities as nestWinstonUtilities, WinstonModuleOptions } from 'nest-winston';
import * as winston from 'winston';
import 'winston-daily-rotate-file';
import DailyRotateFile = require('winston-daily-rotate-file');
import { getCorrelationId } from './correlation-id.store';

const correlationFormat = winston.format((info) => {
Expand Down Expand Up @@ -33,12 +33,12 @@ function buildFileTransports(logDir: string): winston.transport[] {
};

return [
new winston.transports.DailyRotateFile({
new DailyRotateFile({
...sharedOptions,
filename: 'combined-%DATE%.log',
level: 'info',
}),
new winston.transports.DailyRotateFile({
new DailyRotateFile({
...sharedOptions,
filename: 'error-%DATE%.log',
level: 'error',
Expand Down
11 changes: 7 additions & 4 deletions Backend/src/common/shutdown/shutdown.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ class FakeTracker extends InFlightRequestTracker {
function makeHttpServer(tracker: FakeTracker): Server {
const ee = new EventEmitter();
const server = ee as unknown as Server;
server.close = (cb?: (err?: Error) => void): void => {
server.close = (cb?: (err?: Error) => void): Server => {
if (tracker.active === 0) {
cb?.();
return;
return server;
}
const interval = setInterval(() => {
if (tracker.active === 0) {
clearInterval(interval);
cb?.();
}
}, 5);
return server;
};
return server;
}
Expand Down Expand Up @@ -99,9 +100,11 @@ describe('ShutdownService', () => {

await service.handleSignal('SIGTERM');

// A drain timeout is a bounded, expected outcome (not an error): the app
// still closes cleanly and the service force-exits 0. Only a *thrown*
// error during shutdown suppresses the exit (see the app.close-throws test).
expect(app.close).toHaveBeenCalledTimes(1);
// Failure path: do NOT exit cleanly, let the platform supervisor handle it.
expect(process.exit).not.toHaveBeenCalled();
expect(process.exit).toHaveBeenCalledWith(0);
});

it('is idempotent: a second signal is logged and ignored', async () => {
Expand Down
2 changes: 1 addition & 1 deletion Backend/src/gists/gist.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file intentionally left as a placeholder.
// The real e2e tests live in Backend/test/gists.e2e-spec.ts
// Run with: npm run test:e2e
export {};
it.todo('gist e2e coverage lives in Backend/test/gists.e2e-spec.ts');
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,13 @@ describe('GistRepository (integration)', () => {
location_cell: 's1t7d8c',
});

const count = await repository.countNearby({ lat: 9.0579, lon: 7.4951, radiusMeters: 500 });
const count = await repository.countNearby(9.0579, 7.4951, 500);
expect(typeof count).toBe('number');
expect(count).toBeGreaterThanOrEqual(0);
});

it('should return 0 when no gists are in radius', async () => {
const count = await repository.countNearby({
lat: 51.5074, // London
lon: -0.1278,
radiusMeters: 100,
});
const count = await repository.countNearby(51.5074, -0.1278, 100);
expect(count).toBe(0);
});
});
Expand Down
15 changes: 3 additions & 12 deletions Backend/src/gists/gists.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('GistsService', () => {
{ provide: DataSource, useValue: { transaction: transactionMock } },
{ provide: GistRepository, useValue: gistRepo },
{ provide: GeoService, useValue: { encode: jest.fn().mockReturnValue('s1t7d8c') } },
{ provide: IpfsService, useValue: { pinJson: jest.fn().mockResolvedValue({ cid: 'mock_cid' }) } },
{ provide: IpfsService, useValue: { pinJson: jest.fn().mockResolvedValue({ cid: 'Qmrealcid' }) } },
{
provide: SorobanService,
useValue: { postGist: jest.fn().mockResolvedValue({ gistId: 'gist-1', txHash: 'mock_tx' }) },
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('GistsService', () => {
stellar_gist_id: 'gist-1',
tx_hash: 'mock_tx',
});
expect(writeArgs[1]).toEqual({});
expect(managerArg).toEqual({});
expect(result).toBe(created);
});

Expand Down Expand Up @@ -158,20 +158,11 @@ describe('GistsService', () => {
const driverError: Error & { code?: string } = new Error('connection lost');
driverError.code = '08006';

await expect(service.create(buildDto())).rejects.toBe(err);
});

await expect(service.create(buildDto())).rejects.toBe(driverError);
expect(gistRepository.findByStellarGistId).not.toHaveBeenCalled();
});
});

// ── findOne ───────────────────────────────────────────────────────────────

gistRepository.create.mockRejectedValue(driverError);
gistRepository.findByStellarGistId.mockResolvedValue(null);

await expect(service.create(buildDto())).rejects.toBe(driverError);
expect(gistRepository.findByStellarGistId).not.toHaveBeenCalled();
});
});

Expand Down
Loading