1.4.1 (build 46): fix cambio de Chart Type roto por el cache de snapshots

El fetch del cache dependía del timeRange activo (monthsLimit = timeRange.months),
así que al reutilizarlo entre chart types/rangos (optimización del build 45) los
charts recibían historia truncada — Year vs Year o "All" con solo 12 meses, charts
vacíos o incompletos al cambiar de tipo.

Fix: el cache siempre guarda la historia completa (maxHistoryMonths) y el recorte
por rango se hace en memoria (el filtro por cutoffDate ya existía justo después).
Bonus: hiddenHistoryMonths ahora se calcula contra la ventana completa (teaser más
preciso).

Verificado en iPad Pro 13" simulador: Evolution 12M → All → Compare →
Period vs Period → Evolution, todos renderizan con datos.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015qUZrBusG82T37R7PeokqJ
This commit is contained in:
alexandrev-tibco
2026-07-03 16:35:42 +02:00
parent a0710a6f76
commit 7c92ea36c0
3 changed files with 49 additions and 15 deletions
@@ -151,10 +151,42 @@ final class PortfolioJournalUITests: XCTestCase {
}
Thread.sleep(forTimeInterval: 3.0)
let shot = XCTAttachment(screenshot: capture.screenshot())
shot.name = "Charts_Redesign"
shot.lifetime = .keepAlways
add(shot)
func snap(_ name: String) {
let shot = XCTAttachment(screenshot: capture.screenshot())
shot.name = name
shot.lifetime = .keepAlways
add(shot)
}
snap("01_Evolution_default")
// Switch period to All (exercises the shared snapshot cache across ranges)
let allSegment = capture.buttons["All"].firstMatch
if allSegment.waitForExistence(timeout: 3) {
allSegment.tap()
Thread.sleep(forTimeInterval: 2.0)
snap("02_Evolution_All")
}
// Switch chart type to a free multi-control chart and back (cache reuse path)
let compareTile = capture.buttons["Compare"].firstMatch
if compareTile.waitForExistence(timeout: 3) {
compareTile.tap()
Thread.sleep(forTimeInterval: 2.0)
snap("03_Compare")
}
let periodTile = capture.buttons["Period vs Period"].firstMatch
if periodTile.waitForExistence(timeout: 3) {
periodTile.tap()
Thread.sleep(forTimeInterval: 2.0)
snap("04_PeriodVsPeriod")
}
let evolutionTile = capture.buttons["Evolution"].firstMatch
if evolutionTile.waitForExistence(timeout: 3) {
evolutionTile.tap()
Thread.sleep(forTimeInterval: 2.0)
snap("05_Evolution_back")
}
}
/// Captures full-screen screenshots of the main tabs with demo data for App Store