Files
Reflect/Tests iOS/LongTranslationTests.swift
Trey T 2ef1c1ec51 Enable parallel UI test execution via per-session data isolation
Each test class now gets a unique session ID (UUID) passed to the app
via UI_TEST_SESSION_ID environment variable. The app uses this to:

- Route GroupUserDefaults to a session-specific UserDefaults suite,
  preventing tests from clobbering each other's AppStorage state
- Create an in-memory SwiftData container instead of the shared
  on-disk App Group store, eliminating SQLite contention

Refactored 8 test classes that bypassed BaseUITestCase.setUp() with
custom launch args — they now use overridable `localeArguments` and
`extraLaunchArguments` properties, keeping session ID injection
centralized. Added `relaunchApp(resetState:bypassSubscription:)` to
BaseUITestCase for tests that need mid-test relaunch with different
subscription state.

Includes a ParallelUITests.xctestplan with class-level parallelism
enabled and random execution ordering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:04:55 -05:00

59 lines
2.1 KiB
Swift

//
// LongTranslationTests.swift
// Tests iOS
//
// TC-138: Long translations (German) don't truncate critical UI text.
//
import XCTest
final class LongTranslationTests: BaseUITestCase {
override var seedFixture: String? { "single_mood" }
override var bypassSubscription: Bool { true }
override var localeArguments: [String] { ["-AppleLanguages", "(de)", "-AppleLocale", "de_DE"] }
/// TC-138: German locale with long compound words renders without crashes.
/// Navigates through all tabs to ensure no layout truncation causes issues.
func testLongTranslations_GermanLocale_NoLayoutCrash() {
// Day tab should load
let tabBar = app.tabBars.firstMatch
XCTAssertTrue(tabBar.waitForExistence(timeout: 5), "Tab bar should exist")
captureScreenshot(name: "german_long_day")
// Navigate to Month view
let monthTab = app.tabBars.buttons.element(boundBy: 1)
monthTab.tap()
_ = app.waitForExistence(timeout: 2)
captureScreenshot(name: "german_long_month")
// Navigate to Year view
let yearTab = app.tabBars.buttons.element(boundBy: 2)
yearTab.tap()
_ = app.waitForExistence(timeout: 2)
captureScreenshot(name: "german_long_year")
// Navigate to Settings
let settingsTab = app.tabBars.buttons.element(boundBy: 4)
settingsTab.tap()
let settingsHeader = app.element(UITestID.Settings.header)
XCTAssertTrue(
settingsHeader.waitForExistence(timeout: 5),
"Settings header should be visible in German locale"
)
captureScreenshot(name: "german_long_settings")
// Verify no truncation indicators ("..." / ellipsis) in key labels
// Check that "Einstellungen" (Settings) text is fully rendered
let einstellungenText = app.staticTexts.matching(
NSPredicate(format: "label == %@", "Einstellungen")
).firstMatch
XCTAssertTrue(
einstellungenText.waitForExistence(timeout: 3),
"Full German 'Einstellungen' text should be visible (not truncated)"
)
}
}