fix(searchBar): applyParams #1219
|
@ -15,7 +15,7 @@ describe('SmartTable SearchBar integration', () => {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('as filters', () => {
|
describe('as filters in smart-table section', () => {
|
||||||
it('should search by type in searchBar', async() => {
|
it('should search by type in searchBar', async() => {
|
||||||
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
||||||
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
||||||
|
@ -47,6 +47,34 @@ describe('SmartTable SearchBar integration', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('as filters in section without smart-table', () => {
|
||||||
|
it('go to zone section', async() => {
|
||||||
|
await page.loginAndModule('salesPerson', 'zone');
|
||||||
|
await page.waitToClick(selectors.globalItems.searchButton);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in searchBar first time', async() => {
|
||||||
|
await page.doSearch('A');
|
||||||
|
const count = await page.countElement(selectors.zoneIndex.searchResult);
|
||||||
|
|
||||||
|
expect(count).toEqual(7);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in searchBar second time', async() => {
|
||||||
|
await page.doSearch('A');
|
||||||
|
const count = await page.countElement(selectors.zoneIndex.searchResult);
|
||||||
|
|
||||||
|
expect(count).toEqual(7);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should search in searchBar third time', async() => {
|
||||||
|
await page.doSearch('A');
|
||||||
|
const count = await page.countElement(selectors.zoneIndex.searchResult);
|
||||||
|
|
||||||
|
expect(count).toEqual(7);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('as orders', () => {
|
describe('as orders', () => {
|
||||||
it('should order by first id', async() => {
|
it('should order by first id', async() => {
|
||||||
await page.loginAndModule('developer', 'item');
|
await page.loginAndModule('developer', 'item');
|
||||||
|
|
|
@ -308,7 +308,7 @@ export default class Searchbar extends Component {
|
||||||
|
|
||||||
this.tableQ = null;
|
this.tableQ = null;
|
||||||
|
|
||||||
const hasParams = this.$params.q && Object.keys(JSON.parse(this.$params.q)).length;
|
const hasParams = this.$params.q && JSON.parse(this.$params.q).tableQ;
|
||||||
if (hasParams) {
|
if (hasParams) {
|
||||||
const stateFilter = JSON.parse(this.$params.q);
|
const stateFilter = JSON.parse(this.$params.q);
|
||||||
for (let param in stateFilter) {
|
for (let param in stateFilter) {
|
||||||
|
@ -325,8 +325,8 @@ export default class Searchbar extends Component {
|
||||||
for (let param in stateFilter.tableQ)
|
for (let param in stateFilter.tableQ)
|
||||||
params[param] = stateFilter.tableQ[param];
|
params[param] = stateFilter.tableQ[param];
|
||||||
|
|
||||||
Object.assign(stateFilter, params);
|
const newParams = Object.assign(stateFilter, params);
|
||||||
return this.model.applyParams(params)
|
return this.model.applyParams(newParams)
|
||||||
.then(() => this.model.data);
|
.then(() => this.model.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,14 +174,12 @@ describe('Component vnSearchbar', () => {
|
||||||
jest.spyOn(controller, 'doSearch');
|
jest.spyOn(controller, 'doSearch');
|
||||||
controller.model = {
|
controller.model = {
|
||||||
refresh: jest.fn(),
|
refresh: jest.fn(),
|
||||||
|
applyFilter: jest.fn().mockReturnValue(Promise.resolve()),
|
||||||
userParams: {
|
userParams: {
|
||||||
id: 1
|
id: 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.model.applyParams = jest.fn().mockReturnValue(Promise.resolve());
|
|
||||||
jest.spyOn(controller.model, 'applyParams');
|
|
||||||
|
|
||||||
controller.filter = filter;
|
controller.filter = filter;
|
||||||
controller.removeParam(0);
|
controller.removeParam(0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue