Compare commits

...

3 Commits

Author SHA1 Message Date
Gitea Actions
b61a00003a ci: Bump version to 0.2.35 [skip ci] 2025-12-30 09:16:46 +05:00
52dba6f890 moar!
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Has been cancelled
2025-12-29 20:16:02 -08:00
4242678aab fix unit tests 2025-12-29 20:08:01 -08:00
5 changed files with 19 additions and 13 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "flyer-crawler",
"version": "0.2.34",
"version": "0.2.35",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "flyer-crawler",
"version": "0.2.34",
"version": "0.2.35",
"dependencies": {
"@bull-board/api": "^6.14.2",
"@bull-board/express": "^6.14.2",

View File

@@ -1,7 +1,7 @@
{
"name": "flyer-crawler",
"private": true,
"version": "0.2.34",
"version": "0.2.35",
"type": "module",
"scripts": {
"dev": "concurrently \"npm:start:dev\" \"vite\"",

View File

@@ -1,3 +1,4 @@
// src/services/analyticsService.server.test.ts
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { AnalyticsService } from './analyticsService.server';
import { logger } from './logger.server';
@@ -130,13 +131,14 @@ describe('AnalyticsService', () => {
// Get the promise from the service method.
const promise = service.processWeeklyReportJob(job);
// Capture the expectation promise BEFORE triggering the rejection.
const expectation = expect(promise).rejects.toThrow('Processing failed');
// Advance timers to trigger the part of the code that throws.
await vi.advanceTimersByTimeAsync(30000);
// Now, assert that the promise rejects as expected.
// This structure avoids an unhandled promise rejection that can occur
// when awaiting a rejecting promise inside a helper function without a try/catch.
await expect(promise).rejects.toThrow('Processing failed');
// Await the expectation to ensure assertions ran.
await expectation;
// Verify the side effect (error logging) after the rejection is confirmed.
expect(mockLoggerInstance.error).toHaveBeenCalledWith(

View File

@@ -148,11 +148,11 @@ describe('AuthService', () => {
expect(result).toEqual({
newUserProfile: mockUserProfile,
accessToken: 'access-token',
refreshToken: 'mocked-random-string',
refreshToken: 'mocked_random_id',
});
expect(userRepo.saveRefreshToken).toHaveBeenCalledWith(
'user-123',
'mocked-random-string',
'mocked_random_id',
reqLog,
);
});
@@ -178,7 +178,7 @@ describe('AuthService', () => {
);
expect(result).toEqual({
accessToken: 'access-token',
refreshToken: 'mocked-random-string',
refreshToken: 'mocked_random_id',
});
});
});
@@ -218,10 +218,10 @@ describe('AuthService', () => {
);
expect(sendPasswordResetEmail).toHaveBeenCalledWith(
'test@example.com',
expect.stringContaining('/reset-password/mocked-random-string'),
expect.stringContaining('/reset-password/mocked_random_id'),
reqLog,
);
expect(result).toBe('mocked-random-string');
expect(result).toBe('mocked_random_id');
});
it('should log warning and return undefined for non-existent user', async () => {

View File

@@ -122,7 +122,7 @@ afterEach(cleanup);
// when it's promisified. The standard util.promisify doesn't work on a simple vi.fn() mock.
vi.mock('util', async (importOriginal) => {
const actual = await importOriginal<typeof import('util')>();
return {
const mocked = {
...actual,
promisify: (fn: Function) => {
return (...args: any[]) => {
@@ -140,6 +140,10 @@ vi.mock('util', async (importOriginal) => {
};
},
};
return {
...mocked,
default: mocked,
};
});
// Mock 'jsonwebtoken'. The `default` key is crucial because the code under test