mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Handle no result in FetchResultsDone
+ Improve Desktop Filter Overlay Layout
This commit is contained in:
@@ -28,6 +28,16 @@
|
||||
right: 6px;
|
||||
box-shadow: 0px 0px 20px 0px rgba(89, 100, 112, 0.5);
|
||||
|
||||
@include mq-desktop() {
|
||||
bottom: 28px;
|
||||
right: 16vw;
|
||||
}
|
||||
|
||||
@include mq-big-desktop() {
|
||||
bottom: 28px;
|
||||
right: 26vw;
|
||||
}
|
||||
|
||||
transition: all 100ms linear;
|
||||
&.up {
|
||||
transform: rotate(90deg);
|
||||
|
||||
@@ -27,9 +27,8 @@ app-selected-filter-options {
|
||||
@include mq-desktop() {
|
||||
position: absolute;
|
||||
bottom: 25px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
left: 50%;
|
||||
transform: translate(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export class ShelfSearchResultsComponent implements OnInit, OnDestroy {
|
||||
destroy$ = new Subject();
|
||||
|
||||
grouped$ = this.searchStateFacade.result$.pipe(
|
||||
map((results) => groupBy(results, (item) => item.buyerNumber))
|
||||
map((results) => groupBy(results, (item) => (item ? item.buyerNumber : '')))
|
||||
);
|
||||
|
||||
fetching$ = this.searchStateFacade.fetching$;
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ResponseArgsOfIEnumerableOfInputDTO,
|
||||
OrderService,
|
||||
InputDTO,
|
||||
ListResponseArgsOfOrderItemListItemDTO,
|
||||
} from '@swagger/oms';
|
||||
import { hot, cold } from 'jasmine-marbles';
|
||||
import * as actions from './search.actions';
|
||||
@@ -25,6 +26,7 @@ import { Process } from 'apps/sales/src/app/core/models/process.model';
|
||||
import { first } from 'rxjs/operators';
|
||||
import { ProcessState } from 'apps/sales/src/app/core/store/state/process.state';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
|
||||
fdescribe('#SearchEffects', () => {
|
||||
let orderService: jasmine.SpyObj<OrderService>;
|
||||
@@ -197,4 +199,119 @@ fdescribe('#SearchEffects', () => {
|
||||
expect(searchStateFacade.fetchFilters).toHaveBeenCalledWith(id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#FetchResultsDone', () => {
|
||||
it('should dispatch setHits and addResult with fallback values when no result is returned', () => {
|
||||
const httpResponse: {
|
||||
id: number;
|
||||
response: StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>;
|
||||
} = {
|
||||
id,
|
||||
response: {
|
||||
ok: true,
|
||||
body: {
|
||||
error: false,
|
||||
hits: 0,
|
||||
invalidProperties: {},
|
||||
skip: 0,
|
||||
take: 20,
|
||||
},
|
||||
type: null,
|
||||
clone: null,
|
||||
headers: new HttpHeaders(),
|
||||
status: 200,
|
||||
statusText: 'Okay',
|
||||
url: 'someRandomUrl.de',
|
||||
},
|
||||
};
|
||||
|
||||
const fetchResultsDone = actions.fetchResultDone(httpResponse);
|
||||
actions$ = hot('-a', { a: fetchResultsDone });
|
||||
|
||||
const setHitsAction = actions.setHits({ id, hits: 0 });
|
||||
const addResultAction = actions.addResult({ id, result: [] });
|
||||
|
||||
const expected = cold('-(bc)', { b: setHitsAction, c: addResultAction });
|
||||
|
||||
expect(searchEffects.fetchResultDone$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should dispatch setHits and add Result', () => {
|
||||
const httpResponse: {
|
||||
id: number;
|
||||
response: StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>;
|
||||
} = {
|
||||
id,
|
||||
response: {
|
||||
ok: true,
|
||||
body: {
|
||||
error: false,
|
||||
result: [{ orderId: 345 }],
|
||||
hits: 1,
|
||||
invalidProperties: {},
|
||||
skip: 5,
|
||||
take: 20,
|
||||
},
|
||||
type: null,
|
||||
clone: null,
|
||||
headers: new HttpHeaders(),
|
||||
status: 200,
|
||||
statusText: 'Okay',
|
||||
url: 'someRandomUrl.de',
|
||||
},
|
||||
};
|
||||
|
||||
const fetchResultsDone = actions.fetchResultDone(httpResponse);
|
||||
actions$ = hot('-a', { a: fetchResultsDone });
|
||||
|
||||
const setTimestampActions = actions.setTimestamp({ id });
|
||||
const clearResultsActions = actions.clearResults({ id });
|
||||
const setHitsAction = actions.setHits({ id, hits: 1 });
|
||||
const addResultAction = actions.addResult({
|
||||
id,
|
||||
result: [{ orderId: 345 }],
|
||||
});
|
||||
|
||||
const expected = cold('-(bcde)', {
|
||||
b: setTimestampActions,
|
||||
c: clearResultsActions,
|
||||
d: setHitsAction,
|
||||
e: addResultAction,
|
||||
});
|
||||
|
||||
expect(searchEffects.fetchResultDone$).toBeObservable(expected);
|
||||
});
|
||||
|
||||
it('should not return an action if the response is not ok', () => {
|
||||
const httpResponse: {
|
||||
id: number;
|
||||
response: StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>;
|
||||
} = {
|
||||
id,
|
||||
response: {
|
||||
ok: false,
|
||||
body: {
|
||||
error: false,
|
||||
result: [{ orderId: 345 }],
|
||||
hits: 1,
|
||||
invalidProperties: {},
|
||||
skip: 5,
|
||||
take: 20,
|
||||
},
|
||||
type: null,
|
||||
clone: null,
|
||||
headers: new HttpHeaders(),
|
||||
status: 200,
|
||||
statusText: 'Okay',
|
||||
url: 'someRandomUrl.de',
|
||||
},
|
||||
};
|
||||
|
||||
const fetchResultsDone = actions.fetchResultDone(httpResponse);
|
||||
actions$ = hot('-a', { a: fetchResultsDone });
|
||||
|
||||
const expected = cold('-');
|
||||
expect(searchEffects.fetchResultDone$).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,8 +102,8 @@ export class SearchEffects {
|
||||
actions.clearResults({ id: action.id }),
|
||||
]
|
||||
: []),
|
||||
actions.setHits({ id: action.id, hits: result.hits }),
|
||||
actions.addResult({ id: action.id, result: result.result }),
|
||||
actions.setHits({ id: action.id, hits: result.hits || 0 }),
|
||||
actions.addResult({ id: action.id, result: result.result || [] }),
|
||||
];
|
||||
}
|
||||
return NEVER;
|
||||
|
||||
Reference in New Issue
Block a user