Commit 5039f3f6 authored by Vitali Stupin's avatar Vitali Stupin

fix instance switching

parent 72dd2e4b
......@@ -115,8 +115,14 @@ describe('SubsystemListComponent', () => {
fixture = TestBed.createComponent(SubsystemListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
const spy = TestBed.get(Router).navigateByUrl;
component.switchInstance('NEWINST');
expect(TestBed.get(Router).navigateByUrl).toHaveBeenCalledWith('/NEWINST');
expect(spy).toHaveBeenCalledWith('/NEWINST');
spy.calls.reset();
component.switchInstance('INST');
expect(spy).toHaveBeenCalledWith('/INST');
});
it('should receive service warnings', () => {
......@@ -230,4 +236,14 @@ describe('SubsystemListComponent (with instance version)', () => {
component.setInstanceVersion();
expect(TestBed.get(Router).navigateByUrl).toHaveBeenCalledWith('/INST?at=12345');
});
it('switchInstance should reset instance version when instance does not change', () => {
fixture = TestBed.createComponent(SubsystemListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.instanceVersion = 'test';
component.switchInstance('INST');
expect(TestBed.get(Router).navigateByUrl).toHaveBeenCalledWith('/INST');
expect(component.instanceVersion).toBe('');
});
});
......@@ -48,6 +48,11 @@ export class SubsystemListComponent implements OnInit, AfterViewInit, OnDestroy
switchInstance(instance: string): void {
this.router.navigateByUrl('/' + instance);
// Reloading data if clicked on the current instance
if (this.subsystemsService.getInstance() === instance) {
this.instanceVersion = '';
this.subsystemsService.setInstance(instance, this.instanceVersion);
}
}
getApiUrl(): string {
......
import { Injectable, EventEmitter } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, of, BehaviorSubject, Subject } from 'rxjs';
import { of, BehaviorSubject, Subject } from 'rxjs';
import { catchError, debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { Subsystem } from './subsystem';
import { Method } from './method';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment