From 132c6b4a09ccefab081cf31fd66b7bc6a66d5fc2 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Sat, 14 Nov 2026 12:04:22 +0800 Subject: [PATCH 1/3] ci(ios): handle StoreKit timeout cleanup failures --- .github/workflows/ci.yml | 6 ++- scripts/run-ios-test-command.py | 68 ++++++++++++------------- test/iosStoreKitInfrastructure.test.mjs | 34 +++++++++++++ 3 files changed, 73 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3153e6a0..c838fdcc3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -340,7 +340,11 @@ jobs: run: | for bundle in "$RUNNER_TEMP"/xcresult/*.xcresult; do [ -d "$bundle" ] || continue - xcrun xcresulttool get test-results summary --path "$bundle" | python3 -c ' + if [ ! -f "$bundle/Info.plist" ] || ! summary=$(xcrun xcresulttool get test-results summary --path "$bundle"); then + echo "::warning::StoreKit did not finish writing $(basename "$bundle"); see the archived test logs." + continue + fi + printf '%s\n' "$summary" | python3 -c ' import json, sys for failure in json.load(sys.stdin).get("testFailures", []): name = failure.get("testName", "") diff --git a/scripts/run-ios-test-command.py b/scripts/run-ios-test-command.py index 62cfbfa1f..dcd27aeda 100644 --- a/scripts/run-ios-test-command.py +++ b/scripts/run-ios-test-command.py @@ -17,6 +17,38 @@ def interrupt(signum, _frame): raise Interrupted(signum) +def signal_command(process, sig): + try: + os.killpg(process.pid, sig) + except ProcessLookupError: + pass + except PermissionError: + # Some simctl children can make signaling the entire group fail. + # Fall back to the direct child without assuming we own other PIDs. + try: + process.send_signal(sig) + except ProcessLookupError: + pass + except PermissionError: + print(f'Could not signal iOS command PID {process.pid} with {sig.name}', file=sys.stderr) + + +def stop_command(process, sig, grace): + signal.signal(signal.SIGINT, signal.SIG_IGN) + signal.signal(signal.SIGTERM, signal.SIG_IGN) + signal_command(process, sig) + try: + process.wait(timeout=grace) + except subprocess.TimeoutExpired: + pass + # The parent can exit while a descendant still holds a result bundle open. + signal_command(process, signal.SIGKILL) + try: + process.wait(timeout=2) + except subprocess.TimeoutExpired: + print(f'iOS command PID {process.pid} did not exit after cleanup', file=sys.stderr) + + def main(): log = Path(sys.argv[1]) timeout_value = os.environ.get('COOK_IOS_COMMAND_TIMEOUT_SECONDS') @@ -33,43 +65,11 @@ def main(): try: result = process.wait(timeout=timeout) except subprocess.TimeoutExpired: - # A second termination signal must not interrupt owned cleanup. - signal.signal(signal.SIGINT, signal.SIG_IGN) - signal.signal(signal.SIGTERM, signal.SIG_IGN) - try: - os.killpg(process.pid, signal.SIGTERM) - except ProcessLookupError: - pass - try: - process.wait(timeout=2) - except subprocess.TimeoutExpired: - pass - try: - os.killpg(process.pid, signal.SIGKILL) - except ProcessLookupError: - pass - process.wait() + stop_command(process, signal.SIGTERM, grace=2) print(f"IOS command timed out after {timeout:g} seconds: {' '.join(sys.argv[2:])}", file=sys.stderr) result = 124 except Interrupted as error: - # A second termination signal must not interrupt owned cleanup. - signal.signal(signal.SIGINT, signal.SIG_IGN) - signal.signal(signal.SIGTERM, signal.SIG_IGN) - try: - os.killpg(process.pid, signal.SIGINT) - except ProcessLookupError: - pass - try: - process.wait(timeout=10) - except subprocess.TimeoutExpired: - pass - # The parent may exit while a descendant still holds the log - # or result bundle open. Stop the whole owned group either way. - try: - os.killpg(process.pid, signal.SIGKILL) - except ProcessLookupError: - pass - process.wait() + stop_command(process, signal.SIGINT, grace=10) result = 128 + error.signum finally: # Replay even a partial startup log, after its writer has stopped. diff --git a/test/iosStoreKitInfrastructure.test.mjs b/test/iosStoreKitInfrastructure.test.mjs index d8067996e..5626463a7 100644 --- a/test/iosStoreKitInfrastructure.test.mjs +++ b/test/iosStoreKitInfrastructure.test.mjs @@ -12,6 +12,40 @@ import { planIosTests } from '../scripts/ci-changes.mjs' const root = fileURLToPath(new URL('..', import.meta.url)) const hostArchitecture = spawnSync('uname', ['-m'], { encoding: 'utf8' }).stdout.trim() +test('a denied process-group kill still stops the timed-out command and preserves its log', () => { + const task = mkdtempSync(join(tmpdir(), 'cook-storekit-denied-signal-')) + try { + const log = join(task, 'restart.log') + const run = spawnSync('python3', ['-c', ` +import errno, os, runpy, signal, sys +path, log = sys.argv[1:] +killpg = os.killpg +def deny_group_kill(pid, sig): + if sig == signal.SIGKILL: + raise PermissionError(errno.EPERM, 'simulated process-group denial') + killpg(pid, sig) +os.killpg = deny_group_kill +command = 'import os, signal, time; signal.signal(signal.SIGTERM, signal.SIG_IGN); print(os.getpid(), flush=True); time.sleep(60)' +sys.argv = [path, log, sys.executable, '-c', command] +runpy.run_path(path, run_name='__main__') +`, 'scripts/run-ios-test-command.py', log], { + cwd: root, + encoding: 'utf8', + timeout: 10_000, + env: { ...process.env, COOK_IOS_COMMAND_TIMEOUT_SECONDS: '1' }, + }) + assert.equal(run.error, undefined) + assert.equal(run.status, 124) + assert.match(run.stderr, /IOS command timed out after 1 seconds/) + assert.doesNotMatch(run.stderr, /Traceback/) + const pid = Number(readFileSync(log, 'utf8').trim()) + assert.ok(Number.isInteger(pid) && pid > 0) + assert.equal(run.stdout.trim(), String(pid)) + assert.throws(() => process.kill(pid, 0), { code: 'ESRCH' }) + } + finally { rmSync(task, { recursive: true, force: true }) } +}) + test('a cancelled financial step stops its writer and replays partial logs before exit', { timeout: 20_000 }, async () => { for (const ignoresInterrupt of ['0', '1']) await checkCancellation(ignoresInterrupt) From e99f317c3034c1899b87c731df14a4c17127ae09 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Sat, 14 Nov 2026 12:04:26 +0800 Subject: [PATCH 2/3] fix(data): preserve the optional vinegar amount --- packages/data/recipe-amounts.json | 27 ++++++++++++++++++++++++++- packages/data/recipe-dietary.json | 4 ++-- scripts/lib/recipe-amount-followup.ts | 5 ++++- test/recipeAmountAllocations.test.ts | 16 ++++++++++++++-- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/packages/data/recipe-amounts.json b/packages/data/recipe-amounts.json index a6fda88bd..58e6909fc 100644 --- a/packages/data/recipe-amounts.json +++ b/packages/data/recipe-amounts.json @@ -1109,7 +1109,32 @@ ], "quantities": [], "stepSections": [], - "usages": [], + "usages": [ + { + "anchor": { + "block": 10, + "item": 3, + "text": "将鸡蛋打入碗中,加入 `1g * 份数` 的盐,搅匀,即为 `鸡蛋液`\n• 可以考虑向鸡蛋中加入 1ml 醋,这可以去除腥味,令鸡蛋更蓬松" + }, + "ingredient": "醋", + "kind": "amount", + "target": "1ml 醋", + "formula": { + "op": "literal", + "lower": 1, + "unit": "ml" + }, + "display": false, + "conditional": true, + "evidence": [ + { + "block": 10, + "item": 3, + "text": "将鸡蛋打入碗中,加入 `1g * 份数` 的盐,搅匀,即为 `鸡蛋液`\n• 可以考虑向鸡蛋中加入 1ml 醋,这可以去除腥味,令鸡蛋更蓬松" + } + ] + } + ], "blockedIngredients": [], "servingDescription": "每次制作前需要确定计划做几份。一份正好够 1 个人食用" }, diff --git a/packages/data/recipe-dietary.json b/packages/data/recipe-dietary.json index d9a2f7e7f..41e892991 100644 --- a/packages/data/recipe-dietary.json +++ b/packages/data/recipe-dietary.json @@ -1,7 +1,7 @@ { "schemaVersion": 2, "policyVersion": 2, - "amountsFingerprint": "5eacea8726d04b968f561cb3a75af5a014e8225975d87f126f2ece063f968859", + "amountsFingerprint": "5722a6aca355ccdc9194341c3e469c0c68f49cd2eaeafb5be853684c53810c3e", "enabledGoals": [ "weight-aware", "less-added-sugar", @@ -7224,5 +7224,5 @@ } } }, - "dataVersion": "ead74d1c15c9" + "dataVersion": "1b4d2de65e43" } diff --git a/scripts/lib/recipe-amount-followup.ts b/scripts/lib/recipe-amount-followup.ts index d9ba3aa83..730c619e5 100644 --- a/scripts/lib/recipe-amount-followup.ts +++ b/scripts/lib/recipe-amount-followup.ts @@ -4,6 +4,7 @@ import { anchorOf, divide, literal, multiply, scalar, servings, sourceFingerprin /** 第二轮逐篇复核;冻结整篇依据,来源变化时必须重新核对,不能自动重签这些分配。 */ const reviewedFingerprints: Record = { + 250: '12257c0baaf2700b', 489: 'dd5acaa67ca1fac7', 598: '21e127f00de96f6b', 641: '40862bd6ba4d71a7', @@ -68,9 +69,11 @@ export function applyReviewedAmountAllocations(source: RecipeTextData, data: Amo }) entry.usages = entry.usages.filter(u => u.ingredient !== ingredient) entry.usages.push(...usages) - reviews.push({ id, ingredient, complete, explanation, evidence, usages }) + reviews.push({ id, ingredient, complete, explanation, evidence: evidence.length ? evidence : usages.map(usage => usage.anchor), usages }) } + bind(250, '醋', [{ ...amount([10, 3], '1ml 醋', literal(1, 'ml'), true), display: false }], [], '仅在打蛋时可选加入 1ml 醋;原文未给份数依据,保留字面量,不追加到备料总量。') + // 固定配方没有份数基准,只分解 3g / 10g,不把它们乘人数。 bind(598, '食盐', [amount([9, 3], '一半的食盐', part('食盐', 1, 2)), { at: [9, 9], target: '剩下的食盐', kind: 'remaining' }], [[7, 8], [9, 3], [9, 9]], '固定批次食盐 3g:腌肉一半,豆腐阶段使用剩余一半。') bind(598, '酱油', [amount([9, 3], '味极鲜酱油', part('酱油', 1, 2)), { at: [9, 9], target: '味极鲜酱油酱油', kind: 'remaining' }], [[5, 10], [7, 9], [9, 3], [9, 9]], '原料明确酱油为味极鲜;腌肉与豆腐两处各半,原文重复的“酱油”不改写。') diff --git a/test/recipeAmountAllocations.test.ts b/test/recipeAmountAllocations.test.ts index 363d96253..c37324043 100644 --- a/test/recipeAmountAllocations.test.ts +++ b/test/recipeAmountAllocations.test.ts @@ -15,8 +15,8 @@ describe('reviewed source allocations', () => { const reviews = applyReviewedAmountAllocations(texts, copy) expect(copy).toEqual(data) expect(JSON.stringify(texts)).toBe(before) - expect(reviews).toHaveLength(50) - expect(new Set(reviews.map(r => r.id)).size).toBe(18) + expect(reviews).toHaveLength(51) + expect(new Set(reviews.map(r => r.id)).size).toBe(19) for (const review of reviews) { expect(review.evidence.length).toBeGreaterThan(0) for (const evidence of review.evidence) @@ -26,6 +26,18 @@ describe('reviewed source allocations', () => { } }) + it('preserves the optional fixed vinegar amount without adding it to preparation', () => { + const tomato = data.recipes['250']! + expect(tomato.usages).toContainEqual(expect.objectContaining({ + ingredient: '醋', + target: '1ml 醋', + formula: { op: 'literal', lower: 1, unit: 'ml' }, + display: false, + conditional: true, + })) + expect(tomato.quantities.some(quantity => quantity.name === '醋')).toBe(false) + }) + it('rejects changes elsewhere in a reviewed source instead of automatically signing again', () => { const changed = structuredClone(texts) changed.recipes['710']!.blocks.push({ type: 'paragraph', text: '额外加入一份油' }) From f137dab27b5467cdd3d586d8d67cedd9b1f7f9e8 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Sat, 14 Nov 2026 12:05:06 +0800 Subject: [PATCH 3/3] fix(ios): keep cooking guidance and timer controls reachable --- .../Cook/Views/KitchenStepGuidanceView.swift | 79 ++++++++++++------- .../ios/Cook/Views/KitchenWorkbenchView.swift | 35 +++++--- .../Cook/Views/RecipeCookingComponents.swift | 32 +++++++- apps/ios/Cook/Views/RecipeTextView.swift | 71 +++++++++-------- .../CookUITests/KitchenWorkbenchUITests.swift | 29 ++++--- 5 files changed, 155 insertions(+), 91 deletions(-) diff --git a/apps/ios/Cook/Views/KitchenStepGuidanceView.swift b/apps/ios/Cook/Views/KitchenStepGuidanceView.swift index 511587ca6..7f07ca8c0 100644 --- a/apps/ios/Cook/Views/KitchenStepGuidanceView.swift +++ b/apps/ios/Cook/Views/KitchenStepGuidanceView.swift @@ -4,6 +4,7 @@ import SwiftUI /// Local guidance surface attached below the current step and outside its completion button. struct RecipeStepGuidancePanel: View { @Environment(CookAISettings.self) private var ai + @Environment(\.accessibilityReduceMotion) private var reduceMotion @Environment(\.dynamicTypeSize) private var dynamicTypeSize let step: RecipePresentation.Step let guidance: KitchenStepGuidanceModel @@ -14,6 +15,7 @@ struct RecipeStepGuidancePanel: View { @State private var question = "" @State private var lastKind: StepGuidanceKind = .explain @State private var lastQuestion: String? + @State private var panBounce = false @FocusState private var questionFocused: Bool private var response: StepGuidanceResponse? { @@ -30,18 +32,7 @@ struct RecipeStepGuidancePanel: View { var body: some View { VStack(alignment: .leading, spacing: 12) { - Group { - if dynamicTypeSize.isAccessibilitySize { - VStack(alignment: .leading, spacing: 10) { - guidanceActionButtons - } - } else { - HStack(spacing: 10) { - guidanceActionButtons - } - .fixedSize(horizontal: false, vertical: true) - } - } + guidanceActions if asking { VStack(alignment: .leading, spacing: 8) { @@ -122,12 +113,14 @@ struct RecipeStepGuidancePanel: View { } } } - .padding(14) - .background(Color(uiColor: .secondarySystemGroupedBackground), in: RoundedRectangle(cornerRadius: 16)) - .overlay { - RoundedRectangle(cornerRadius: 16) - .strokeBorder(Color.accentColor.opacity(0.18), lineWidth: 1) - .accessibilityHidden(true) + .padding(.horizontal, 14) + .padding(.vertical, 10) + .frame(maxWidth: .infinity, alignment: .leading) + .background { + if showsDetails { + RoundedRectangle(cornerRadius: 16) + .fill(Color(uiColor: .secondarySystemGroupedBackground)) + } } .accessibilityElement(children: .contain) .accessibilityIdentifier("recipe.guidance.panel") @@ -183,21 +176,52 @@ struct RecipeStepGuidancePanel: View { return !trimmed.isEmpty && trimmed.count <= StepGuidanceRequest.maximumQuestionLength && !guidance.isLoading } + private var showsDetails: Bool { + asking || guidance.isLoading || guidance.phase == .error || response != nil || !ai.canUseRemote + } + + @ViewBuilder + private var guidanceActions: some View { + if dynamicTypeSize.isAccessibilitySize { + stackedGuidanceActions + } else { + ViewThatFits(in: .horizontal) { + HStack(spacing: 12) { + guidanceActionButtons + } + stackedGuidanceActions + } + } + } + + private var stackedGuidanceActions: some View { + VStack(alignment: .leading, spacing: 8) { + guidanceActionButtons + } + } + @ViewBuilder private var guidanceActionButtons: some View { - guidanceButton("本步讲解", systemImage: "sparkles", identifier: "recipe.guidance.explain") { + guidanceButton("本步讲解", identifier: "recipe.guidance.explain") { + Image(systemName: "frying.pan") + .foregroundStyle(.orange) + .symbolEffect(.bounce, options: .nonRepeating, value: panBounce) + } action: { + if !reduceMotion { panBounce.toggle() } lastKind = .explain lastQuestion = nil explain() } - guidanceButton(asking ? "收起提问" : "问这一步", - systemImage: asking ? "chevron.up" : "questionmark.bubble", - identifier: "recipe.guidance.question") { + .buttonStyle(.bordered) + guidanceButton(asking ? "收起提问" : "问这一步", identifier: "recipe.guidance.question") { + Image(systemName: asking ? "chevron.up" : "questionmark.bubble") + } action: { withAnimation(.easeInOut(duration: 0.2)) { asking.toggle() } if !asking { questionFocused = false } } + .buttonStyle(.borderless) } private func sendQuestion() { @@ -209,16 +233,15 @@ struct RecipeStepGuidancePanel: View { ask(trimmed) } - private func guidanceButton(_ title: String, systemImage: String, identifier: String, - action: @escaping () -> Void) -> some View { + private func guidanceButton(_ title: String, identifier: String, @ViewBuilder icon: () -> Icon, + action: @escaping () -> Void) -> some View { Button(action: action) { - Label(title, systemImage: systemImage) + Label { Text(title) } icon: { icon().accessibilityHidden(true) } .font(.subheadline.weight(.medium)) - .frame(minHeight: 44) + .fixedSize(horizontal: false, vertical: true) + .frame(minWidth: 44, minHeight: 44) .contentShape(Rectangle()) } - .buttonStyle(.bordered) - .frame(maxWidth: dynamicTypeSize.isAccessibilitySize ? .infinity : nil, alignment: .leading) .disabled(guidance.isLoading) .accessibilityIdentifier(identifier) } diff --git a/apps/ios/Cook/Views/KitchenWorkbenchView.swift b/apps/ios/Cook/Views/KitchenWorkbenchView.swift index d247ccf19..f50601667 100644 --- a/apps/ios/Cook/Views/KitchenWorkbenchView.swift +++ b/apps/ios/Cook/Views/KitchenWorkbenchView.swift @@ -33,15 +33,19 @@ struct KitchenWorkbenchView: View { ZStack(alignment: .top) { // 紧凑模式的两块面板重叠以保留阅读位置;可见面板也需位于无障碍命中层级最上方。 KitchenPaneLayout(frames: frames) { - instructions - .scrollEdgeBar(edge: .bottom) { - if compact, !dynamicTypeSize.isAccessibilitySize { timerShortcut } + VStack(spacing: 0) { + instructions + .frame(maxWidth: .infinity, maxHeight: .infinity) + .clipped() + if compact, !dynamicTypeSize.isAccessibilitySize { + Divider() + timerShortcut } - .clipped() - .opacity(!compact || pane == .recipe ? 1 : 0) - .allowsHitTesting(!compact || pane == .recipe) - .accessibilityHidden(compact && pane != .recipe) - .zIndex(!compact || pane == .recipe ? 1 : 0) + } + .opacity(!compact || pane == .recipe ? 1 : 0) + .allowsHitTesting(!compact || pane == .recipe) + .accessibilityHidden(compact && pane != .recipe) + .zIndex(!compact || pane == .recipe ? 1 : 0) preparation(tabletop: frames.mode == .tabletop) .clipped() .opacity(!compact || pane == .preparation ? 1 : 0) @@ -104,8 +108,6 @@ struct KitchenWorkbenchView: View { if let text = store.text(for: recipe) { RecipeTextContent(recipe: recipe, text: text, preparationInSidebar: true, showsStepGuidance: true, dietaryGoal: dietaryGoal) - .accessibilityLabel("菜谱做法") - .accessibilityIdentifier("kitchen.instructions") } else { ContentUnavailableView { Label("暂未收录图文做法", systemImage: "book.closed") @@ -132,15 +134,22 @@ struct KitchenWorkbenchView: View { HStack { Label(timer.phase(at: context.date) == .finished ? "计时结束" : "计时器", systemImage: "timer") Spacer() - Text(timer.display(at: context.date)).monospacedDigit() - Image(systemName: "chevron.right").font(.caption) + Text(timer.display(at: context.date)) + .font(.body.weight(.semibold).monospacedDigit()) + Image(systemName: "chevron.right") + .font(.caption) + .foregroundStyle(.secondary) + .accessibilityHidden(true) } - .padding() + .padding(.horizontal, 20) + .padding(.vertical, 12) + .frame(minHeight: 52) .contentShape(Rectangle()) } .buttonStyle(.plain) .accessibilityIdentifier("kitchen.timerShortcut") } + .background(Color(uiColor: .secondarySystemGroupedBackground), ignoresSafeAreaEdges: .bottom) } } diff --git a/apps/ios/Cook/Views/RecipeCookingComponents.swift b/apps/ios/Cook/Views/RecipeCookingComponents.swift index 464af7cc3..daed8611f 100644 --- a/apps/ios/Cook/Views/RecipeCookingComponents.swift +++ b/apps/ios/Cook/Views/RecipeCookingComponents.swift @@ -180,6 +180,7 @@ struct RecipeStepCard: View { let toggle: () -> Void var body: some View { + let stepText = recipeStepMarkdown(instruction?.text ?? step.text) VStack(spacing: 0) { Button(action: toggle) { HStack(alignment: .top, spacing: 12) { @@ -198,7 +199,7 @@ struct RecipeStepCard: View { .accessibilityHidden(true) VStack(alignment: .leading, spacing: 6) { - Text(recipeMarkdown(instruction?.text ?? step.text)) + Text(stepText) .font(.body) .foregroundStyle(completed ? Color.secondary : Color.primary) .lineSpacing(3) @@ -235,7 +236,7 @@ struct RecipeStepCard: View { .contentShape(RoundedRectangle(cornerRadius: 16)) } .buttonStyle(RecipeStepButtonStyle()) - .accessibilityLabel(Text("第 \(step.number) 步,") + Text(recipeMarkdown(instruction?.text ?? step.text))) + .accessibilityLabel(Text("第 \(step.number) 步,") + Text(stepText)) .accessibilityValue(completed ? "已完成" : "未完成") .accessibilityHint(completed ? "轻点撤销完成" : current ? "轻点完成并前往下一步" : "轻点标记完成") .accessibilityIdentifier("recipe.step.\(step.number)") @@ -328,6 +329,33 @@ func recipeMarkdown(_ text: String) -> AttributedString { return (try? AttributedString(markdown: text, options: options)) ?? AttributedString(text) } +private func recipeStepMarkdown(_ text: String) -> AttributedString { + let quantity = #"(? String { + element.label.replacingOccurrences(of: "\u{202F}", with: " ") + } let app = XCUIApplication() app.launchArguments = XCUIApplication.standardCookingLaunchArguments + ["-ui-testing-reset-consent", "-ui-testing-reset-kitchen"] app.launchEnvironment["COOK_UI_TEST_DECLINE_CONSENT"] = "1" @@ -153,26 +156,26 @@ final class KitchenWorkbenchUITests: XCTestCase { XCTAssertTrue(recipeServings.waitForExistence(timeout: 10)) XCTAssertEqual(app.staticTexts["recipe.amount.鸡蛋"].label, "2 个") let stepText = app.staticTexts["recipe.stepText.4"] - XCTAssertTrue(stepText.label.contains("1 g 的盐")) + XCTAssertTrue(visibleText(stepText).contains("1 g 的盐")) let oilStep = app.staticTexts["recipe.stepText.5"] let remainingSalt = app.staticTexts["recipe.stepText.10"] - XCTAssertTrue(oilStep.label.contains("食用油(8 ml)")) - XCTAssertTrue(remainingSalt.label.contains("剩余的盐(0.5–1 g)")) + XCTAssertTrue(visibleText(oilStep).contains("食用油(8 ml)")) + XCTAssertTrue(visibleText(remainingSalt).contains("剩余的盐(0.5–1 g)")) recipeServings.buttons.element(boundBy: 1).tap() recipeServings.buttons.element(boundBy: 1).tap() XCTAssertEqual(app.staticTexts["recipe.amount.鸡蛋"].label, "5 个") XCTAssertEqual(app.staticTexts["recipe.amount.食用油"].label, "20 ml") XCTAssertEqual(app.staticTexts["recipe.amount.盐"].label, "4.5–6 g") - XCTAssertTrue(stepText.label.contains("3 g 的盐"), "步骤中的分次用量独立于整菜总量") + XCTAssertTrue(visibleText(stepText).contains("3 g 的盐"), "步骤中的分次用量独立于整菜总量") XCTAssertFalse(stepText.label.contains("份数")) - XCTAssertTrue(stepText.label.contains("1ml 醋"), "原文固定的可选用量保留") - XCTAssertTrue(oilStep.label.contains("食用油(20 ml)")) - XCTAssertTrue(remainingSalt.label.contains("剩余的盐(1.5–3 g)")) + XCTAssertTrue(visibleText(stepText).contains("1 ml 醋"), "原文固定的可选用量保留") + XCTAssertTrue(visibleText(oilStep).contains("食用油(20 ml)")) + XCTAssertTrue(visibleText(remainingSalt).contains("剩余的盐(1.5–3 g)")) app.buttons["recipe.continueStep"].tap() let step = app.buttons["recipe.step.4"] step.tap() XCTAssertEqual(step.value as? String, "已完成") - XCTAssertTrue(remainingSalt.label.contains("剩余的盐(1.5–3 g)"), "勾选不重复扣减用量") + XCTAssertTrue(visibleText(remainingSalt).contains("剩余的盐(1.5–3 g)"), "勾选不重复扣减用量") capture(app, "recipe-step-three-servings") let left = app.windows.firstMatch left.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.85)) @@ -195,9 +198,9 @@ final class KitchenWorkbenchUITests: XCTestCase { if app.segmentedControls.buttons["做法"].exists { app.segmentedControls.buttons["做法"].tap() } XCTAssertEqual(recipeServings.value as? String, "2 份") XCTAssertEqual(app.staticTexts["recipe.amount.鸡蛋"].label, "3 个") - XCTAssertTrue(stepText.label.contains("2 g 的盐")) - XCTAssertTrue(oilStep.label.contains("食用油(12 ml)")) - XCTAssertTrue(remainingSalt.label.contains("剩余的盐(1–2 g)")) + XCTAssertTrue(visibleText(stepText).contains("2 g 的盐")) + XCTAssertTrue(visibleText(oilStep).contains("食用油(12 ml)")) + XCTAssertTrue(visibleText(remainingSalt).contains("剩余的盐(1–2 g)")) XCTAssertEqual(step.value as? String, "已完成", "份数变化不改变步骤身份或完成记录") app.buttons["kitchen.close"].tap() app.terminate() @@ -206,9 +209,9 @@ final class KitchenWorkbenchUITests: XCTestCase { openKitchen(app) XCTAssertEqual(recipeServings.value as? String, "2 份") XCTAssertEqual(app.staticTexts["recipe.amount.食用油"].label, "12 ml") - XCTAssertTrue(stepText.label.contains("2 g 的盐")) + XCTAssertTrue(visibleText(stepText).contains("2 g 的盐")) XCTAssertEqual(step.value as? String, "已完成") - XCTAssertTrue(remainingSalt.label.contains("剩余的盐(1–2 g)")) + XCTAssertTrue(visibleText(remainingSalt).contains("剩余的盐(1–2 g)")) capture(app, "recipe-servings-restored") }