feat: finalize lease documents and IRL revisions
This commit is contained in:
1 parent
f127c69a28
commit
1bf6a3449c
196 files changed
+20564
-666
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { vi } from 'vitest';
|
||||
import { LeaseFinalizationService } from './lease-finalization.service';
|
||||
|
||||
describe('LeaseFinalizationService', () => {
|
||||
const http = {
|
||||
get: vi.fn().mockReturnValue(of({})),
|
||||
post: vi.fn().mockReturnValue(of({})),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
TestBed.configureTestingModule({
|
||||
providers: [LeaseFinalizationService, { provide: HttpClient, useValue: http }],
|
||||
});
|
||||
});
|
||||
|
||||
it('uses the finalization state endpoint', () => {
|
||||
TestBed.inject(LeaseFinalizationService).getState('lease-1').subscribe();
|
||||
|
||||
expect(http.get).toHaveBeenCalledWith('/api/leases/lease-1/finalization');
|
||||
});
|
||||
|
||||
it('uploads an attested guarantee deed for one guarantor and tenant pair', () => {
|
||||
const file = new File(['deed'], 'cautionnement.pdf', { type: 'application/pdf' });
|
||||
TestBed.inject(LeaseFinalizationService)
|
||||
.uploadGuaranteeDeed('lease-1', file, 'guarantor-1', 'tenant-1')
|
||||
.subscribe();
|
||||
|
||||
const formData = http.post.mock.calls[0][1] as FormData;
|
||||
expect(http.post.mock.calls[0][0]).toBe('/api/leases/lease-1/guarantee-deeds');
|
||||
expect(formData.get('file')).toBe(file);
|
||||
expect(formData.get('guarantorId')).toBe('guarantor-1');
|
||||
expect(formData.get('tenantId')).toBe('tenant-1');
|
||||
expect(formData.get('attestation')).toBe('true');
|
||||
});
|
||||
|
||||
it('keeps the civil signature date string and repeated warnings unchanged', () => {
|
||||
const file = new File(['lease'], 'bail-signe.pdf', { type: 'application/pdf' });
|
||||
TestBed.inject(LeaseFinalizationService)
|
||||
.finalize('lease-1', {
|
||||
signedLease: file,
|
||||
revisionNumber: 4,
|
||||
lastSignatureDate: '2026-07-19',
|
||||
allPartiesSigned: true,
|
||||
revisionMatches: true,
|
||||
confirmedWarningCodes: ['DPE_OVERRIDE', 'RENT_OVERRIDE'],
|
||||
})
|
||||
.subscribe();
|
||||
|
||||
const formData = http.post.mock.calls[0][1] as FormData;
|
||||
expect(http.post.mock.calls[0][0]).toBe('/api/leases/lease-1/finalization');
|
||||
expect(formData.get('signedLease')).toBe(file);
|
||||
expect(formData.get('revisionNumber')).toBe('4');
|
||||
expect(formData.get('lastSignatureDate')).toBe('2026-07-19');
|
||||
expect(formData.get('allPartiesSigned')).toBe('true');
|
||||
expect(formData.get('revisionMatches')).toBe('true');
|
||||
expect(formData.getAll('confirmedWarningCodes')).toEqual(['DPE_OVERRIDE', 'RENT_OVERRIDE']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user