Skip to content

SchemaEditor has no tests, and no harness to write them against #128

Closed

Description

@matt-edmondson

Problem

SchemaEditor has never had a test. Every line of it is either an ImGui draw call or logic interleaved with one, so none of it executes without a live ImGui context.

This surfaced concretely in #125: that PR added a large amount of editor code and SonarCloud's quality gate failed on 19% coverage of new code against a required 80%. Nothing was wrong with the code — there is simply no way to execute it in a test. The immediate fix there was to exclude SchemaEditor/** from Sonar's coverage measurement (it is still analysed for bugs, smells and security). That is the right scoping for UI draw code, but it means editor regressions are caught only by running the editor.

What makes this tractable

ktsu.ImGui.App ships an ImGui.App.Testing package, and ImGuiAppConfig has TestMode and TestWindow for exactly this. So a headless harness is available rather than needing to be invented.

Scope

  • A SchemaEditor.Test project. Note the editor targets net10.0 only while Schema.Test multi-targets, so this cannot simply be folded into the existing test project.
  • A headless harness that can drive frames through ImGuiApp in test mode.
  • Cover the logic that currently has none, in rough priority order:
    • AppData.RecordRecentFile - dedup, ordering, bounding. Pure logic, testable with no harness at all.
    • EditField - that a value commits once on deactivate-after-edit and not per frame, and that buffers are keyed per widget so sibling rows do not share one (the bug found by review in Editor, code generation, data sources and format versioning (#112–#122) #125).
    • SchemaEditor.Files - the unsaved-changes guard, and that Save-then-continue sequences correctly through the asynchronous file browser.
    • SchemaEditor.Diagnostics - debounce timing, GetIssueFor, and that NavigateTo selects the right element for each issue kind.
  • Once a harness exists, reconsider whether the Sonar coverage exclusion can be narrowed to just the draw-call files.

[assembly: InternalsVisibleTo("ktsu.Schema.Test")] already sits in SchemaEditor/AppData.cs, suggesting editor testing was intended at some point; the target assembly name will need revisiting.

Acceptance criteria

  • A test project exists that can drive the editor headlessly.
  • The logic listed above is covered.
  • The Sonar coverage exclusion is narrowed to what genuinely cannot be executed, or removed.

Activity

  1. added
    enhancement
    on Aug 27, 2026
  2. added 2 commits that reference this issue on Sep 4, 2026
  3. matt-edmondson commented on Sep 8, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Priority: High Effort: Medium

    What needs to be done: SchemaEditor has zero tests and no way to write any, since its logic is interleaved with ImGui draw calls. This already caused concrete friction: PR #125 tripped SonarCloud's 80%-coverage-on-new-code gate at 19%, worked around with a blanket coverage exclusion rather than a real fix. ktsu.ImGui.App's ImGui.App.Testing package (TestMode/TestWindow) makes a headless harness tractable now.

    Suggested next steps / acceptance criteria:

    • Create SchemaEditor.Test (net10.0 only, per the editor's own single-TFM constraint) with a headless ImGuiApp test-mode harness.
    • Cover the prioritized list in the issue: AppData.RecordRecentFile, EditField (the specific per-widget-buffer bug found in Editor, code generation, data sources and format versioning (#112–#122) #125 review), SchemaEditor.Files's unsaved-changes guard, and SchemaEditor.Diagnostics.
    • Narrow (or remove) the Sonar coverage exclusion once real coverage exists.
    • Fix/rename the stale InternalsVisibleTo("ktsu.Schema.Test") in SchemaEditor/AppData.cs to point at the new test project.

    Blockers / dependencies: None identified — this can start immediately and doesn't require #126/#127. Recommend sequencing it before or alongside #126 (generated data editors), since establishing the headless-harness pattern here first avoids inventing it twice if that generator turns out to emit ImGui-based UI.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions