Skip to content

Commit d8c143c

Browse files
committed
test(datagrid): fix EvictionTests — selected tab is intentionally not evicted
`evictInactiveRowData` deliberately skips the currently selected tab ("kept in memory so the user sees no refresh flicker"), but the migrated tests added a tab and immediately called eviction — the new tab was the selected tab, so eviction was a no-op and the assertions failed. Fix: add a second tab so the first becomes background, then assert eviction on the background tab.
1 parent 59acea1 commit d8c143c

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

TableProTests/Views/Main/EvictionTests.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,21 @@ struct EvictionTests {
4545
tabManager.tabs[index].execution.lastExecutedAt = Date()
4646
}
4747

48-
@Test("evictInactiveRowData evicts loaded tabs without pending changes")
48+
@Test("evictInactiveRowData evicts background tabs without pending changes")
4949
func evictsLoadedTabs() {
5050
let (coordinator, tabManager) = makeCoordinator()
5151
addLoadedTab(to: coordinator, tabManager: tabManager, tableName: "users")
52-
let tabId = tabManager.tabs[0].id
52+
let backgroundTabId = tabManager.tabs[0].id
53+
// Add a second tab so the first becomes background (eviction skips the selected tab)
54+
addLoadedTab(to: coordinator, tabManager: tabManager, tableName: "orders")
5355

54-
#expect(coordinator.tableRowsStore.tableRows(for: tabId).rows.count == 10)
55-
#expect(coordinator.tableRowsStore.isEvicted(tabId) == false)
56+
#expect(coordinator.tableRowsStore.tableRows(for: backgroundTabId).rows.count == 10)
57+
#expect(coordinator.tableRowsStore.isEvicted(backgroundTabId) == false)
5658

5759
coordinator.evictInactiveRowData()
5860

59-
#expect(coordinator.tableRowsStore.isEvicted(tabId) == true)
60-
#expect(coordinator.tableRowsStore.tableRows(for: tabId).rows.isEmpty)
61+
#expect(coordinator.tableRowsStore.isEvicted(backgroundTabId) == true)
62+
#expect(coordinator.tableRowsStore.tableRows(for: backgroundTabId).rows.isEmpty)
6163
}
6264

6365
@Test("evictInactiveRowData skips tabs with pending changes")
@@ -78,13 +80,14 @@ struct EvictionTests {
7880
func preservesMetadataAfterEviction() {
7981
let (coordinator, tabManager) = makeCoordinator()
8082
addLoadedTab(to: coordinator, tabManager: tabManager, tableName: "users")
83+
let backgroundTabId = tabManager.tabs[0].id
84+
addLoadedTab(to: coordinator, tabManager: tabManager, tableName: "orders")
8185

8286
coordinator.evictInactiveRowData()
8387

84-
let tabId = tabManager.tabs[0].id
85-
let rows = coordinator.tableRowsStore.tableRows(for: tabId)
88+
let rows = coordinator.tableRowsStore.tableRows(for: backgroundTabId)
8689
#expect(rows.columns == ["id", "name", "email"])
87-
#expect(coordinator.tableRowsStore.isEvicted(tabId) == true)
90+
#expect(coordinator.tableRowsStore.isEvicted(backgroundTabId) == true)
8891
}
8992

9093
@Test("evictInactiveRowData with no tabs is no-op")

0 commit comments

Comments
 (0)