|
4 | 4 | // |
5 | 5 |
|
6 | 6 | import Foundation |
7 | | -import TableProPluginKit |
8 | 7 | import SwiftUI |
| 8 | +import TableProPluginKit |
9 | 9 | import Testing |
10 | 10 |
|
11 | 11 | @testable import TablePro |
@@ -97,20 +97,41 @@ struct TableViewCoordinatorLayoutTests { |
97 | 97 | #expect(coordinator.savedColumnLayout(binding: ColumnLayoutState()) == nil) |
98 | 98 | } |
99 | 99 |
|
100 | | - @Test("Non-table tab uses the binding directly") |
101 | | - func nonTableTabUsesBinding() { |
| 100 | + @Test("Query tab drops a stale saved column order so new columns keep their query position") |
| 101 | + func queryTabDropsStaleColumnOrder() { |
102 | 102 | let coordinator = makeCoordinator( |
103 | 103 | tabType: .query, |
104 | 104 | connectionId: nil, |
105 | 105 | tableName: nil, |
106 | 106 | persister: FakeColumnLayoutPersister() |
107 | 107 | ) |
108 | | - let resolved = coordinator.savedColumnLayout(binding: nonEmptyLayout()) |
109 | | - #expect(resolved?.columnWidths == ["id": 60]) |
| 108 | + var binding = ColumnLayoutState() |
| 109 | + binding.columnWidths = ["id": 60, "business_model": 120] |
| 110 | + binding.columnOrder = ["id", "business_model"] |
| 111 | + |
| 112 | + var expected = ColumnLayoutState() |
| 113 | + expected.columnWidths = ["id": 60, "business_model": 120] |
| 114 | + |
| 115 | + #expect(coordinator.savedColumnLayout(binding: binding) == expected) |
| 116 | + } |
| 117 | + |
| 118 | + @Test("Query tab keeps remembered widths when there is no saved order") |
| 119 | + func queryTabKeepsWidths() { |
| 120 | + let coordinator = makeCoordinator( |
| 121 | + tabType: .query, |
| 122 | + connectionId: nil, |
| 123 | + tableName: nil, |
| 124 | + persister: FakeColumnLayoutPersister() |
| 125 | + ) |
| 126 | + |
| 127 | + var expected = ColumnLayoutState() |
| 128 | + expected.columnWidths = ["id": 60] |
| 129 | + |
| 130 | + #expect(coordinator.savedColumnLayout(binding: nonEmptyLayout()) == expected) |
110 | 131 | } |
111 | 132 |
|
112 | | - @Test("Non-table tab returns nil when binding is empty") |
113 | | - func nonTableTabEmptyReturnsNil() { |
| 133 | + @Test("Query tab returns nil when binding is empty") |
| 134 | + func queryTabEmptyReturnsNil() { |
114 | 135 | let coordinator = makeCoordinator( |
115 | 136 | tabType: .query, |
116 | 137 | connectionId: nil, |
|
0 commit comments