Primary Issue: TZ Environment Variable Breaking Tests
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 18m47s
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 18m47s
This commit is contained in:
@@ -118,7 +118,8 @@
|
|||||||
"mcp__localerrors__get_project",
|
"mcp__localerrors__get_project",
|
||||||
"mcp__localerrors__get_issue",
|
"mcp__localerrors__get_issue",
|
||||||
"mcp__localerrors__get_event",
|
"mcp__localerrors__get_event",
|
||||||
"mcp__localerrors__list_teams"
|
"mcp__localerrors__list_teams",
|
||||||
|
"WebSearch"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"enabledMcpjsonServers": [
|
"enabledMcpjsonServers": [
|
||||||
|
|||||||
@@ -27,9 +27,13 @@ const defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setupSuccessMocks = () => {
|
const setupSuccessMocks = () => {
|
||||||
|
// The API returns {success, data: {userprofile, token}}, and the mutation extracts .data
|
||||||
const mockAuthResponse = {
|
const mockAuthResponse = {
|
||||||
userprofile: createMockUserProfile({ user: { user_id: '123', email: 'test@example.com' } }),
|
success: true,
|
||||||
token: 'mock-token',
|
data: {
|
||||||
|
userprofile: createMockUserProfile({ user: { user_id: '123', email: 'test@example.com' } }),
|
||||||
|
token: 'mock-token',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
(mockedApiClient.loginUser as Mock).mockResolvedValue(
|
(mockedApiClient.loginUser as Mock).mockResolvedValue(
|
||||||
new Response(JSON.stringify(mockAuthResponse)),
|
new Response(JSON.stringify(mockAuthResponse)),
|
||||||
|
|||||||
@@ -82,7 +82,11 @@ const defaultAuthenticatedProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setupSuccessMocks = () => {
|
const setupSuccessMocks = () => {
|
||||||
const mockAuthResponse = { userprofile: authenticatedProfile, token: 'mock-token' };
|
// The API returns {success, data: {userprofile, token}}, and the mutation extracts .data
|
||||||
|
const mockAuthResponse = {
|
||||||
|
success: true,
|
||||||
|
data: { userprofile: authenticatedProfile, token: 'mock-token' },
|
||||||
|
};
|
||||||
(mockedApiClient.loginUser as Mock).mockResolvedValue(
|
(mockedApiClient.loginUser as Mock).mockResolvedValue(
|
||||||
new Response(JSON.stringify(mockAuthResponse)),
|
new Response(JSON.stringify(mockAuthResponse)),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ describe('API Client', () => {
|
|||||||
.mockResolvedValueOnce({
|
.mockResolvedValueOnce({
|
||||||
ok: true,
|
ok: true,
|
||||||
status: 200,
|
status: 200,
|
||||||
json: () => Promise.resolve({ token: 'new-refreshed-token' }),
|
// The API returns {success, data: {token}} wrapper format
|
||||||
|
json: () => Promise.resolve({ success: true, data: { token: 'new-refreshed-token' } }),
|
||||||
} as Response)
|
} as Response)
|
||||||
.mockResolvedValueOnce({
|
.mockResolvedValueOnce({
|
||||||
ok: true,
|
ok: true,
|
||||||
@@ -218,7 +219,7 @@ describe('API Client', () => {
|
|||||||
localStorage.setItem('authToken', 'expired-token');
|
localStorage.setItem('authToken', 'expired-token');
|
||||||
// Mock the global fetch to return a sequence of responses:
|
// Mock the global fetch to return a sequence of responses:
|
||||||
// 1. 401 Unauthorized (initial API call)
|
// 1. 401 Unauthorized (initial API call)
|
||||||
// 2. 200 OK (token refresh call)
|
// 2. 200 OK (token refresh call) - uses API wrapper format {success, data: {token}}
|
||||||
// 3. 200 OK (retry of the initial API call)
|
// 3. 200 OK (retry of the initial API call)
|
||||||
vi.mocked(global.fetch)
|
vi.mocked(global.fetch)
|
||||||
.mockResolvedValueOnce({
|
.mockResolvedValueOnce({
|
||||||
@@ -229,7 +230,8 @@ describe('API Client', () => {
|
|||||||
.mockResolvedValueOnce({
|
.mockResolvedValueOnce({
|
||||||
ok: true,
|
ok: true,
|
||||||
status: 200,
|
status: 200,
|
||||||
json: () => Promise.resolve({ token: 'new-refreshed-token' }),
|
// The API returns {success, data: {token}} wrapper format
|
||||||
|
json: () => Promise.resolve({ success: true, data: { token: 'new-refreshed-token' } }),
|
||||||
} as Response)
|
} as Response)
|
||||||
.mockResolvedValueOnce({
|
.mockResolvedValueOnce({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
|||||||
@@ -62,12 +62,33 @@ vi.mock('./logger.server', () => ({
|
|||||||
vi.mock('bullmq', () => ({
|
vi.mock('bullmq', () => ({
|
||||||
Worker: mocks.MockWorker,
|
Worker: mocks.MockWorker,
|
||||||
Queue: vi.fn(function () {
|
Queue: vi.fn(function () {
|
||||||
return { add: vi.fn() };
|
return { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) };
|
||||||
}),
|
}),
|
||||||
// Add UnrecoverableError to the mock so it can be used in tests
|
// Add UnrecoverableError to the mock so it can be used in tests
|
||||||
UnrecoverableError: class UnrecoverableError extends Error {},
|
UnrecoverableError: class UnrecoverableError extends Error {},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Mock redis.server to prevent real Redis connection attempts
|
||||||
|
vi.mock('./redis.server', () => ({
|
||||||
|
connection: {
|
||||||
|
on: vi.fn(),
|
||||||
|
quit: vi.fn().mockResolvedValue(undefined),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock queues.server to provide mock queue instances
|
||||||
|
vi.mock('./queues.server', () => ({
|
||||||
|
flyerQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
emailQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
analyticsQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
cleanupQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
weeklyAnalyticsQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
tokenCleanupQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
receiptQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
expiryAlertQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
barcodeQueue: { add: vi.fn(), close: vi.fn().mockResolvedValue(undefined) },
|
||||||
|
}));
|
||||||
|
|
||||||
// Mock flyerProcessingService.server as flyerWorker and cleanupWorker depend on it
|
// Mock flyerProcessingService.server as flyerWorker and cleanupWorker depend on it
|
||||||
vi.mock('./flyerProcessingService.server', () => {
|
vi.mock('./flyerProcessingService.server', () => {
|
||||||
// Mock the constructor to return an object with the mocked methods
|
// Mock the constructor to return an object with the mocked methods
|
||||||
@@ -88,6 +109,67 @@ vi.mock('./flyerDataTransformer', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Mock aiService.server to prevent initialization issues
|
||||||
|
vi.mock('./aiService.server', () => ({
|
||||||
|
aiService: {
|
||||||
|
extractAndValidateData: vi.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock db/index.db to prevent database connections
|
||||||
|
vi.mock('./db/index.db', () => ({
|
||||||
|
personalizationRepo: {},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock flyerAiProcessor.server
|
||||||
|
vi.mock('./flyerAiProcessor.server', () => ({
|
||||||
|
FlyerAiProcessor: vi.fn().mockImplementation(function () {
|
||||||
|
return { processFlyer: vi.fn() };
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock flyerPersistenceService.server
|
||||||
|
vi.mock('./flyerPersistenceService.server', () => ({
|
||||||
|
FlyerPersistenceService: vi.fn().mockImplementation(function () {
|
||||||
|
return { persistFlyerData: vi.fn() };
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock db/connection.db to prevent database connections
|
||||||
|
vi.mock('./db/connection.db', () => ({
|
||||||
|
withTransaction: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock receiptService.server
|
||||||
|
vi.mock('./receiptService.server', () => ({
|
||||||
|
processReceiptJob: vi.fn().mockResolvedValue(undefined),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock expiryService.server
|
||||||
|
vi.mock('./expiryService.server', () => ({
|
||||||
|
processExpiryAlertJob: vi.fn().mockResolvedValue(undefined),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock barcodeService.server
|
||||||
|
vi.mock('./barcodeService.server', () => ({
|
||||||
|
processBarcodeDetectionJob: vi.fn().mockResolvedValue(undefined),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock flyerFileHandler.server
|
||||||
|
vi.mock('./flyerFileHandler.server', () => ({
|
||||||
|
FlyerFileHandler: vi.fn().mockImplementation(function () {
|
||||||
|
return { handleFile: vi.fn() };
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock workerOptions config
|
||||||
|
vi.mock('../config/workerOptions', () => ({
|
||||||
|
defaultWorkerOptions: {
|
||||||
|
lockDuration: 30000,
|
||||||
|
stalledInterval: 30000,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
// Helper to create a mock BullMQ Job object
|
// Helper to create a mock BullMQ Job object
|
||||||
const createMockJob = <T>(data: T): Job<T> => {
|
const createMockJob = <T>(data: T): Job<T> => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user