feat: activate draft leases into rent dues (#28)
This commit is contained in:
1 parent
971ffd6feb
commit
c2afe515c0
42 files changed
+1735
-113
No files matched your search
@@ -73,4 +73,87 @@ describe('LeaseCard', () => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toContain('Impossible de télécharger ce bail.');
|
||||
});
|
||||
|
||||
it('offers draft lifecycle actions with activation progress and an actionable failure', () => {
|
||||
const fixture = TestBed.createComponent(LeaseCard);
|
||||
fixture.componentRef.setInput('apartments', []);
|
||||
fixture.componentRef.setInput('tenants', []);
|
||||
fixture.componentRef.setInput('lease', {
|
||||
id: 'lease-1',
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: [],
|
||||
guarantors: [],
|
||||
startDate: '2026-01-01',
|
||||
endDate: '2027-01-01',
|
||||
monthlyRent: 800,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 800,
|
||||
status: 'DRAFT',
|
||||
});
|
||||
fixture.componentRef.setInput('activating', true);
|
||||
fixture.componentRef.setInput('activationError', 'Un bail actif chevauche cette période.');
|
||||
fixture.detectChanges();
|
||||
|
||||
const text = fixture.nativeElement.textContent.replace(/\s+/g, ' ');
|
||||
expect(text).toContain('Modifier');
|
||||
expect(text).toContain('Supprimer');
|
||||
expect(text).toContain('Activation…');
|
||||
expect(text).toContain('Un bail actif chevauche cette période.');
|
||||
const activation = [...fixture.nativeElement.querySelectorAll('button')].find((button) =>
|
||||
button.textContent.includes('Activation…'),
|
||||
);
|
||||
expect(activation.disabled).toBe(true);
|
||||
|
||||
fixture.componentRef.setInput('lease', {
|
||||
...fixture.componentInstance.lease(),
|
||||
status: 'ACTIVE',
|
||||
});
|
||||
fixture.componentRef.setInput('activating', false);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Modifier');
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Supprimer');
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Activer');
|
||||
});
|
||||
|
||||
it('shows the resulting rent schedule with separate settlement and timing labels', () => {
|
||||
const fixture = TestBed.createComponent(LeaseCard);
|
||||
fixture.componentRef.setInput('apartments', []);
|
||||
fixture.componentRef.setInput('tenants', []);
|
||||
fixture.componentRef.setInput('lease', {
|
||||
id: 'lease-1',
|
||||
apartmentId: 'apartment-1',
|
||||
tenantIds: [],
|
||||
guarantors: [],
|
||||
startDate: '2026-01-01',
|
||||
endDate: '2026-01-31',
|
||||
monthlyRent: 800,
|
||||
monthlyCharges: 50,
|
||||
securityDeposit: 800,
|
||||
status: 'ACTIVE',
|
||||
});
|
||||
fixture.componentRef.setInput('rentDues', [
|
||||
{
|
||||
id: 'due-1',
|
||||
leaseId: 'lease-1',
|
||||
month: '2026-01',
|
||||
dueDate: '2026-01-01',
|
||||
rent: 800,
|
||||
charges: 50,
|
||||
total: 850,
|
||||
remainingAmount: 850,
|
||||
settlement: 'UNPAID',
|
||||
timing: 'OVERDUE',
|
||||
},
|
||||
]);
|
||||
fixture.detectChanges();
|
||||
|
||||
const text = fixture.nativeElement.textContent.replace(/\s+/g, ' ');
|
||||
const amounts = [...fixture.nativeElement.querySelectorAll('.rent-due dl div')].map((term) =>
|
||||
[...term.children].map((item) => item.textContent.trim()).join(' '),
|
||||
);
|
||||
expect(text).toContain('2026-01');
|
||||
expect(amounts).toEqual(['Loyer 800 €', 'Charges 50 €', 'Total 850 €', 'Restant 850 €']);
|
||||
expect(text).toContain('Règlement : Non réglée');
|
||||
expect(text).toContain('Temporalité : En retard');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user