Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

test(onboarding): pin the no-re-onboarding-after-update contract

Ruben Lütke925c242a904c
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/OnboardingGate.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/OnboardingGate.test.tsx
index 98f1dfb7f4..203fd99b53 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/OnboardingGate.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/OnboardingGate.test.tsx
@@ -45,6 +45,18 @@ it("fails open (renders nothing) on a fetch error", async () => {
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull(), { timeout: 500 });
});
+it("stays hidden when completed, even with an outdated accepted terms version", async () => {
+ // The update contract: a version bump (app or terms) must never re-open the
+ // gate — `completed` is the only signal it reads.
+ stub({
+ ...base,
+ completed: true,
+ terms: { accepted: true, accepted_version: "0.1", current_version: "9.9" },
+ });
+ render(<OnboardingGate />);
+ await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
+});
+
it("persists terms acceptance when the risk gate is accepted", async () => {
const calls: Array<[string, RequestInit | undefined]> = [];
vi.stubGlobal(
diff --git a/tests/unit/setup/test_onboarding_fastpath.py b/tests/unit/setup/test_onboarding_fastpath.py
index e62e80c69b..5eedaa198c 100644
--- a/tests/unit/setup/test_onboarding_fastpath.py
+++ b/tests/unit/setup/test_onboarding_fastpath.py
@@ -97,6 +97,25 @@ async def test_step_persists_progress(tmp_path: Path) -> None:
fp._STATE_PATH_OVERRIDE = None
+async def test_completed_survives_any_version_bump(tmp_path: Path) -> None:
+ """The update contract: NOTHING version-shaped may re-open the gate.
+
+ Completed markers set + a terms-version bump => still completed. If someone
+ ever wires a version comparison into `completed`, this fails.
+ """
+ fp._STATE_PATH_OVERRIDE = tmp_path / "setup_state.json"
+ try:
+ st.accept_terms("0.1-ancient", path=tmp_path / "setup_state.json")
+ st.mark_onboarding_complete(path=tmp_path / "setup_state.json")
+ sent, send = _collector()
+ await fp.handle(_scope("GET", "/api/onboarding/state"), _receive_empty, send)
+ payload = _body_json(sent)
+ assert payload["completed"] is True
+ assert payload["terms"]["accepted_version"] != payload["terms"]["current_version"]
+ finally:
+ fp._STATE_PATH_OVERRIDE = None
+
+
async def test_non_onboarding_path_not_handled() -> None:
sent, send = _collector()
handled = await fp.handle(_scope("GET", "/api/health"), _receive_empty, send)