feat(ui): add RepoImportModalViewModel with candidate merge logic
This commit is contained in:
48
tests/ClaudeDo.Ui.Tests/RepoImportCandidatesTests.cs
Normal file
48
tests/ClaudeDo.Ui.Tests/RepoImportCandidatesTests.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using ClaudeDo.Ui.Services;
|
||||
using ClaudeDo.Ui.ViewModels.Modals;
|
||||
|
||||
namespace ClaudeDo.Ui.Tests;
|
||||
|
||||
public sealed class RepoImportCandidatesTests
|
||||
{
|
||||
[Fact]
|
||||
public void BuildCandidates_NewRepo_IsCheckedAndNotAlreadyAdded()
|
||||
{
|
||||
var found = new[] { new RepoCandidate("repo-a", @"C:\src\repo-a") };
|
||||
var current = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var existing = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var items = RepoImportModalViewModel.BuildCandidates(found, current, existing);
|
||||
|
||||
Assert.Single(items);
|
||||
Assert.True(items[0].IsChecked);
|
||||
Assert.False(items[0].AlreadyAdded);
|
||||
Assert.Equal("repo-a", items[0].Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildCandidates_ExistingWorkingDir_IsMarkedAlreadyAdded()
|
||||
{
|
||||
var found = new[] { new RepoCandidate("repo-a", @"C:\src\repo-a") };
|
||||
var current = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var existing = new HashSet<string>(new[] { @"c:\src\repo-a" }, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var items = RepoImportModalViewModel.BuildCandidates(found, current, existing);
|
||||
|
||||
Assert.Single(items);
|
||||
Assert.True(items[0].AlreadyAdded);
|
||||
Assert.True(items[0].IsChecked); // already-added rows render ticked
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildCandidates_SkipsPathsAlreadyShown()
|
||||
{
|
||||
var found = new[] { new RepoCandidate("repo-a", @"C:\src\repo-a") };
|
||||
var current = new HashSet<string>(new[] { @"c:\src\repo-a" }, StringComparer.OrdinalIgnoreCase);
|
||||
var existing = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var items = RepoImportModalViewModel.BuildCandidates(found, current, existing);
|
||||
|
||||
Assert.Empty(items);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user