fix: complete loading review coverage (#18)
This commit is contained in:
1 parent
0f68a91c5d
commit
a8a3d7a747
8 files changed
+107
-52
No files matched your search
@@ -64,4 +64,25 @@ describe('ApartmentForm', () => {
|
||||
'Impossible d’enregistrer cet appartement.',
|
||||
);
|
||||
});
|
||||
|
||||
it('preserves entered values after a save fails', async () => {
|
||||
const fixture = TestBed.createComponent(ApartmentForm);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
const form = fixture.componentInstance;
|
||||
form.name.set('T2 rénové');
|
||||
form.address.set('45 rue des Entrepreneurs');
|
||||
form.purchasePrice.set(265000);
|
||||
fixture.componentRef.setInput('saveError', 'Impossible d’enregistrer cet appartement.');
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(fixture.nativeElement.querySelector('input[name=name]').value).toBe('T2 rénové');
|
||||
expect(fixture.nativeElement.querySelector('input[name=address]').value).toBe(
|
||||
'45 rue des Entrepreneurs',
|
||||
);
|
||||
expect(fixture.nativeElement.textContent).toContain(
|
||||
'Impossible d’enregistrer cet appartement.',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -53,6 +53,16 @@ describe('ApartmentsPage', () => {
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Aucun appartement enregistré');
|
||||
});
|
||||
|
||||
it('shows the empty state only after a successful empty load', () => {
|
||||
workspace.apartmentLoadState.set({ loaded: true, loading: false, error: '' });
|
||||
const fixture = TestBed.createComponent(ApartmentsPage);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.nativeElement.textContent).toContain('Aucun appartement enregistré');
|
||||
expect(fixture.nativeElement.querySelector('.skeleton-card')).toBeNull();
|
||||
expect(fixture.nativeElement.querySelector('.load-error')).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps established apartments visible during a background refresh', () => {
|
||||
workspace.apartments.set([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user