Skip to content

Commit 0a80321

Browse files
committed
test(datagrid): rewrite clearSort no-op test without inconsistent cache setup
1 parent a164f1d commit 0a80321

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

TableProTests/Views/Main/MainContentCoordinatorSortTests.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,18 @@ struct MainContentCoordinatorSortTests {
256256
#expect(tabManager.tabs[idx].sortState.columns.isEmpty)
257257
}
258258

259-
@Test("clearSort on an unsorted tab is a no-op")
259+
@Test("clearSort on an unsorted tab does not crash and leaves sort state empty")
260260
func clearSortIsNoOpWhenUnsorted() {
261-
let (coordinator, _, tabId) = makeCoordinator()
261+
let (coordinator, tabManager, tabId) = makeCoordinator()
262262
seedRows(coordinator, for: tabId)
263263

264-
coordinator.querySortCache[tabId] = QuerySortCacheEntry(
265-
sortedIDs: [.existing(0)],
266-
columnIndex: 0,
267-
direction: .ascending,
268-
schemaVersion: 0
269-
)
270-
271264
coordinator.clearSort()
272265

273-
#expect(coordinator.querySortCache[tabId] != nil)
266+
guard let idx = tabManager.tabs.firstIndex(where: { $0.id == tabId }) else {
267+
Issue.record("Expected tab to exist")
268+
return
269+
}
270+
#expect(tabManager.tabs[idx].sortState.columns.isEmpty)
274271
}
275272

276273
@Test("cleanupSortCache drops entries for tabs that are no longer open")

0 commit comments

Comments
 (0)