Commit f690cb4f54
Unsigned
Layout: unified · split
DomainDataPortabilityService.swift −4
| @@ -758,10 +758,6 @@ enum DomainDataPortabilityService { | ||
| 758 | 758 | /// reads it; nothing else should. |
| 759 | 759 | static let legacyHistoryBlobKey = StorageKey.history |
| 760 | 760 | |
| 761 | /// The hard ceiling on history, independent of the user's auto-prune | |
| 762 | /// setting. The per-tier retention dial D1 settled on (50/250/2000) | |
| 763 | /// replaces this constant; until then every tier shares it. | |
| 764 | static let historyStorageCap = 250 | |
| 765 | 761 | |
| 766 | 762 | |
| 767 | 763 | static func loadAuditSessions(defaults: UserDefaults = .standard) -> [AuditSession] { |
DomainDig/DomainMonitoringService.swift +6 −4
| @@ -259,7 +259,6 @@ final class DomainMonitoringService { | ||
| 259 | 259 | static let shared = DomainMonitoringService() |
| 260 | 260 | |
| 261 | 261 | private let inspectionService = DomainInspectionService() |
| 262 | private let maxHistoryEntries = 250 | |
| 263 | 262 | private let calendar = Calendar.current |
| 264 | 263 | |
| 265 | 264 | func performMonitoring( |
| @@ -599,10 +598,13 @@ final class DomainMonitoringService { | ||
| 599 | 598 | failures: .init(snapshot: snapshot) |
| 600 | 599 | ) |
| 601 | 600 | |
| 601 | // Same retention rule as the view model's: the tier's limit, but never | |
| 602 | // below what is already stored, so a monitoring run on a lapsed Pro+ | |
| 603 | // install does not prune a history the app itself would keep. Read | |
| 604 | // before the insert, or the row being added raises its own ceiling. | |
| 605 | let storedLimit = max(FeatureAccessService.historyRetentionLimit, history.count) | |
| 602 | 606 | history.insert(entry, at: 0) |
| 603 | if history.count > maxHistoryEntries { | |
| 604 | history = Array(history.prefix(maxHistoryEntries)) | |
| 605 | } | |
| 607 | history = Array(history.prefix(storedLimit)) | |
| 606 | 608 | |
| 607 | 609 | if let index = trackedDomains.firstIndex(where: { $0.id == trackedDomainID }) { |
| 608 | 610 | trackedDomains[index].lastSnapshotID = entry.id |
DomainDig/DomainViewModel.swift +74 −28
| @@ -302,7 +302,6 @@ final class DomainViewModel { | ||
| 302 | 302 | var trackedDomains: [TrackedDomain] |
| 303 | 303 | |
| 304 | 304 | private static let historyKey = "lookupHistory" |
| 305 | private static let maxHistory = 250 | |
| 306 | 305 | var history: [HistoryEntry] |
| 307 | 306 | var auditSessions: [AuditSession] |
| 308 | 307 | private static let workflowsKey = "domainWorkflows" |
| @@ -859,7 +858,7 @@ final class DomainViewModel { | ||
| 859 | 858 | } |
| 860 | 859 | } |
| 861 | 860 | persistTrackedDomains() |
| 862 | relinked.forEach { storeHistoryEntry($0, replacingExisting: true) } | |
| 861 | relinked.forEach { updateStoredHistory($0) } | |
| 863 | 862 | sanitizeMonitoringSelection() |
| 864 | 863 | } |
| 865 | 864 | |
| @@ -875,7 +874,7 @@ final class DomainViewModel { | ||
| 875 | 874 | } |
| 876 | 875 | } |
| 877 | 876 | persistTrackedDomains() |
| 878 | relinked.forEach { storeHistoryEntry($0, replacingExisting: true) } | |
| 877 | relinked.forEach { updateStoredHistory($0) } | |
| 879 | 878 | sanitizeMonitoringSelection() |
| 880 | 879 | } |
| 881 | 880 | |
| @@ -1809,6 +1808,9 @@ final class DomainViewModel { | ||
| 1809 | 1808 | currentHistoryEntryID = entry.id |
| 1810 | 1809 | } |
| 1811 | 1810 | |
| 1811 | // Before the insert: afterwards `history.count` includes this entry | |
| 1812 | // and `growthHistoryLimit` would never prune anything. | |
| 1813 | let storedLimit = growthHistoryLimit | |
| 1812 | 1814 | let replacedLatest = replaceLatest |
| 1813 | 1815 | && !history.isEmpty |
| 1814 | 1816 | && history[0].domain.caseInsensitiveCompare(snapshot.domain) == .orderedSame |
| @@ -1816,7 +1818,7 @@ final class DomainViewModel { | ||
| 1816 | 1818 | history[0] = entry |
| 1817 | 1819 | } else { |
| 1818 | 1820 | history.insert(entry, at: 0) |
| 1819 | trimHistoryToLimit() | |
| 1821 | history = Array(history.prefix(storedLimit)) | |
| 1820 | 1822 | } |
| 1821 | 1823 | |
| 1822 | 1824 | updateTrackedDomainSnapshotMetadata( |
| @@ -1829,7 +1831,11 @@ final class DomainViewModel { | ||
| 1829 | 1831 | certificateWarningLevel: DomainDiffService.certificateWarningLevel(for: snapshot), |
| 1830 | 1832 | certificateDaysRemaining: snapshot.sslInfo?.daysUntilExpiry |
| 1831 | 1833 | ) |
| 1832 | storeHistoryEntry(entry, replacingExisting: replacedLatest) | |
| 1834 | if replacedLatest { | |
| 1835 | updateStoredHistory(entry) | |
| 1836 | } else { | |
| 1837 | appendStoredHistory(entry, cap: storedLimit) | |
| 1838 | } | |
| 1833 | 1839 | notifyIfNeeded(for: entry, snapshot: snapshot, previousSnapshot: previousSnapshot) |
| 1834 | 1840 | return entry |
| 1835 | 1841 | } |
| @@ -1837,25 +1843,34 @@ final class DomainViewModel { | ||
| 1837 | 1843 | /// A single snapshot written on its own. `persistHistory` rewrites every |
| 1838 | 1844 | /// row because it cannot tell what changed; these callers can, and at the |
| 1839 | 1845 | /// Pro+ cap that is the difference between 23 ms and 656 ms. |
| 1840 | private func storeHistoryEntry(_ entry: HistoryEntry, replacingExisting: Bool) { | |
| 1846 | /// Replaces one stored snapshot. No cap: an update changes a row that is | |
| 1847 | /// already there and cannot push the store past its limit. | |
| 1848 | private func updateStoredHistory(_ entry: HistoryEntry) { | |
| 1841 | 1849 | if historyPersistenceSuspended { |
| 1842 | 1850 | historyPersistenceDirty = true |
| 1843 | 1851 | return |
| 1844 | 1852 | } |
| 1845 | if replacingExisting { | |
| 1846 | DomainDataPortabilityService.updateHistoryEntry( | |
| 1847 | entry, | |
| 1848 | defaults: defaults, | |
| 1849 | historyLocation: historyLocation | |
| 1850 | ) | |
| 1851 | } else { | |
| 1852 | DomainDataPortabilityService.appendHistoryEntry( | |
| 1853 | entry, | |
| 1854 | cap: effectiveHistoryLimit, | |
| 1855 | defaults: defaults, | |
| 1856 | historyLocation: historyLocation | |
| 1857 | ) | |
| 1853 | DomainDataPortabilityService.updateHistoryEntry( | |
| 1854 | entry, | |
| 1855 | defaults: defaults, | |
| 1856 | historyLocation: historyLocation | |
| 1857 | ) | |
| 1858 | refreshDataLifecycleSummary() | |
| 1859 | } | |
| 1860 | ||
| 1861 | /// Stores a new snapshot under `cap`, which the caller reads before its | |
| 1862 | /// own insert so the row being added does not raise its own ceiling. | |
| 1863 | private func appendStoredHistory(_ entry: HistoryEntry, cap: Int) { | |
| 1864 | if historyPersistenceSuspended { | |
| 1865 | historyPersistenceDirty = true | |
| 1866 | return | |
| 1858 | 1867 | } |
| 1868 | DomainDataPortabilityService.appendHistoryEntry( | |
| 1869 | entry, | |
| 1870 | cap: cap, | |
| 1871 | defaults: defaults, | |
| 1872 | historyLocation: historyLocation | |
| 1873 | ) | |
| 1859 | 1874 | refreshDataLifecycleSummary() |
| 1860 | 1875 | } |
| 1861 | 1876 | |
| @@ -1874,7 +1889,8 @@ final class DomainViewModel { | ||
| 1874 | 1889 | |
| 1875 | 1890 | /// Rewrites the whole store. Only the auto-prune setting needs this — it |
| 1876 | 1891 | /// drops rows from the middle and cannot say which. Every other writer |
| 1877 | /// goes through `storeHistoryEntry` or `removeStoredHistory`. | |
| 1892 | /// goes through `appendStoredHistory`, `updateStoredHistory` or | |
| 1893 | /// `removeStoredHistory`. | |
| 1878 | 1894 | private func persistHistory() { |
| 1879 | 1895 | if historyPersistenceSuspended { |
| 1880 | 1896 | historyPersistenceDirty = true |
| @@ -1894,14 +1910,14 @@ final class DomainViewModel { | ||
| 1894 | 1910 | func setHistoryAutoPruneOption(_ option: HistoryAutoPruneOption) { |
| 1895 | 1911 | historyAutoPruneOption = option |
| 1896 | 1912 | defaults.set(option.rawValue, forKey: Self.historyAutoPruneKey) |
| 1897 | trimHistoryToLimit() | |
| 1913 | history = Array(history.prefix(requestedHistoryLimit)) | |
| 1898 | 1914 | persistHistory() |
| 1899 | 1915 | } |
| 1900 | 1916 | |
| 1901 | 1917 | func updateHistoryNote(_ note: String, for entry: HistoryEntry) { |
| 1902 | 1918 | guard let index = history.firstIndex(where: { $0.id == entry.id }) else { return } |
| 1903 | 1919 | history[index].note = note.trimmingCharacters(in: .whitespacesAndNewlines).nilIfEmpty |
| 1904 | storeHistoryEntry(history[index], replacingExisting: true) | |
| 1920 | updateStoredHistory(history[index]) | |
| 1905 | 1921 | } |
| 1906 | 1922 | |
| 1907 | 1923 | #if DEBUG |
| @@ -1958,14 +1974,44 @@ final class DomainViewModel { | ||
| 1958 | 1974 | refreshDataLifecycleSummary() |
| 1959 | 1975 | } |
| 1960 | 1976 | |
| 1961 | /// The number of snapshots this install keeps: the user's auto-prune | |
| 1962 | /// choice, never above the store's own ceiling. | |
| 1963 | private var effectiveHistoryLimit: Int { | |
| 1964 | min(historyAutoPruneOption.keepCount ?? Self.maxHistory, Self.maxHistory) | |
| 1977 | /// What Settings says under the auto-prune picker. The old copy claimed | |
| 1978 | /// auto-prune "defaults to unlimited", which was never true — there has | |
| 1979 | /// always been a hard ceiling, and under D1 it is the tier's. | |
| 1980 | var historyRetentionCaption: String { | |
| 1981 | let limit = tierHistoryLimit | |
| 1982 | let base = "History stays on this device. Your plan keeps up to \(limit) snapshots" | |
| 1983 | guard history.count > limit else { | |
| 1984 | return base + "; auto-prune trims to fewer if you want." | |
| 1985 | } | |
| 1986 | return base | |
| 1987 | + ", and you have \(history.count). Nothing already saved is removed —" | |
| 1988 | + " new snapshots replace the oldest instead." | |
| 1989 | } | |
| 1990 | ||
| 1991 | /// Snapshots this tier keeps: 50 free, 250 Pro, 2000 Pro+ under D1. | |
| 1992 | private var tierHistoryLimit: Int { | |
| 1993 | FeatureAccessService.historyRetentionLimit | |
| 1994 | } | |
| 1995 | ||
| 1996 | /// The ceiling a newly stored snapshot is kept under, computed before the | |
| 1997 | /// insert. Never below what is already held: a lapsed Pro+ subscriber with | |
| 1998 | /// 2000 snapshots keeps all 2000 (Review Focus #6), and the store holds | |
| 1999 | /// there rather than draining to the lower tier a row at a time. For | |
| 2000 | /// anyone at or under their tier's limit this is just that limit. | |
| 2001 | var growthHistoryLimit: Int { | |
| 2002 | max(tierHistoryLimit, history.count) | |
| 2003 | } | |
| 2004 | ||
| 2005 | /// What the user's own auto-prune choice asks for, which may be less than | |
| 2006 | /// the tier allows but never more. This one is permitted to delete, | |
| 2007 | /// because the user chose it. | |
| 2008 | var requestedHistoryLimit: Int { | |
| 2009 | min(historyAutoPruneOption.keepCount ?? tierHistoryLimit, tierHistoryLimit) | |
| 1965 | 2010 | } |
| 1966 | 2011 | |
| 2012 | /// Caps growth without pruning what is already stored. | |
| 1967 | 2013 | private func trimHistoryToLimit() { |
| 1968 | history = Array(history.prefix(effectiveHistoryLimit)) | |
| 2014 | history = Array(history.prefix(growthHistoryLimit)) | |
| 1969 | 2015 | } |
| 1970 | 2016 | |
| 1971 | 2017 | private func nextSnapshotIndex(for domain: String, trackedDomainID: UUID?) -> Int { |
| @@ -2099,7 +2145,7 @@ final class DomainViewModel { | ||
| 2099 | 2145 | } |
| 2100 | 2146 | } |
| 2101 | 2147 | |
| 2102 | relinked.forEach { storeHistoryEntry($0, replacingExisting: true) } | |
| 2148 | relinked.forEach { updateStoredHistory($0) } | |
| 2103 | 2149 | |
| 2104 | 2150 | if let latestEntry = history.first(where: { $0.domain.caseInsensitiveCompare(domain) == .orderedSame }), |
| 2105 | 2151 | let trackedIndex = trackedDomains.firstIndex(where: { $0.id == trackedDomain.id }) { |
DomainDig/FeatureAccessService.swift +16 −3
| @@ -73,6 +73,10 @@ struct FeatureEntitlements: Equatable { | ||
| 73 | 73 | let batchSizeLimit: Int? |
| 74 | 74 | /// Concurrently open audit sessions; nil is unlimited. |
| 75 | 75 | let activeAuditSessionLimit: Int? |
| 76 | /// Snapshots kept per install, the retention dial D1 settled on. Not | |
| 77 | /// optional: every tier has a ceiling, and the store is not a place to | |
| 78 | /// accumulate without one. | |
| 79 | let historyRetentionLimit: Int | |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | struct UpgradePromptContext: Identifiable, Equatable { |
| @@ -108,7 +112,8 @@ enum FeatureAccessService { | ||
| 108 | 112 | trackedDomainLimit: 5, |
| 109 | 113 | workflowLimit: 1, |
| 110 | 114 | batchSizeLimit: 10, |
| 111 | activeAuditSessionLimit: 1 | |
| 115 | activeAuditSessionLimit: 1, | |
| 116 | historyRetentionLimit: 50 | |
| 112 | 117 | ) |
| 113 | 118 | case .pro: |
| 114 | 119 | return FeatureEntitlements( |
| @@ -127,7 +132,8 @@ enum FeatureAccessService { | ||
| 127 | 132 | trackedDomainLimit: effectivelyUnlimitedTrackedDomains, |
| 128 | 133 | workflowLimit: nil, |
| 129 | 134 | batchSizeLimit: nil, |
| 130 | activeAuditSessionLimit: nil | |
| 135 | activeAuditSessionLimit: nil, | |
| 136 | historyRetentionLimit: 250 | |
| 131 | 137 | ) |
| 132 | 138 | case .proPlus: |
| 133 | 139 | return FeatureEntitlements( |
| @@ -136,11 +142,18 @@ enum FeatureAccessService { | ||
| 136 | 142 | trackedDomainLimit: effectivelyUnlimitedTrackedDomains, |
| 137 | 143 | workflowLimit: nil, |
| 138 | 144 | batchSizeLimit: nil, |
| 139 | activeAuditSessionLimit: nil | |
| 145 | activeAuditSessionLimit: nil, | |
| 146 | historyRetentionLimit: 2_000 | |
| 140 | 147 | ) |
| 141 | 148 | } |
| 142 | 149 | } |
| 143 | 150 | |
| 151 | /// Snapshots this tier keeps. A downgrade lowers what the store may grow | |
| 152 | /// to; it never prunes what is already there (Review Focus #6). | |
| 153 | static var historyRetentionLimit: Int { | |
| 154 | entitlements.historyRetentionLimit | |
| 155 | } | |
| 156 | ||
| 144 | 157 | static func hasAccess(to capability: FeatureCapability) -> Bool { |
| 145 | 158 | entitlements.capabilities.contains(capability) |
| 146 | 159 | } |
DomainDig/SettingsViews.swift +1 −1
| @@ -165,7 +165,7 @@ private struct HistoryNetworkSettingsView: View { | ||
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | Text("History remains local-first. Auto-prune only trims older local snapshots on this device and defaults to unlimited.") | |
| 168 | Text(viewModel.historyRetentionCaption) | |
| 169 | 169 | .font(appDensity.font(.caption, design: .default)) |
| 170 | 170 | .foregroundStyle(Color(.appTextSecondary)) |
| 171 | 171 | } |
DomainDigTests/DomainViewModelStoreTests.swift +91 −10
| @@ -166,23 +166,104 @@ final class DomainViewModelStoreTests: XCTestCase { | ||
| 166 | 166 | XCTAssertEqual(viewModel.history.map(\.id), seeded.prefix(50).map(\.id)) |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | /// "Unlimited" is unlimited only up to the store's own hard cap. The | |
| 170 | /// setting has no bearing on that ceiling. | |
| 171 | func testTheHardCapAppliesEvenWhenPruningIsUnlimited() { | |
| 169 | /// A store already over the cap must still be readable. Pruning happens on | |
| 170 | /// a write, not on a read, so loading must not drop rows. | |
| 171 | func testAStoreAlreadyOverTheCapLoadsEveryRow() { | |
| 172 | DomainDataPortabilityService.saveHistoryEntries(makeEntries(300), defaults: scratch, historyLocation: historyLocation) | |
| 173 | ||
| 174 | XCTAssertEqual(makeViewModel().history.count, 300) | |
| 175 | } | |
| 176 | ||
| 177 | // MARK: Retention | |
| 178 | ||
| 179 | /// At or under the tier's limit, the ceiling a new snapshot is stored | |
| 180 | /// under is simply that limit. | |
| 181 | func testTheGrowthLimitIsTheTierLimitWhenUnderIt() { | |
| 182 | let limit = FeatureAccessService.historyRetentionLimit | |
| 183 | let viewModel = makeViewModel() | |
| 184 | ||
| 185 | viewModel.history = [] | |
| 186 | XCTAssertEqual(viewModel.growthHistoryLimit, limit) | |
| 187 | ||
| 188 | viewModel.history = makeEntries(limit) | |
| 189 | XCTAssertEqual(viewModel.growthHistoryLimit, limit) | |
| 190 | } | |
| 191 | ||
| 192 | /// Review Focus #6. A lapsed Pro+ subscriber holds more snapshots than the | |
| 193 | /// new tier allows, so the ceiling is what they hold — the store stops | |
| 194 | /// growing without deleting anything, rather than draining to the lower | |
| 195 | /// tier a row per lookup. | |
| 196 | func testTheGrowthLimitNeverFallsBelowWhatIsHeld() { | |
| 197 | let limit = FeatureAccessService.historyRetentionLimit | |
| 198 | let viewModel = makeViewModel() | |
| 199 | viewModel.history = makeEntries(limit + 200) | |
| 200 | ||
| 201 | XCTAssertEqual(viewModel.growthHistoryLimit, limit + 200) | |
| 202 | } | |
| 203 | ||
| 204 | /// The user's own auto-prune choice may ask for less than the tier allows, | |
| 205 | /// never more. | |
| 206 | func testTheRequestedLimitIsClampedByTheTier() { | |
| 207 | let limit = FeatureAccessService.historyRetentionLimit | |
| 208 | let viewModel = makeViewModel() | |
| 209 | ||
| 210 | viewModel.setHistoryAutoPruneOption(.keep50) | |
| 211 | XCTAssertEqual(viewModel.requestedHistoryLimit, min(50, limit)) | |
| 212 | ||
| 213 | viewModel.setHistoryAutoPruneOption(.unlimited) | |
| 214 | XCTAssertEqual(viewModel.requestedHistoryLimit, limit, "unlimited is the tier's limit, not unbounded") | |
| 215 | } | |
| 216 | ||
| 217 | /// The user asked, so this one is allowed to delete. | |
| 218 | func testTheUsersAutoPruneChoiceIsAllowedToPrune() { | |
| 219 | let viewModel = makeViewModel() | |
| 220 | viewModel.history = makeEntries(120) | |
| 221 | ||
| 222 | viewModel.setHistoryAutoPruneOption(.keep50) | |
| 223 | ||
| 224 | XCTAssertEqual(viewModel.history.count, 50) | |
| 225 | XCTAssertEqual( | |
| 226 | DomainDataPortabilityService.loadHistoryIndex( | |
| 227 | defaults: scratch, | |
| 228 | historyLocation: historyLocation | |
| 229 | ).count, | |
| 230 | 50 | |
| 231 | ) | |
| 232 | } | |
| 233 | ||
| 234 | func testUnlimitedAutoPruneTrimsToTheTierLimit() { | |
| 235 | let limit = FeatureAccessService.historyRetentionLimit | |
| 172 | 236 | let viewModel = makeViewModel() |
| 173 | viewModel.history = makeEntries(300) | |
| 237 | viewModel.history = makeEntries(limit + 50) | |
| 174 | 238 | |
| 175 | 239 | viewModel.setHistoryAutoPruneOption(.unlimited) |
| 176 | 240 | |
| 177 | XCTAssertEqual(viewModel.history.count, 250) | |
| 241 | XCTAssertEqual(viewModel.history.count, limit) | |
| 178 | 242 | } |
| 179 | 243 | |
| 180 | /// A store already over the cap must still be readable. Pruning happens on | |
| 181 | /// a write, not on a read, so loading must not drop rows. | |
| 182 | func testAStoreAlreadyOverTheCapLoadsEveryRow() { | |
| 183 | DomainDataPortabilityService.saveHistoryEntries(makeEntries(300), defaults: scratch, historyLocation: historyLocation) | |
| 244 | // MARK: The Settings caption | |
| 184 | 245 | |
| 185 | XCTAssertEqual(makeViewModel().history.count, 300) | |
| 246 | /// The old copy said auto-prune "defaults to unlimited", which was never | |
| 247 | /// true: there has always been a hard ceiling. | |
| 248 | func testTheRetentionCaptionNamesTheLimitAndNotUnlimited() { | |
| 249 | let viewModel = makeViewModel() | |
| 250 | viewModel.history = [] | |
| 251 | ||
| 252 | let caption = viewModel.historyRetentionCaption | |
| 253 | ||
| 254 | XCTAssertTrue(caption.contains("\(FeatureAccessService.historyRetentionLimit)")) | |
| 255 | XCTAssertFalse(caption.lowercased().contains("unlimited")) | |
| 256 | } | |
| 257 | ||
| 258 | /// Over the limit the caption says nothing already saved is removed, which | |
| 259 | /// is what the store actually does. | |
| 260 | func testTheRetentionCaptionReassuresWhenOverTheLimit() { | |
| 261 | let viewModel = makeViewModel() | |
| 262 | viewModel.history = makeEntries(FeatureAccessService.historyRetentionLimit + 10) | |
| 263 | ||
| 264 | let caption = viewModel.historyRetentionCaption | |
| 265 | ||
| 266 | XCTAssertTrue(caption.contains("Nothing already saved is removed")) | |
| 186 | 267 | } |
| 187 | 268 | |
| 188 | 269 | // MARK: Tracking |
DomainDigTests/FeatureAccessTests.swift +19
| @@ -129,6 +129,25 @@ final class FeatureAccessTests: XCTestCase { | ||
| 129 | 129 | XCTAssertFalse(names.contains("dnsHistory")) |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | // MARK: Retention | |
| 133 | ||
| 134 | /// The dial D1 settled on. These are the numbers the paywall promises and | |
| 135 | /// the store enforces, so they are pinned here rather than inferred. | |
| 136 | func testEachTierHasItsRetentionLimit() { | |
| 137 | XCTAssertEqual(FeatureAccessService.entitlements(for: .free).historyRetentionLimit, 50) | |
| 138 | XCTAssertEqual(FeatureAccessService.entitlements(for: .pro).historyRetentionLimit, 250) | |
| 139 | XCTAssertEqual(FeatureAccessService.entitlements(for: .proPlus).historyRetentionLimit, 2_000) | |
| 140 | } | |
| 141 | ||
| 142 | func testRetentionRisesWithTheTier() { | |
| 143 | let free = FeatureAccessService.entitlements(for: .free).historyRetentionLimit | |
| 144 | let pro = FeatureAccessService.entitlements(for: .pro).historyRetentionLimit | |
| 145 | let proPlus = FeatureAccessService.entitlements(for: .proPlus).historyRetentionLimit | |
| 146 | ||
| 147 | XCTAssertLessThan(free, pro) | |
| 148 | XCTAssertLessThan(pro, proPlus) | |
| 149 | } | |
| 150 | ||
| 132 | 151 | // MARK: Downgrade safety |
| 133 | 152 | |
| 134 | 153 | /// A lapsed subscriber keeps data above the new ceiling. Nothing may refuse |