// import { Spectator, byText, createComponentFactory } from '@ngneat/spectator';
// import { ShellProcessBarComponent } from './process-bar.component';
// import { RouterTestingModule } from '@angular/router/testing';
// import { ApplicationProcess, ApplicationService } from '@core/application';
// import { NEVER, of } from 'rxjs';
// import { MockComponent } from 'ng-mocks';
// import { CdkMenu, CdkMenuModule, CdkMenuTrigger } from '@angular/cdk/menu';
// import { UISvgIconComponent } from '@ui/icon';
// import { TestScheduler } from 'rxjs/testing';
// import { TemplateRef } from '@angular/core';
// import { ShellProcessBarItemComponent } from './process-bar-item/process-bar-item.component';
// import { ProductCatalogNavigationService } from '@shared/services/navigation';
// import { MessageModalService } from '@shared/modals/message-modal';
// import { DomainCheckoutService } from '@domain/checkout';
// import { BreadcrumbService } from '@core/breadcrumb';
// import { UiModalService } from '@ui/modal';

// describe('ShellProcessBarComponent', () => {
//   let spectator: Spectator<ShellProcessBarComponent>;
//   const createComponent = createComponentFactory({
//     component: ShellProcessBarComponent,
//     imports: [RouterTestingModule, CdkMenuModule],
//     mocks: [MessageModalService, DomainCheckoutService, BreadcrumbService, UiModalService],
//     declarations: [MockComponent(UISvgIconComponent), MockComponent(ShellProcessBarItemComponent)],
//   });
//   let applicationService: jasmine.SpyObj<ApplicationService>;
//   let catalogNavigationService: jasmine.SpyObj<ProductCatalogNavigationService>;

//   let testScheduler: TestScheduler;

//   beforeEach(() => {
//     applicationService = jasmine.createSpyObj<ApplicationService>(['getSection$', 'getProcesses$', 'createProcess']);
//     catalogNavigationService = jasmine.createSpyObj<ProductCatalogNavigationService>(['getArticleSearchBasePath']);

//     applicationService.getSection$.and.returnValue(NEVER);
//     applicationService.getProcesses$.and.returnValue(NEVER);

//     spectator = createComponent({
//       providers: [
//         {
//           provide: ApplicationService,
//           useValue: applicationService,
//         },
//         {
//           provide: ProductCatalogNavigationService,
//           useValue: catalogNavigationService,
//         },
//       ],
//     });

//     testScheduler = new TestScheduler((actual, expected) => {
//       expect(actual).toEqual(expected);
//     });
//   });

//   it('should create', () => {
//     expect(spectator.component).toBeTruthy();
//   });

//   describe('ngOnInit', () => {
//     it('should call initSection$', () => {
//       const spy = spyOn(spectator.component, 'initSection$');
//       spectator.component.ngOnInit();
//       expect(spy).toHaveBeenCalled();
//     });

//     it('should call initProcesses$', () => {
//       const spy = spyOn(spectator.component, 'initProcesses$');
//       spectator.component.ngOnInit();
//       expect(spy).toHaveBeenCalled();
//     });

//     it('should call initShowStartProcessText$', () => {
//       const spy = spyOn(spectator.component, 'initShowStartProcessText$');
//       spectator.component.ngOnInit();
//       expect(spy).toHaveBeenCalled();
//     });
//   });

//   describe('initSection$', () => {
//     // it('should init section$ that emits the currently selected section', () => {
//     //   testScheduler.run(({ cold, expectObservable }) => {
//     //     const section$ = cold<'customer' | 'branch'>('a', { a: 'customer' });
//     //     applicationService.getSection$.and.returnValue(section$);
//     //     spectator.component.initSection$();
//     //     expectObservable(spectator.component.section$).toBe('a', { a: 'customer' });
//     //   });
//     // });
//   });

