Files
iptvnator/apps/web/src/app/app-startup-status.component.spec.ts
T
4gray 9f950a1530 fix(migration): show startup preparation and recover source read failures (#1568)
* fix(migration): show startup preparation and recover source read failures

* fix(migration): keep inventory reload failures recoverable

* test(migration): type the deferred recovery hook

* fix(migration): reconcile failed EPG cleanup before recovery

* fix(migration): await settings before inventory readiness

* style(migration): add a subtle theme-aware startup watermark
2026-09-07 21:24:34 +02:00

67 lines
2.7 KiB
TypeScript

import { TestBed } from '@angular/core/testing';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { TranslateModule } from '@ngx-translate/core';
import {
PlaylistActions,
selectPlaylistsLoadFailed,
selectPlaylistsLoadingFlag,
} from '@iptvnator/m3u-state';
import { AppStartupStatusComponent } from './app-startup-status.component';
describe('AppStartupStatusComponent', () => {
beforeEach(() =>
TestBed.configureTestingModule({
imports: [AppStartupStatusComponent, TranslateModule.forRoot()],
providers: [
provideMockStore({
selectors: [
{ selector: selectPlaylistsLoadingFlag, value: false },
{ selector: selectPlaylistsLoadFailed, value: false },
],
}),
],
})
);
it('keeps showing preparation while EPG reconciliation delays the route', () => {
const store = TestBed.inject(MockStore);
store.overrideSelector(selectPlaylistsLoadingFlag, true);
const fixture = TestBed.createComponent(AppStartupStatusComponent);
fixture.detectChanges();
expect(
fixture.nativeElement.querySelector('[role="status"]')
).not.toBeNull();
fixture.componentRef.setInput('routeReady', true);
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('section')).toBeNull();
});
it('does not expose an empty workspace before sources finish loading', () => {
const fixture = TestBed.createComponent(AppStartupStatusComponent);
fixture.componentRef.setInput('routeReady', true);
fixture.detectChanges();
expect(fixture.componentInstance.complete()).toBe(false);
const store = TestBed.inject(MockStore);
store.overrideSelector(selectPlaylistsLoadingFlag, true);
store.refreshState();
fixture.detectChanges();
expect(fixture.componentInstance.complete()).toBe(true);
});
it('offers a retry on failure without rendering raw storage errors', () => {
TestBed.inject(MockStore).overrideSelector(
selectPlaylistsLoadFailed,
true
);
const fixture = TestBed.createComponent(AppStartupStatusComponent);
fixture.detectChanges();
expect(
fixture.nativeElement.querySelector('[role="alert"]')
).not.toBeNull();
expect(fixture.nativeElement.querySelector('mat-spinner')).toBeNull();
const dispatch = jest.spyOn(TestBed.inject(MockStore), 'dispatch');
fixture.nativeElement.querySelector('button').click();
expect(dispatch).toHaveBeenCalledWith(PlaylistActions.loadPlaylists());
});
});