From 1361dba309489ce6bed3c011342725073a8ab232 Mon Sep 17 00:00:00 2001 From: mayuriphad Date: Mon, 5 Oct 2026 14:56:52 +0530 Subject: [PATCH] fix(test): register action-retrier at the nested component path The component installs action-retrier as a child, so an app that uses r2 resolves it at "/actionRetrier". register() in the test helper registered it at the top-level "actionRetrier", so deleteObject and store threw `Component "r2/actionRetrier" is not registered` in tests that follow the documented r2Test.register(t) pattern. Register it under `${name}/actionRetrier` and add a test for the default and a custom component name. Fixes #72 --- src/test.test.ts | 35 +++++++++++++++++++++++++++++++++++ src/test.ts | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/test.test.ts diff --git a/src/test.test.ts b/src/test.test.ts new file mode 100644 index 0000000..2fca0e1 --- /dev/null +++ b/src/test.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it, vi } from "vitest"; +import type { TestConvex } from "convex-test"; +import type { GenericSchema, SchemaDefinition } from "convex/server"; +import r2Test from "./test.js"; + +type TestInstance = TestConvex>; + +function registeredNames(name?: string) { + const registerComponent = vi.fn(); + const t = { registerComponent } as unknown as TestInstance; + if (name === undefined) { + r2Test.register(t); + } else { + r2Test.register(t, name); + } + return registerComponent.mock.calls.map((call) => call[0] as string); +} + +describe("register", () => { + it("registers action-retrier as a child of the r2 component", () => { + const names = registeredNames(); + + expect(names).toContain("r2"); + expect(names).toContain("r2/actionRetrier"); + expect(names).not.toContain("actionRetrier"); + }); + + it("nests action-retrier under a custom component name", () => { + const names = registeredNames("storage"); + + expect(names).toContain("storage"); + expect(names).toContain("storage/actionRetrier"); + expect(names).not.toContain("actionRetrier"); + }); +}); diff --git a/src/test.ts b/src/test.ts index e12d1ee..1ca137c 100644 --- a/src/test.ts +++ b/src/test.ts @@ -15,6 +15,7 @@ export function register( name: string = "r2", ) { t.registerComponent(name, schema, modules); - actionRetrier.register(t); + // The component installs action-retrier as a child, so it lives at "/actionRetrier". + actionRetrier.register(t, `${name}/actionRetrier`); } export default { register, schema, modules };