Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const publishMock = vi.fn();
|
||||
vi.mock("@toolctrl/feature-flags", () => ({
|
||||
publishFeatureFlagInvalidationOnce: (...args: unknown[]) => publishMock(...args),
|
||||
}));
|
||||
|
||||
import { broadcastFlagInvalidation } from "./invalidate.js";
|
||||
|
||||
describe("broadcastFlagInvalidation", () => {
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
beforeEach(() => {
|
||||
publishMock.mockReset();
|
||||
publishMock.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = { ...originalEnv };
|
||||
});
|
||||
|
||||
it("forwards the flag name and defaults the sharedStoreNamespace to 'web'", async () => {
|
||||
delete process.env.FEATURE_FLAGS_PUBLISH_NAMESPACE;
|
||||
await broadcastFlagInvalidation("billing.beta");
|
||||
|
||||
expect(publishMock).toHaveBeenCalledTimes(1);
|
||||
expect(publishMock).toHaveBeenCalledWith({
|
||||
flagName: "billing.beta",
|
||||
sharedStoreNamespace: "web",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses FEATURE_FLAGS_PUBLISH_NAMESPACE when set", async () => {
|
||||
process.env.FEATURE_FLAGS_PUBLISH_NAMESPACE = "platform";
|
||||
await broadcastFlagInvalidation("billing.beta");
|
||||
|
||||
expect(publishMock).toHaveBeenCalledWith({
|
||||
flagName: "billing.beta",
|
||||
sharedStoreNamespace: "platform",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to 'web' when FEATURE_FLAGS_PUBLISH_NAMESPACE is blank", async () => {
|
||||
process.env.FEATURE_FLAGS_PUBLISH_NAMESPACE = " ";
|
||||
await broadcastFlagInvalidation("billing.beta");
|
||||
|
||||
expect(publishMock).toHaveBeenCalledWith({
|
||||
flagName: "billing.beta",
|
||||
sharedStoreNamespace: "web",
|
||||
});
|
||||
});
|
||||
|
||||
it("swallows publisher errors so the calling command still exits cleanly", async () => {
|
||||
publishMock.mockRejectedValueOnce(new Error("redis down"));
|
||||
await expect(broadcastFlagInvalidation("billing.beta")).resolves.toBeUndefined();
|
||||
expect(publishMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user