|
| 1 | +import { readFileSync } from "node:fs"; |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | +import { compilePine } from "../lib/compiler"; |
| 4 | +import { defaultConfig } from "../lib/defaults"; |
| 5 | +import { toPublicIndicatorConfig } from "../lib/public-indicator-config"; |
| 6 | + |
| 7 | +const clone = <T,>(value: T): T => JSON.parse(JSON.stringify(value)); |
| 8 | + |
| 9 | +describe("public indicator-only product", () => { |
| 10 | + it("forces stale Strategy mode state back to Indicator before generation", () => { |
| 11 | + const stale = clone(defaultConfig); |
| 12 | + stale.outputMode = "strategy"; |
| 13 | + const publicConfig = toPublicIndicatorConfig(stale); |
| 14 | + const code = compilePine(publicConfig); |
| 15 | + |
| 16 | + expect(publicConfig.outputMode).toBe("indicator"); |
| 17 | + expect(code).toContain("indicator("); |
| 18 | + expect(code).not.toContain("strategy("); |
| 19 | + expect(code).not.toContain("strategy.entry"); |
| 20 | + expect(code).not.toContain("strategy.exit"); |
| 21 | + }); |
| 22 | + |
| 23 | + it("does not expose an Output or Strategy Tester selector in the public page", () => { |
| 24 | + const page = readFileSync("app/page.tsx", "utf8"); |
| 25 | + |
| 26 | + expect(page).not.toContain('label="Output"'); |
| 27 | + expect(page).not.toContain("Strategy Tester"); |
| 28 | + expect(page).toContain("Indicator only:"); |
| 29 | + expect(page).toContain("toPublicIndicatorConfig(clone(preset))"); |
| 30 | + }); |
| 31 | +}); |
0 commit comments