import Foundation
import Testing
@testable import Kanban

/// **The board popover's git-note detection** (12-editions.md ▸ The free tier and `.git`, ruled
/// 2026-07-27): the free tier's whole git story is one line, shown only on a board that carries an
/// inert `.git`. The seam
/// that decides *whether* to show it — `BoardGitNote.hasGitDirectory(at:)` — is a pure, read-only
/// `FileManager` check, pinned here against real bytes on disk. Everything else about the note (its
/// wording, its placement in `BoardInfoView`) is SwiftUI rendering and deliberately untested.
struct BoardInfoPopoverTests {

    @Test("A board with a .git at its root reports true")
    func trueForABoardWithGit() throws {
        let fixture = try WriterFixture()
        defer { fixture.tearDown() }

        try fixture.item("", Item.board)
        try fixture.file(".git/HEAD", Data("ref: refs/heads/main\n".utf8))

        #expect(BoardGitNote.hasGitDirectory(at: fixture.root))
    }

    @Test("An ordinary board with no .git reports false")
    func falseForAnOrdinaryBoard() throws {
        let fixture = try WriterFixture()
        defer { fixture.tearDown() }

        try fixture.item("", Item.board)

        #expect(!BoardGitNote.hasGitDirectory(at: fixture.root))
    }
}
