Major changes: - Textbook UI: chapter list, reader, and interactive exercise view (keyboard + Apple Pencil) surfaced under the Course tab. 30 chapters, 251 exercises. - Stem-change conjugation toggle on Week 4 flashcard decks (E-IE, E-I, O-UE). Uses existing VerbForm + IrregularSpan data to render highlighted present tense conjugations inline. - Deterministic on-device answer grader with partial credit (correct / close for accent-stripped or single-char-typo / wrong). 11 unit tests cover it. - SharedModels: TextbookChapter (local), TextbookExerciseAttempt (cloud- synced), AnswerGrader helpers. Bumped schema. - DataLoader: textbook seeder (version 8) + refresh helpers that preserve LanGo course decks when textbook data is re-seeded. - Local extraction pipeline in Conjuga/Scripts/textbook/ — XHTML chapter parser, answer-key parser, macOS Vision image OCR + PDF page OCR, merger, NSSpellChecker validator, language-aware auto-fixer, and repair pass that re-pairs quarantined vocab rows using bounding-box coordinates. - UI test target (ConjugaUITests) with three tests: end-to-end textbook flow, all-chapters screenshot audit, and stem-change toggle verification. Generated textbook content (textbook_data.json, textbook_vocab.json) and third-party source files are gitignored — re-run Scripts/textbook/run_pipeline.sh locally to regenerate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.6 KiB
Swift
67 lines
2.6 KiB
Swift
import XCTest
|
|
|
|
final class StemChangeToggleTests: XCTestCase {
|
|
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
func testStemChangeConjugationToggle() throws {
|
|
let app = XCUIApplication()
|
|
app.launchArguments += ["-onboardingComplete", "YES"]
|
|
app.launch()
|
|
|
|
// Course → LanGo Beginner I → Week 4 → E-IE stem-changing verbs
|
|
app.tabBars.buttons["Course"].tap()
|
|
|
|
// Locate the E-IE deck row. Deck titles appear as static text / button.
|
|
// Scroll until visible, then tap.
|
|
let deckPredicate = NSPredicate(format: "label CONTAINS[c] 'E-IE stem changing verbs' AND NOT label CONTAINS[c] 'REVÉS'")
|
|
let deckRow = app.buttons.matching(deckPredicate).firstMatch
|
|
|
|
let listRef = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.85))
|
|
let topRef = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.10))
|
|
for _ in 0..<12 {
|
|
if deckRow.exists && deckRow.isHittable { break }
|
|
listRef.press(forDuration: 0.1, thenDragTo: topRef)
|
|
}
|
|
XCTAssertTrue(deckRow.waitForExistence(timeout: 3), "E-IE deck row missing")
|
|
deckRow.tap()
|
|
|
|
attach(app, name: "01-deck-top")
|
|
|
|
// Tap "Show conjugation" on the first card
|
|
let showBtn = app.buttons.matching(NSPredicate(format: "label BEGINSWITH 'Show conjugation'")).firstMatch
|
|
XCTAssertTrue(showBtn.waitForExistence(timeout: 3), "Show conjugation button missing")
|
|
showBtn.tap()
|
|
|
|
// Wait for the conjugation rows + animation to settle.
|
|
let yoLabel = app.staticTexts["yo"].firstMatch
|
|
XCTAssertTrue(yoLabel.waitForExistence(timeout: 3), "yo row not rendered")
|
|
// Give the transition time to complete before snapshotting.
|
|
Thread.sleep(forTimeInterval: 0.6)
|
|
attach(app, name: "02-conjugation-open")
|
|
|
|
// Also confirm all expected person labels are rendered.
|
|
for person in ["yo", "tú", "nosotros"] {
|
|
XCTAssertTrue(
|
|
app.staticTexts[person].firstMatch.exists,
|
|
"missing conjugation row for \(person)"
|
|
)
|
|
}
|
|
|
|
// Tap again to hide
|
|
let hideBtn = app.buttons.matching(NSPredicate(format: "label BEGINSWITH 'Hide conjugation'")).firstMatch
|
|
XCTAssertTrue(hideBtn.waitForExistence(timeout: 2))
|
|
hideBtn.tap()
|
|
}
|
|
|
|
private func attach(_ app: XCUIApplication, name: String) {
|
|
let s = app.screenshot()
|
|
let a = XCTAttachment(screenshot: s)
|
|
a.name = name
|
|
a.lifetime = .keepAlways
|
|
add(a)
|
|
}
|
|
}
|