Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Nov 21, 2023
1 parent 68cc28b commit 4d2fcf2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/prepare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ jobs:
-scheme Landmarks \
-only-testing LandmarksUITests \
-configuration Debug \
-sdk iphoneos -destination 'platform=iOS Simulator,name=iPhone 14' \
-sdk iphoneos \
-destination 'platform=iOS Simulator,OS=16.2,name=iPhone 14' \
| xcbeautify --renderer github-actions
2 changes: 1 addition & 1 deletion Landmarks/Resources/landmarkData.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"state": "Alaska",
"id": 1002,
"isFeatured": false,
"isFavorite": false,
"isFavorite": true,
"park": "Lake Clark National Park and Preserve",
"coordinates": {
"longitude": -152.665167,
Expand Down
10 changes: 10 additions & 0 deletions Landmarks/Views/Landmarks/LandmarkList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ struct LandmarkList: View {
}
}

func makeLabel(_ landmark: Landmark) -> String {
var label = landmark.name
if landmark.isFavorite {
label = label + ", favorited"
}

return label
}

var body: some View {
NavigationView {
List {
Expand All @@ -25,6 +34,7 @@ struct LandmarkList: View {
LandmarkDetail(landmark: landmark)
} label: {
LandmarkRow(landmark: landmark)
.accessibilityLabel(makeLabel(landmark))
}
.navigationTitle("Landmarks")
}
Expand Down
2 changes: 2 additions & 0 deletions Landmarks/Views/Landmarks/LandmarkRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ struct LandmarkRow: View {
.resizable()
.frame(width: 50, height: 50)
Text(landmark.name)
.accessibilityHidden(true)

Spacer()

if landmark.isFavorite {
Image(systemName: "star.fill")
.foregroundColor(.yellow)
.accessibilityHidden(true)
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions LandmarksUITests/LandmarksUITests.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@ - (void)testFavoriteUsingPredicates {
// Open landmark page
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"label = %@", @"Turtle Rock"];
XCUIElementQuery *element = [[app descendantsMatchingType:XCUIElementTypeAny]
XCUIElementQuery *query = [[app descendantsMatchingType:XCUIElementTypeAny]
matchingPredicate:predicate];
[[element firstMatch] tap];
[[query firstMatch] tap];

// Mark landmark as favorite
predicate = [NSPredicate predicateWithFormat:@"identifier = %@", @"favorite"];
element = [[app descendantsMatchingType:XCUIElementTypeAny]
query = [[app descendantsMatchingType:XCUIElementTypeAny]
matchingPredicate:predicate];
[[element firstMatch] tap];
[[query firstMatch] tap];

// Go to landmarks list
predicate = [NSPredicate predicateWithFormat:@"label = %@", @"Landmarks"];
element = [[app descendantsMatchingType:XCUIElementTypeAny]
query = [[app descendantsMatchingType:XCUIElementTypeAny]
matchingPredicate:predicate];
[[element firstMatch] tap];
[[query firstMatch] tap];

// Assert that landmark is favorited
predicate = [NSPredicate
predicateWithFormat:@"label = %@", @"Turtle Rock, favorited"];
query = [[app descendantsMatchingType:XCUIElementTypeAny]
matchingPredicate:predicate];
XCUIElement *element = query.allElementsBoundByIndex.firstObject;

XCTAssertTrue(element.exists);
}

@end

0 comments on commit 4d2fcf2

Please sign in to comment.