//   describe('initProcesses$', () => {
//     it('should init processes$ that emits the processes of the currently selected section', () => {
//       testScheduler.run(({ cold, expectObservable }) => {
//         const section$ = cold<'customer' | 'branch'>('a', { a: 'customer', b: 'branch' });
//         spectator.component.section$ = section$;

//         const processes$ = cold<ApplicationProcess[]>('a', { a: [] });
//         applicationService.getProcesses$.and.returnValue(processes$);

//         spectator.component.initProcesses$();

//         expectObservable(spectator.component.processes$).toBe('a', { a: [] });
//       });
//     });
//   });

//   describe('initShowStartProcessText$', () => {
//     it('should init showStartProcessText$ that emits true if processes$ emits an empty array', () => {
//       testScheduler.run(({ cold, expectObservable }) => {
//         const processes$ = cold<ApplicationProcess[]>('a', { a: [] });
//         spectator.component.processes$ = processes$;

//         spectator.component.initShowStartProcessText$();

//         expectObservable(spectator.component.showStartProcessText$).toBe('a', { a: true });
//       });
//     });

//     it('should init showStartProcessText$ that emits false if processes$ emits a non-empty array', () => {
//       testScheduler.run(({ cold, expectObservable }) => {
//         const processes$ = cold<ApplicationProcess[]>('a', { a: [{ id: 0, name: '', section: 'customer' }] });
//         spectator.component.processes$ = processes$;

//         spectator.component.initShowStartProcessText$();

//         expectObservable(spectator.component.showStartProcessText$).toBe('a', { a: false });
//       });
//     });
//   });

//   describe("createProcess(target: string = 'product')", () => {
//     it('should call applicationService.createProcess with the target', async () => {
//       spectator.component.createProcess('product');
//       const process: ApplicationProcess = { id: 0, name: '', section: 'customer' };
//       spyOn(spectator.component, 'createCartProcess').and.returnValue(Promise.resolve(process));
//       spyOn(spectator.component, 'navigateTo').and.callFake((target: string, process: ApplicationProcess) => null);

//       await spectator.component.createProcess('product');

//       expect(spectator.component.createCartProcess).toHaveBeenCalled();
//       expect(spectator.component.navigateTo).toHaveBeenCalledWith('product', process);
//     });
//   });

//   describe('navigateTo(target: string, process: ApplicationProcess)', () => {
//     it('should call catalogNavigationService.navigateToProductSearch with the correct processId', () => {
//       const process: ApplicationProcess = { id: 0, name: '', section: 'customer' };
//       spectator.component.navigateTo('product', process);
//       expect(catalogNavigationService.getArticleSearchBasePath).toHaveBeenCalledWith(process.id);
//     });
//   });

//   describe('template', () => {
//     describe('shell-process-bar-item', () => {
//       it('should render the shellProcessBarItem component for each process in processes$ ', () => {
//         const processes: ApplicationProcess[] = [
//           { id: 0, name: 'Test 1', section: 'customer' },
//           { id: 1, name: 'Test 2', section: 'customer' },
//         ];
//         spectator.component.processes$ = of(processes);
//         spectator.detectComponentChanges();

//         const shellProcessBarItems = spectator.queryAll(ShellProcessBarItemComponent);
//         expect(shellProcessBarItems.length).toBe(2);
//       });

//       it('should pass the process to the shellProcessBarItem component', () => {
//         const processes: ApplicationProcess[] = [
//           { id: 0, name: 'Test 1', section: 'customer' },
//           { id: 1, name: 'Test 2', section: 'customer' },
//         ];
//         spectator.component.processes$ = of(processes);
//         spectator.detectComponentChanges();

//         const shellProcessBarItems = spectator.queryAll(ShellProcessBarItemComponent);
//         expect(shellProcessBarItems[0].process).toBe(processes[0]);
//         expect(shellProcessBarItems[1].process).toBe(processes[1]);
//       });
//     });
//   });
// });
