66128e7a5c
Hasta ahora includeWeekends y activeMealTypes vivían solo en AppSettings y aplicaban a todo el calendario. WeekPlan puede ahora sobreescribirlos para su semana (includeWeekendsOverride / mealTypesOverrideRaw) y WeekSchedule resuelve qué manda en cada semana: su override si lo tiene, los ajustes globales si no. Todo lo que pintaba días y comidas —planificador, exports, compartir texto, widget, watch— pasa por settings.schedule(for:), así que una semana con fin de semana añadido o con desayuno activo se ve igual en todas partes. Crear o editar el override es premium; los ya guardados se respetan aunque la suscripción caduque, para no borrar comidas ya planificadas. La hoja avisa y pide confirmación cuando quitar un día o una comida se lleva por delante algo ya planificado. Refs #32 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013su1ttRiMeMYxkZJ1Y3246
41 lines
2.2 KiB
Swift
41 lines
2.2 KiB
Swift
import XCTest
|
|
|
|
/// The per-week schedule sheet has to be reachable from the home and show the
|
|
/// premium upsell to free users — neither is visible to a unit test.
|
|
final class WeekScheduleUITests: XCTestCase {
|
|
|
|
func testWeekScheduleSheetOpensFromHome() throws {
|
|
let app = XCUIApplication()
|
|
app.launchArguments += ["-AppleLanguages", "(en)", "-AppleLocale", "en_US", "UITEST_DISABLE_ANALYTICS"]
|
|
app.launch()
|
|
|
|
if !app.otherElements["home_root"].waitForExistence(timeout: 5) {
|
|
for id in ["onboarding_cta_welcome", "onboarding_cta_meal_windows", "onboarding_cta_weekends",
|
|
"onboarding_cta_calendar", "onboarding_cta_first_dishes",
|
|
"onboarding_cta_week_ready_skip", "onboarding_cta_paywall_skip"] {
|
|
let button = app.buttons[id]
|
|
if button.waitForExistence(timeout: 10) { button.tap() }
|
|
}
|
|
XCTAssertTrue(app.otherElements["home_root"].waitForExistence(timeout: 15), "Home never appeared")
|
|
}
|
|
|
|
let scheduleButton = app.buttons["This week only"]
|
|
XCTAssertTrue(scheduleButton.waitForExistence(timeout: 10), "Week schedule button not found on the home")
|
|
scheduleButton.tap()
|
|
|
|
XCTAssertTrue(app.navigationBars["This week only"].waitForExistence(timeout: 5), "Week schedule sheet did not open")
|
|
XCTAssertTrue(app.switches["Breakfast"].waitForExistence(timeout: 5), "Meal toggles missing")
|
|
XCTAssertTrue(app.switches["Include weekends"].exists, "Weekend toggle missing")
|
|
// Free install: the sheet sells premium instead of applying changes.
|
|
XCTAssertTrue(app.staticTexts["Customising a single week is Premium"].exists, "Premium upsell missing for a free user")
|
|
XCTAssertFalse(app.buttons["Apply"].isEnabled, "Apply must stay disabled without premium")
|
|
|
|
let screenshot = app.screenshot()
|
|
let attachment = XCTAttachment(screenshot: screenshot)
|
|
attachment.name = "week-schedule-sheet"
|
|
attachment.lifetime = .keepAlways
|
|
add(attachment)
|
|
try? screenshot.pngRepresentation.write(to: URL(fileURLWithPath: "/tmp/mealmood-week-schedule-sheet.png"))
|
|
}
|
|
}
|