feat(demo): add the jury guide and demonstration markers to the demo stand build
This commit is contained in:
1 parent
d365a05c96
commit
41206abbcf
32 files changed
+1096
-141
No files matched your search
@@ -1 +1,2 @@
|
||||
export { paths } from "./paths";
|
||||
export { standMode, standModeFrom, type StandMode } from "./stand";
|
||||
@@ -9,6 +9,8 @@ export const paths = {
|
||||
verifyEmail: "/verify-email",
|
||||
support: "/support",
|
||||
status: "/status",
|
||||
/** Jury guide of the demonstration stand; the route exists only in a demo build. */
|
||||
demoGuide: "/demo",
|
||||
candidate: {
|
||||
root: "/candidate",
|
||||
onboarding: "/candidate/onboarding",
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { standModeFrom } from "./stand";
|
||||
|
||||
describe("standModeFrom", () => {
|
||||
it("turns the demonstration mode on only for the literal value true", () => {
|
||||
expect(standModeFrom({ VITE_DEMO_STAND: "true" })).toEqual({ demo: true });
|
||||
});
|
||||
|
||||
it("keeps the mode off when the build sets no flag", () => {
|
||||
expect(standModeFrom({})).toEqual({ demo: false });
|
||||
});
|
||||
|
||||
it.each(["false", "", "TRUE", "1", "yes"])("keeps the mode off for %j", (value) => {
|
||||
expect(standModeFrom({ VITE_DEMO_STAND: value }).demo).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Mode of the running build. Builds that serve synthetic demonstration data
|
||||
* set VITE_DEMO_STAND to "true": the isolated demonstration stand through
|
||||
* deploy/docker/docker-compose.demo.yml, and the browser suite through
|
||||
* deploy/docker/docker-compose.e2e.yml. Other builds leave it unset, so the
|
||||
* jury guide and the demonstration banner are not part of them.
|
||||
*/
|
||||
export type StandMode = {
|
||||
/** True only for a build that serves synthetic demonstration data. */
|
||||
readonly demo: boolean;
|
||||
};
|
||||
|
||||
/** Reads the mode from build-time environment values; testable without Vite. */
|
||||
export function standModeFrom(env: Readonly<Record<string, unknown>>): StandMode {
|
||||
return { demo: env.VITE_DEMO_STAND === "true" };
|
||||
}
|
||||
|
||||
export const standMode: StandMode = standModeFrom(import.meta.env);
|
||||
Reference in new issue
Block a user