Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

test(redis): clear stale detail editor on rebind

Tobi9bbb9d34fbf9
diff --git a/macos/Tests/GridexTests/RedisDataGridLifecycleTests.swift b/macos/Tests/GridexTests/RedisDataGridLifecycleTests.swift
index 909e492..c948356 100644
--- a/macos/Tests/GridexTests/RedisDataGridLifecycleTests.swift
+++ b/macos/Tests/GridexTests/RedisDataGridLifecycleTests.swift
@@ -32,6 +32,22 @@ final class RedisDataGridLifecycleTests: XCTestCase {
XCTAssertNil(appState.statusRowCount)
}
+ func test_rebindingSameRedisContextClearsStaleDetailEditorState() {
+ let appState = AppState()
+ let state = DataGridViewState()
+ let context = redisContext(databaseName: "db0", revision: 1)
+ state.appState = appState
+ state.bindRedisContext(context)
+
+ appState.selectedRowDetails = [(column: "name", value: "obsolete")]
+ appState.onDetailFieldEdit = { _, _ in }
+
+ state.bindRedisContext(context)
+
+ XCTAssertNil(appState.selectedRowDetails)
+ XCTAssertNil(appState.onDetailFieldEdit)
+ }
+
func test_redisContextMakesGridReadOnlyAndAllMutationEntryPointsNoOp() async {
let state = DataGridViewState()
state.bindRedisContext(redisContext(databaseName: "db0", revision: 1))