Skip to content

Test suite is a single tautological assertion — zero business logic, classification, or Edge Function behavior is tested #12

@tg12

Description

@tg12

Summary

The project's test suite consists of a single file containing one assertion: expect(true).toBe(true). No business logic, no Edge Function behavior, no data model, no component, and no utility function is tested. The test suite is a placeholder that was never replaced with real tests.

Evidence

src/test/example.test.ts (the entire test file):

import { describe, it, expect } from "vitest";

describe("example", () => {
  it("should pass", () => {
    expect(true).toBe(true);
  });
});

src/test/setup.ts contains only the jsdom setup boilerplate. There are no other test files in the project.

package.json defines "test": "vitest run" — running npm test produces 1 passing test that asserts a tautology. CI (if any) would show a green check that means nothing.

Functions with zero test coverage include:

  • All 8 Edge Functions (TypeScript/Deno)
  • src/integrations/supabase/client.ts — Supabase client initialization
  • src/data/fields.ts — data model and helper functions (haToAcres)
  • src/lib/utils.ts — utility functions
  • All React components
  • soil-data's classification logic (classifySoil, usdaTexture, phRating)

Why this matters

  1. No regression safety net: Any change to the GEE expression builders, soil classification logic, or data transformations can silently break production behavior with zero test failure.
  2. False CI confidence: If CI runs npm test, it reports green. A reviewer or automated tool that checks "are tests passing?" will incorrectly conclude the codebase is tested.
  3. Classification correctness unverified: classifySoil uses several overlapping numerical thresholds for soil type classification. Without tests, it is impossible to verify that the correct soil type is returned for boundary values, or that the USDA texture triangle logic (usdaTexture) correctly classifies soil fractions.
  4. haToAcres conversion factor untested: The conversion function Math.round(ha * 2.47105 * 10) / 10 has rounding behavior that affects displayed field sizes; this is not tested.

Root cause

The project was scaffolded by Lovable with a placeholder test file that was never developed. The vitest.config.ts is correctly configured; the tooling is in place, but no actual tests were written.

Recommended fix

Replace the placeholder with meaningful tests, prioritizing correctness-critical pure functions first:

1. Soil classification (pure functions, easiest to test):

// src/test/soil-classification.test.ts
import { describe, it, expect } from "vitest";
// import classifySoil, usdaTexture etc. from the shared module once extracted

describe("usdaTexture", () => {
  it("returns Clay when clay >= 40%", () => { ... });
  it("returns Sand when sand >= 85%", () => { ... });
  it("handles null inputs", () => { ... });
});

2. haToAcres conversion:

it("converts 1 hectare to 2.5 acres (rounded)", () => {
  expect(haToAcres(1)).toBe(2.5);
});

3. Edge Function input validation (once extracted to shared module):

it("rejects polygons with < 4 vertices", () => { ... });
it("rejects coordinates outside [-180,180]", () => { ... });

Acceptance criteria

  • npm test runs more than one tautological assertion
  • classifySoil and usdaTexture have test coverage for at least the main branches
  • haToAcres is tested with known values
  • The placeholder expect(true).toBe(true) test is removed or replaced

Suggested labels

bug

Priority

P3

Severity

Low — not a security issue, but a correctness and maintenance risk. Classification bugs will reach users silently.

Confidence

Confirmed — src/test/example.test.ts is the only test file in the repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions