removed cron job that made rentals active. Now whether or not the rental is active is determined on the fly

This commit is contained in:
jackiettran
2026-01-02 17:08:49 -05:00
parent bc01c818aa
commit 4209dcc8fc
17 changed files with 142 additions and 162 deletions

View File

@@ -790,11 +790,15 @@ describe('Rentals Routes', () => {
});
describe('POST /:id/mark-completed', () => {
// Active status is computed: confirmed + startDateTime in the past
const pastDate = new Date();
pastDate.setHours(pastDate.getHours() - 1); // 1 hour ago
const mockRental = {
id: 1,
ownerId: 1,
renterId: 2,
status: 'active',
status: 'confirmed',
startDateTime: pastDate,
update: jest.fn(),
};
@@ -837,7 +841,7 @@ describe('Rentals Routes', () => {
expect(response.status).toBe(400);
expect(response.body).toEqual({
error: 'Can only mark active or confirmed rentals as completed',
error: 'Can only mark active rentals as completed',
});
});
});

View File

@@ -10,6 +10,7 @@ describe('ConditionCheckService', () => {
describe('submitConditionCheck', () => {
// Set rental dates relative to current time for valid time window
// Active status is computed: confirmed + startDateTime in the past
const now = new Date();
const mockRental = {
id: 'rental-123',
@@ -17,7 +18,7 @@ describe('ConditionCheckService', () => {
renterId: 'renter-789',
startDateTime: new Date(now.getTime() - 1000 * 60 * 60), // 1 hour ago
endDateTime: new Date(now.getTime() + 1000 * 60 * 60 * 24), // 24 hours from now
status: 'active'
status: 'confirmed' // Will be computed as "active" since startDateTime is in the past
};
const mockPhotos = ['/uploads/photo1.jpg', '/uploads/photo2.jpg'];

View File

@@ -27,11 +27,15 @@ describe('DamageAssessmentService', () => {
beforeEach(() => {
// Reset mockRental for each test to avoid state pollution
// Active status is computed: confirmed + startDateTime in the past
const pastDate = new Date();
pastDate.setHours(pastDate.getHours() - 1); // 1 hour ago
mockRental = {
id: 'rental-123',
ownerId: 'owner-789',
renterId: 'renter-456',
status: 'active',
status: 'confirmed',
startDateTime: pastDate,
item: { name: 'Test Camera', dailyRate: 100 },
update: jest.fn().mockResolvedValue({
id: 'rental-123',

View File

@@ -91,9 +91,11 @@ describe('LateReturnService', () => {
let mockRental;
beforeEach(() => {
// Active status is computed: confirmed + startDateTime in the past
mockRental = {
id: '123',
status: 'active',
status: 'confirmed',
startDateTime: new Date('2023-05-01T08:00:00Z'), // In the past
endDateTime: new Date('2023-06-01T10:00:00Z'),
item: { pricePerHour: 10, name: 'Test Item' },
renterId: 'renter-123',

View File

@@ -229,8 +229,11 @@ describe('RefundService', () => {
});
});
it('should reject cancellation for active rental', () => {
const rental = { ...baseRental, status: 'active' };
it('should reject cancellation for active rental (computed from confirmed + past start)', () => {
// Active status is now computed: confirmed + startDateTime in the past
const pastDate = new Date();
pastDate.setHours(pastDate.getHours() - 1); // 1 hour ago
const rental = { ...baseRental, status: 'confirmed', startDateTime: pastDate };
const result = RefundService.validateCancellationEligibility(rental, 100);
expect(result).toEqual({