diff options
| author | Fuwn <[email protected]> | 2026-02-23 13:31:30 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-23 13:33:43 -0800 |
| commit | 2dd5ad49c5b70471dd17045a7bea6f49d97ef9d9 (patch) | |
| tree | 321be2a11ebfe7b13f51bd2a88b9a011affe6299 /SoraTests | |
| parent | chore: sync string catalog from xcode rebuild (diff) | |
| download | sora-testing-2dd5ad49c5b70471dd17045a7bea6f49d97ef9d9.tar.xz sora-testing-2dd5ad49c5b70471dd17045a7bea6f49d97ef9d9.zip | |
feat: localize accessibility fallback and value strings
Diffstat (limited to 'SoraTests')
| -rw-r--r-- | SoraTests/ViewDerivedDataTests.swift | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift index 26410f8..6a27667 100644 --- a/SoraTests/ViewDerivedDataTests.swift +++ b/SoraTests/ViewDerivedDataTests.swift @@ -361,6 +361,92 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b ) } + func testFavoritesAccessibilityFallbackAndValueUseLocalizedHumanStrings() throws { + let source = try loadSource(at: "Sora/Views/FavoritesView.swift") + let labelFunctionSource = try extractFunction( + named: "private func favoriteAccessibilityLabel(", + from: source + ) + let valueFunctionSource = try extractFunction( + named: "private func favoriteAccessibilityValue(", + from: source + ) + let fallbackLabelLocalizationCount = tokenCount( + matching: #"String\(localized:\s*"Favorite post"#, + in: labelFunctionSource + ) + let accessibilityValueLocalizationCount = tokenCount( + matching: #"String\(localized:\s*"Rating"#, + in: valueFunctionSource + ) + let uppercasedRatingCount = tokenCount( + matching: #"favorite\.rating\.rawValue\.uppercased\(\)"#, + in: valueFunctionSource + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + fallbackLabelLocalizationCount, + 0, + "Favorite accessibility fallback label should use localized copy." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + accessibilityValueLocalizationCount, + 0, + "Favorite accessibility value should use localized copy." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertEqual( + uppercasedRatingCount, + 0, + "Favorite accessibility value should not uppercase rating text." + ) + } + + func testPostGridAccessibilityFallbackAndValueUseLocalizedHumanStrings() throws { + let source = try loadSource(at: "Sora/Views/Post/Grid/PostGridView.swift") + let labelFunctionSource = try extractFunction( + named: "private func postAccessibilityLabel(", + from: source + ) + let valueFunctionSource = try extractFunction( + named: "private func postAccessibilityValue(", + from: source + ) + let fallbackLabelLocalizationCount = tokenCount( + matching: #"String\(localized:\s*"Post"#, + in: labelFunctionSource + ) + let accessibilityValueLocalizationCount = tokenCount( + matching: #"String\(localized:\s*"Rating"#, + in: valueFunctionSource + ) + let uppercasedRatingCount = tokenCount( + matching: #"post\.rating\.rawValue\.uppercased\(\)"#, + in: valueFunctionSource + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + fallbackLabelLocalizationCount, + 0, + "Post accessibility fallback label should use localized copy." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + accessibilityValueLocalizationCount, + 0, + "Post accessibility value should use localized copy." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertEqual( + uppercasedRatingCount, + 0, + "Post accessibility value should not uppercase rating text." + ) + } + func testFavoritesDeleteActionUsesDestructiveRole() throws { let source = try loadSource(at: "Sora/Views/FavoritesView.swift") let functionSource = try extractFunction( |