e2e testing

This commit is contained in:
2026-06-15 19:17:13 +05:30
parent 896561245d
commit 01685f14c2
18 changed files with 1102 additions and 198 deletions

View File

@@ -20,6 +20,8 @@ import {
FIESTA_APPLOCATION_ID,
FIESTA_PRIMARY_LOCATION_ID,
getOrderSummary,
getRevenueSummary,
getTimeSeries,
getLocationSummary,
getOrderInsight,
getOrders,
@@ -62,6 +64,8 @@ import {
export const fiestaKeys = {
orderSummary: (tenantid: number, fromdate: string, todate: string, locationid?: number) =>
['fiesta', 'orderSummary', tenantid, fromdate, todate, locationid ?? 0] as const,
revenueSummary: (params: Record<string, unknown>) => ['fiesta', 'revenueSummary', params] as const,
timeSeries: (params: Record<string, unknown>) => ['fiesta', 'timeSeries', params] as const,
locationSummary: (tenantid: number) => ['fiesta', 'locationSummary', tenantid] as const,
orderInsight: (tenantid: number) => ['fiesta', 'orderInsight', tenantid] as const,
orders: (params: Record<string, unknown>) => ['fiesta', 'orders', params] as const,
@@ -102,6 +106,33 @@ export function useFiestaOrderSummary(tenantid: number = FIESTA_TENANT_ID, fromd
});
}
export function useFiestaRevenueSummary(opts: {
tenantid: number;
fromdate: string;
todate: string;
locationid?: number;
}) {
return useQuery({
queryKey: fiestaKeys.revenueSummary(opts as Record<string, unknown>),
queryFn: () => getRevenueSummary(opts),
enabled: Boolean(opts.tenantid && opts.fromdate && opts.todate),
});
}
export function useFiestaTimeSeries(opts: {
tenantid: number;
granularity: 'day' | 'month' | 'year';
fromdate: string;
todate: string;
locationid?: number;
}) {
return useQuery({
queryKey: fiestaKeys.timeSeries(opts as Record<string, unknown>),
queryFn: () => getTimeSeries(opts),
enabled: Boolean(opts.tenantid && opts.fromdate && opts.todate),
});
}
export function useFiestaLocationSummary(tenantid: number = FIESTA_TENANT_ID) {
return useQuery({
queryKey: fiestaKeys.locationSummary(tenantid),
@@ -153,10 +184,16 @@ export function useFiestaAllOrders(opts: {
return useQuery({
queryKey: ['fiesta', 'allOrders', opts],
queryFn: async () => {
const statuses = ['created', 'pending', 'processing', 'delivered', 'cancelled'];
const results = await Promise.all(
statuses.map(status =>
getOrders({
// Include all known statuses from ORDER_STATUS_MAP to ensure we don't miss orders
const statuses = [
'created', 'pending', 'processing', 'delivered', 'cancelled',
'accepted', 'assigned', 'ready', 'picked', 'active', 'arrived'
];
// Fetch sequentially to avoid rate-limiting or proxy dropping parallel requests
const results: Row[][] = [];
for (const status of statuses) {
try {
const res = await getOrders({
tenantid: opts.tenantid,
status,
fromdate: opts.fromdate,
@@ -164,10 +201,13 @@ export function useFiestaAllOrders(opts: {
locationid: opts.locationid,
applocationid: opts.applocationid,
keyword: opts.keyword,
pagesize: 100,
}).catch(() => [] as Row[])
)
);
pagesize: 500,
});
results.push(res);
} catch (e) {
results.push([]);
}
}
// Merge and deduplicate by orderid/orderheaderid
const merged: Row[] = [];
const seen = new Set<string>();