All files / lib/feedback memory.ts

0% Statements 0/23
100% Branches 1/1
100% Functions 1/1
0% Lines 0/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                         
import type { FeedbackEvent } from './types';
 
type TimelineEvent = FeedbackEvent & {
  result?: any;
  blockedBy?: string | null;
};
 
const timeline: TimelineEvent[] = [];
 
// alias مطابق لكل الأسماء المستخدمة في التيستات
export async function recordFeedback(e: TimelineEvent) {
  timeline.push(e);
}
 
export async function record(e: TimelineEvent) {
  return recordFeedback(e);
}
 
export function getTimeline() {
  return timeline;
}
 
export function clearTimeline() {
  timeline.length = 0;
}
 
// إرجاع آخر أكشنات من نوع معيّن
export function lastActions(kind: string) {
  return timeline
    .map((t) => t.chosenAction)
    .filter(Boolean)
    .filter((a) => a!.kind === kind);
}
 
// alias لاسم بديل ظهر في بعض التيستات
export const getLastActions = lastActions;