All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { WidgetsController } from "./widgets.controller";
|
|
|
|
const THROTTLER_SKIP_DEFAULT_KEY = "THROTTLER:SKIPdefault";
|
|
|
|
describe("WidgetsController throttler metadata", () => {
|
|
it("marks widget data polling endpoints to skip throttling", () => {
|
|
const pollingHandlers = [
|
|
WidgetsController.prototype.getStatCardData,
|
|
WidgetsController.prototype.getChartData,
|
|
WidgetsController.prototype.getListData,
|
|
WidgetsController.prototype.getCalendarPreviewData,
|
|
WidgetsController.prototype.getActiveProjectsData,
|
|
WidgetsController.prototype.getAgentChainsData,
|
|
];
|
|
|
|
for (const handler of pollingHandlers) {
|
|
expect(Reflect.getMetadata(THROTTLER_SKIP_DEFAULT_KEY, handler)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("does not skip throttling for non-polling widget routes", () => {
|
|
expect(
|
|
Reflect.getMetadata(THROTTLER_SKIP_DEFAULT_KEY, WidgetsController.prototype.findAll)
|
|
).toBe(undefined);
|
|
|
|
expect(
|
|
Reflect.getMetadata(THROTTLER_SKIP_DEFAULT_KEY, WidgetsController.prototype.findByName)
|
|
).toBe(undefined);
|
|
});
|
|
});
|