mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-25 09:24:54 +10:00
feat: add Atlas Cloud sponsorship placements
This commit is contained in:
@@ -19,6 +19,7 @@ export const flagsRouter = {
|
||||
z.object({
|
||||
disableSignups: z.boolean().describe("Whether new user signups are disabled on this instance."),
|
||||
disableEmailAuth: z.boolean().describe("Whether email-based authentication is disabled on this instance."),
|
||||
showSponsors: z.boolean().describe("Whether sponsor placements are shown on this instance."),
|
||||
}),
|
||||
)
|
||||
.handler((): FeatureFlags => flagsService.getFlags()),
|
||||
|
||||
@@ -3,6 +3,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
const envMock = vi.hoisted(() => ({
|
||||
FLAG_DISABLE_SIGNUPS: false,
|
||||
FLAG_DISABLE_EMAIL_AUTH: false,
|
||||
FLAG_SHOW_SPONSORS: false,
|
||||
}));
|
||||
|
||||
vi.mock("@reactive-resume/env/server", () => ({ env: envMock }));
|
||||
@@ -16,6 +17,7 @@ describe("flagsService.getFlags", () => {
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,6 +27,7 @@ describe("flagsService.getFlags", () => {
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: true,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,16 +37,32 @@ describe("flagsService.getFlags", () => {
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: true,
|
||||
showSponsors: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("returns showSponsors=true when env flag is set", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_DISABLE_EMAIL_AUTH = false;
|
||||
envMock.FLAG_SHOW_SPONSORS = true;
|
||||
expect(flagsService.getFlags()).toEqual({
|
||||
disableSignups: false,
|
||||
disableEmailAuth: false,
|
||||
showSponsors: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("reads the latest env values on every call (no stale cache)", () => {
|
||||
envMock.FLAG_DISABLE_SIGNUPS = false;
|
||||
envMock.FLAG_SHOW_SPONSORS = false;
|
||||
const before = flagsService.getFlags();
|
||||
envMock.FLAG_DISABLE_SIGNUPS = true;
|
||||
envMock.FLAG_SHOW_SPONSORS = true;
|
||||
const after = flagsService.getFlags();
|
||||
|
||||
expect(before.disableSignups).toBe(false);
|
||||
expect(after.disableSignups).toBe(true);
|
||||
expect(before.showSponsors).toBe(false);
|
||||
expect(after.showSponsors).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,11 +3,13 @@ import { env } from "@reactive-resume/env/server";
|
||||
export type FeatureFlags = {
|
||||
disableSignups: boolean;
|
||||
disableEmailAuth: boolean;
|
||||
showSponsors: boolean;
|
||||
};
|
||||
|
||||
export const flagsService = {
|
||||
getFlags: (): FeatureFlags => ({
|
||||
disableSignups: env.FLAG_DISABLE_SIGNUPS,
|
||||
disableEmailAuth: env.FLAG_DISABLE_EMAIL_AUTH,
|
||||
showSponsors: env.FLAG_SHOW_SPONSORS,
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user