5084-monitor.index_tickets #1301

Merged
vicent merged 7 commits from 5084-monitor.index_tickets into dev 2023-02-02 10:52:52 +00:00
2 changed files with 7 additions and 11 deletions

View File

@ -478,8 +478,8 @@ export default class SmartTable extends Component {
const params = {q: JSON.stringify(stateFilter)}; const params = {q: JSON.stringify(stateFilter)};
this.$state.go(this.$state.current.name, params, {location: 'replace'}); this.$state.go(this.$state.current.name, params, {location: 'replace'})
this.refresh(); .then(() => this.refresh());
} }
applySort() { applySort() {
@ -499,8 +499,8 @@ export default class SmartTable extends Component {
stateFilter.tableOrder = order; stateFilter.tableOrder = order;
const params = {q: JSON.stringify(stateFilter)}; const params = {q: JSON.stringify(stateFilter)};
this.$state.go(this.$state.current.name, params, {location: 'replace'}); this.$state.go(this.$state.current.name, params, {location: 'replace'})
this.refresh(); .then(() => this.refresh());
} }
filterSanitizer(field) { filterSanitizer(field) {
@ -589,7 +589,7 @@ export default class SmartTable extends Component {
refresh() { refresh() {
this.isRefreshing = true; this.isRefreshing = true;
this.model.refresh() this.model.refresh()
.then(() => this.isRefreshing = false); .finally(() => this.isRefreshing = false);
} }
} }

View File

@ -160,7 +160,7 @@ describe('Component smartTable', () => {
describe('applySort()', () => { describe('applySort()', () => {
it('should call the $state go and model refresh without making changes on the model order', () => { it('should call the $state go and model refresh without making changes on the model order', () => {
controller.$state = { controller.$state = {
go: jest.fn(), go: jest.fn().mockReturnValue(new Promise(resolve => resolve())),
current: { current: {
name: 'section' name: 'section'
} }
@ -171,13 +171,12 @@ describe('Component smartTable', () => {
expect(controller.model.order).toBeUndefined(); expect(controller.model.order).toBeUndefined();
expect(controller.$state.go).toHaveBeenCalled(); expect(controller.$state.go).toHaveBeenCalled();
expect(controller.refresh).toHaveBeenCalled();
}); });
it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => { it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => {
const orderBy = {field: 'myField', sortType: 'ASC'}; const orderBy = {field: 'myField', sortType: 'ASC'};
controller.$state = { controller.$state = {
go: jest.fn(), go: jest.fn().mockReturnValue(new Promise(resolve => resolve())),
current: { current: {
name: 'section' name: 'section'
} }
@ -190,7 +189,6 @@ describe('Component smartTable', () => {
expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`); expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`);
expect(controller.$state.go).toHaveBeenCalled(); expect(controller.$state.go).toHaveBeenCalled();
expect(controller.refresh).toHaveBeenCalled();
}); });
}); });
@ -293,12 +291,10 @@ describe('Component smartTable', () => {
controller.$inputsScope = { controller.$inputsScope = {
searchProps: {} searchProps: {}
}; };
jest.spyOn(controller, 'refresh');
controller.defaultFilter(); controller.defaultFilter();
expect(controller.model.addFilter).toHaveBeenCalled(); expect(controller.model.addFilter).toHaveBeenCalled();
expect(controller.refresh).toHaveBeenCalled();
}); });
}); });