caelum0x 994f2d1a31 feat(relay): drop upstream marketing, Relay UI naming, pinned docs links, Autopilot off
README rewritten with engine features, not-available list and Apache-2.0
attribution (forked from TensorZero 2026.6.0). UI status indicator, logger
prefix and warnings renamed to Relay (RELAY_UI_LOG_LEVEL with legacy alias).
Help links resolve via docs-url.ts to pinned engine docs (VITE_RELAY_DOCS_URL
override); fixed SFT link. /autopilot always shows the unavailable page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:23:22 +03:00

58 lines
1.9 KiB
TypeScript

import { expect, test, vi } from "vitest";
import { pollForFeedbackItem } from "./feedback";
import { getTensorZeroClient } from "~/utils/tensorzero.server";
test("pollForFeedbackItem should find feedback when it exists", async () => {
const targetId = "01942e26-4693-7e80-8591-47b98e25d721";
const limit = 10;
const tensorZeroClient = getTensorZeroClient();
// Run the getFeedbackByTargetId function to return feedback with the target ID
const originalQueryFeedback = await tensorZeroClient.getFeedbackByTargetId(
targetId,
{ limit },
);
// Ensure we have feedback to test with
expect(originalQueryFeedback.length).toBeGreaterThan(0);
// Use the first feedback item's ID for our test
const existingFeedbackId = originalQueryFeedback[0].id;
// Poll for the existing feedback item
const feedback = await pollForFeedbackItem(
targetId,
existingFeedbackId,
limit,
3, // Fewer retries for faster test
50, // Shorter delay for faster test
);
// Verify the feedback was found
expect(feedback.length).toBeGreaterThan(0);
expect(feedback.some((f) => f.id === existingFeedbackId)).toBe(true);
// Test with non-existent feedback ID
const nonExistentId = "non-existent-feedback-id";
const consoleSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
const emptyFeedback = await pollForFeedbackItem(
targetId,
nonExistentId,
limit,
2, // Fewer retries for faster test
50, // Shorter delay for faster test
);
// Verify warning was logged
expect(consoleSpy).toHaveBeenCalledWith(
`[Relay UI ${__APP_VERSION__}] Feedback ${nonExistentId} for target ${targetId} not found after 2 retries.`,
);
// Verify we still get feedback for the target, even though specific item wasn't found
expect(emptyFeedback.length).toBeGreaterThan(0);
expect(emptyFeedback.some((f) => f.id === nonExistentId)).toBe(false);
consoleSpy.mockRestore();
});