Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1995·InsForge

[Bug]: cloud-hosting-helpers.test.ts tests its own copies, so it cannot fail

Author: Chirag6722Created Aug 20, 2026Updated Sep 9, 2026

What's the bug?

backend/tests/unit/cloud-hosting-helpers.test.ts passes on every run regardless of what the production code does, because it never touches the production code.

Found while investigating #1879 (two hostname-based cloud-detection implementations). This is a third place that logic lives, and it is the one giving false assurance that it is covered.

Three things, checked against 268d79d:

It imports no production code. The only import in the file is vitest:

1:import { describe, it, expect } from 'vitest';

Everything under test is defined locally in the same file, introduced by comments that say so:

typescript
// Mirrors isCloudHostingBackend from frontend/src/cloudHostingHelpers.ts
function isCloudHostingBackend(backendUrl: string): boolean { ... }

The file it names does not exist. frontend/src/cloudHostingHelpers.ts is not in the tree. The header comment says the tests cover "the pure logic extracted from the frontend helpers", but nothing connects them to it.

One of the three functions exists nowhere in the repo at all. Occurrences outside this test file:

isCloudHostingBackend    0
getErrorMessage         19
normalizeProjectInfo     3

So isCloudHostingBackend is tested and not shipped, while getErrorMessage and normalizeProjectInfo are shipped and not tested: the test exercises its own re-implementations of them rather than the real ones.

Why it matters

A mirrored test is a test with a delay on it. Change the real normalizeProjectInfo and this file still goes green, because it is asserting against a copy that was correct whenever it was written. The failure is silent by construction, and the CI tick is indistinguishable from real coverage.

It bears directly on #1879. isCloudHostingBackend here is the same hostname.endsWith('.insforge.app') check as packages/dashboard/src/lib/utils/utils.ts:155, so anyone auditing cloud detection finds a test suite that appears to cover it and does not.

Suggested fix

Import the real functions and delete the local copies. getErrorMessage and normalizeProjectInfo exist and can be imported today. isCloudHostingBackend has to be resolved first: either it is dead and the test goes with it, or the behaviour is still wanted and it should be re-exported from wherever cloud detection ends up living once #1879 is settled.

The durable version is a rule rather than a one-off fix: a test that re-implements what it is testing should not exist. If the logic is hard to import, that is a reason to export it, not to copy it.

Environment (optional)

Commit 268d79d. Verified by reading the file and grepping the tree; I did not run the suite, since a suite that cannot fail passing is not evidence either way.

Happy to take this one if it is wanted, though the isCloudHostingBackend half probably wants to land after #1879 rather than before it.

Source: InsForge/InsForge

View original on GitHubView discussion on GitHub