diff --git a/test-int/cli/test_project_commands_integration.py b/test-int/cli/test_project_commands_integration.py index 920e52d1..bc99ca17 100644 --- a/test-int/cli/test_project_commands_integration.py +++ b/test-int/cli/test_project_commands_integration.py @@ -119,3 +119,52 @@ def test_project_set_default(app_config, config_manager): for line in lines: if "another-project" in line: assert "✓" in line + + +def test_remove_default_project_issue_397(app_config, config_manager): + """Test that removed default project doesn't appear in list (issue #397). + + Reproduces bug where 'main' project still shows in 'bm project list' + after being removed. + """ + runner = CliRunner() + + # Use a separate temporary directory to avoid nested path conflicts + with tempfile.TemporaryDirectory() as temp_dir: + new_project_path = Path(temp_dir) / "newmain" + new_project_path.mkdir() + + # Step 1: Add a new project + result = runner.invoke(app, ["project", "add", "newmain", str(new_project_path)]) + if result.exit_code != 0: + print(f"STDOUT: {result.stdout}") + print(f"STDERR: {result.stderr}") + assert result.exit_code == 0 + + # Step 2: Set the new project as default + result = runner.invoke(app, ["project", "default", "newmain"]) + if result.exit_code != 0: + print(f"STDOUT: {result.stdout}") + print(f"STDERR: {result.stderr}") + assert result.exit_code == 0 + + # Step 3: Remove the original default project (test-project acts as "main") + result = runner.invoke(app, ["project", "remove", "test-project"]) + if result.exit_code != 0: + print(f"STDOUT: {result.stdout}") + print(f"STDERR: {result.stderr}") + assert result.exit_code == 0 + + # Step 4: Verify test-project is NOT in the list + result = runner.invoke(app, ["project", "list"]) + if result.exit_code != 0: + print(f"STDOUT: {result.stdout}") + print(f"STDERR: {result.stderr}") + assert result.exit_code == 0 + + # Bug: test-project still appears in list after removal + # Expected: test-project should NOT be in the output + assert "test-project" not in result.stdout, ( + f"Bug reproduced: 'test-project' still appears in list after removal.\n" + f"Output:\n{result.stdout}" + )