fix(import): support custom issue types during import (#1322)
* fix(import): support custom issue types during import Fixes regression from7cf67153where custom issue types (agent, molecule, convoy, etc.) were rejected during import with "invalid issue type" error. - Add validateFieldUpdateWithCustom() for both custom statuses and types - Add validateIssueTypeWithCustom() for custom type validation - Update queries.go UpdateIssue() to fetch and validate custom types - Update transaction.go UpdateIssue() to fetch and validate custom types - Add 15 test cases covering custom type validation scenarios This aligns UpdateIssue() validation with the federation trust model used by ValidateForImport(). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix(test): add metadata.json and chdir to temp dir in direct mode tests Fixes three test failures caused by commite82f5136which changed ensureStoreActive() to use factory.NewFromConfig() instead of respecting the global dbPath variable. Root cause: - Tests create issues in test.db and set dbPath = testDBPath - ensureStoreActive() calls factory.NewFromConfig() which reads metadata.json - Without metadata.json, it defaults to beads.db - Opens empty beads.db instead of test.db with the seeded issues - Additionally, FindBeadsDir() was finding the real .beads dir, not the test one Fixes applied: 1. TestFallbackToDirectModeEnablesFlush: Add metadata.json pointing to test.db and chdir to temp dir 2. TestImportFromJSONLInlineAfterDaemonDisconnect: Same fix 3. TestIsBeadsPluginInstalledProjectLevel: Set temp HOME to avoid detecting plugin from real ~/.claude/settings.json All three tests now pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,22 @@ func TestFallbackToDirectModeEnablesFlush(t *testing.T) {
|
||||
}
|
||||
testDBPath := filepath.Join(beadsDir, "test.db")
|
||||
|
||||
// Create metadata.json so factory.NewFromConfig knows which DB to open (GH#e82f5136)
|
||||
metadataJSON := `{"database":"test.db","jsonl_export":"issues.jsonl"}`
|
||||
if err := os.WriteFile(filepath.Join(beadsDir, "metadata.json"), []byte(metadataJSON), 0644); err != nil {
|
||||
t.Fatalf("failed to create metadata.json: %v", err)
|
||||
}
|
||||
|
||||
// Change to temp directory so FindBeadsDir finds our test .beads directory
|
||||
originalWd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get working directory: %v", err)
|
||||
}
|
||||
if err := os.Chdir(tmpDir); err != nil {
|
||||
t.Fatalf("failed to change to temp directory: %v", err)
|
||||
}
|
||||
defer os.Chdir(originalWd)
|
||||
|
||||
// Seed database with issues
|
||||
setupStore := newTestStore(t, testDBPath)
|
||||
|
||||
@@ -193,6 +209,22 @@ func TestImportFromJSONLInlineAfterDaemonDisconnect(t *testing.T) {
|
||||
testDBPath := filepath.Join(beadsDir, "beads.db")
|
||||
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
|
||||
|
||||
// Create metadata.json so factory.NewFromConfig knows which DB to open (GH#e82f5136)
|
||||
metadataJSON := `{"database":"beads.db","jsonl_export":"issues.jsonl"}`
|
||||
if err := os.WriteFile(filepath.Join(beadsDir, "metadata.json"), []byte(metadataJSON), 0644); err != nil {
|
||||
t.Fatalf("failed to create metadata.json: %v", err)
|
||||
}
|
||||
|
||||
// Change to temp directory so FindBeadsDir finds our test .beads directory
|
||||
originalWd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get working directory: %v", err)
|
||||
}
|
||||
if err := os.Chdir(tmpDir); err != nil {
|
||||
t.Fatalf("failed to change to temp directory: %v", err)
|
||||
}
|
||||
defer os.Chdir(originalWd)
|
||||
|
||||
// Create and seed the database
|
||||
setupStore := newTestStore(t, testDBPath)
|
||||
issue := &types.Issue{
|
||||
|
||||
@@ -262,6 +262,9 @@ func TestIsBeadsPluginInstalledProjectLevel(t *testing.T) {
|
||||
t.Run("plugin disabled", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
t.Chdir(tmpDir)
|
||||
// Set temp home to avoid detecting plugin from real ~/.claude/settings.json
|
||||
t.Setenv("HOME", tmpDir)
|
||||
t.Setenv("USERPROFILE", tmpDir)
|
||||
|
||||
if err := os.MkdirAll(".claude", 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -279,6 +282,9 @@ func TestIsBeadsPluginInstalledProjectLevel(t *testing.T) {
|
||||
t.Run("no plugin section", func(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
t.Chdir(tmpDir)
|
||||
// Set temp home to avoid detecting plugin from real ~/.claude/settings.json
|
||||
t.Setenv("HOME", tmpDir)
|
||||
t.Setenv("USERPROFILE", tmpDir)
|
||||
|
||||
if err := os.MkdirAll(".claude", 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user