mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
feat: improved e2e tests
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||
import {SCDish, SCPlace, SCThings} from '@openstapps/core';
|
||||
import {PlaceMensaService} from '../../../data/types/place/special/mensa/place-mensa-service';
|
||||
import moment from 'moment';
|
||||
import {fadeAnimation} from '../../fade.animation';
|
||||
import {isToday} from 'date-fns';
|
||||
|
||||
/**
|
||||
* Shows a section with meals of the chosen mensa
|
||||
@@ -32,15 +32,12 @@ export class MensaSectionContentComponent {
|
||||
/**
|
||||
* Map of dishes for each day
|
||||
*/
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
dishes: Promise<SCDish[]>;
|
||||
|
||||
@Input() set item(value: SCThings) {
|
||||
if (!value) return;
|
||||
this.dishes = this.mensaService.getAllDishes(value as SCPlace, 1).then(it => {
|
||||
const closestDayWithDishes = Object.keys(it)
|
||||
.filter(key => it[key].length > 0)
|
||||
.find(key => moment(key).isSame(moment(), 'day'));
|
||||
const closestDayWithDishes = Object.keys(it).find(key => it[key].length > 0 && isToday(new Date(key)));
|
||||
return closestDayWithDishes ? it[closestDayWithDishes] : [];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ export class CoordinatedSearchProvider {
|
||||
* 2. If not, waits a set amount of time for other requests to come in
|
||||
*/
|
||||
async coordinatedSearch(query: SCSearchRequest, latencyMs = 50): Promise<SCSearchResponse> {
|
||||
console.log('coordinatedSearch', query);
|
||||
const ongoingQuery: OngoingQuery = {request: query};
|
||||
this.queue.push(ongoingQuery);
|
||||
|
||||
|
||||
@@ -14,14 +14,11 @@
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {SCDish, SCISO8601Date, SCPlace, SCSearchQuery, SCThingType} from '@openstapps/core';
|
||||
import moment from 'moment';
|
||||
import {DataProvider} from '../../../../data.provider';
|
||||
import {mapValues} from '@openstapps/collection-utils';
|
||||
import {SettingsProvider} from '../../../../../settings/settings.provider';
|
||||
import {addDays, startOfHour} from 'date-fns';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@@ -38,58 +35,55 @@ export class PlaceMensaService {
|
||||
*/
|
||||
async getAllDishes(place: SCPlace, days: number): Promise<Record<SCISO8601Date, SCDish[]>> {
|
||||
const priceGroup = await this.settingsProvider.getSetting('profile', 'group');
|
||||
const request = mapValues<Record<SCISO8601Date, SCISO8601Date>, SCSearchQuery>(
|
||||
Array.from({length: days})
|
||||
.map((_, i) => i)
|
||||
.map(i => moment().add(i, 'days').toISOString())
|
||||
.reduce(
|
||||
(accumulator, item) => {
|
||||
accumulator[item] = item;
|
||||
return accumulator;
|
||||
},
|
||||
{} as Record<SCISO8601Date, SCISO8601Date>,
|
||||
),
|
||||
date => ({
|
||||
filter: {
|
||||
arguments: {
|
||||
filters: [
|
||||
{
|
||||
arguments: {
|
||||
field: 'offers.inPlace.uid',
|
||||
value: place.uid,
|
||||
},
|
||||
type: 'value',
|
||||
|
||||
const request = Object.fromEntries(
|
||||
Array.from({length: days}, (_, i) => {
|
||||
const date = addDays(startOfHour(Date.now()), i).toISOString();
|
||||
return [
|
||||
date,
|
||||
{
|
||||
filter: {
|
||||
arguments: {
|
||||
filters: [
|
||||
{
|
||||
arguments: {
|
||||
field: 'offers.inPlace.uid',
|
||||
value: place.uid,
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: SCThingType.Dish,
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'offers.availabilityRange',
|
||||
scope: 'd',
|
||||
time: date,
|
||||
},
|
||||
type: 'availability',
|
||||
},
|
||||
],
|
||||
operation: 'and',
|
||||
},
|
||||
type: 'boolean',
|
||||
},
|
||||
sort: [
|
||||
{
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: SCThingType.Dish,
|
||||
field: `offers.prices.${(priceGroup.value as string).replace(/s$/, '')}`,
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'offers.availabilityRange',
|
||||
scope: 'd',
|
||||
time: date,
|
||||
},
|
||||
type: 'availability',
|
||||
order: 'desc',
|
||||
type: 'generic',
|
||||
},
|
||||
],
|
||||
operation: 'and',
|
||||
},
|
||||
type: 'boolean',
|
||||
},
|
||||
sort: [
|
||||
{
|
||||
arguments: {
|
||||
field: `offers.prices.${(priceGroup.value as string).replace(/s$/, '')}`,
|
||||
},
|
||||
order: 'desc',
|
||||
type: 'generic',
|
||||
},
|
||||
],
|
||||
size: 1000,
|
||||
size: 1000,
|
||||
} satisfies SCSearchQuery,
|
||||
];
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -56,10 +56,7 @@ export class ContextMenuComponent {
|
||||
* No specific type => Type name alphabetically => Bucket count
|
||||
*/
|
||||
get facets(): FilterFacet[] {
|
||||
const options = this.filterOption.compact
|
||||
? this.filterOption.options.slice(0, this.compactFilterOptionCount)
|
||||
: this.filterOption.options;
|
||||
return options.filter(it => it.buckets.length > 0);
|
||||
return this.filterOption.options.filter(it => it.buckets.length > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,13 +93,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</ion-list>
|
||||
<ion-button
|
||||
fill="clear"
|
||||
*ngIf="!filterOption.compact && filterOption.options.length > compactFilterOptionCount"
|
||||
(click)="filterOption.compact = true"
|
||||
>
|
||||
{{ 'menu.context.filter.showAll' | translate }}
|
||||
</ion-button>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-menu>
|
||||
|
||||
Reference in New Issue
Block a user