Skip to content

Commit ca0cd46

Browse files
committed
test: fix tests with typos in buttons and initial states
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 7a54796 commit ca0cd46

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

DesignToolbox/DesignToolbox/Pages/Components/Checkbox/CheckboxPicker/CheckboxPickerPage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct CheckboxPickerPage: View {
3838

3939
private struct CheckboxPickerDemo: View {
4040

41-
@State private var selections: [String] = ["Choice_1"] // cf configurationModel.populate()
41+
@State private var selections: [String] = []
4242
@ObservedObject var configurationModel: CheckboxPickerConfigurationModel
4343
@Environment(\.theme) private var theme
4444

DesignToolbox/DesignToolbox/Resources/Localizable.xcstrings

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,19 +897,19 @@
897897
"localizations" : {
898898
"ar" : {
899899
"stringUnit" : {
900-
"state" : "translated",
900+
"state" : "needs_review",
901901
"value" : "Checkbox Item"
902902
}
903903
},
904904
"en" : {
905905
"stringUnit" : {
906906
"state" : "translated",
907-
"value" : "Checkbox item"
907+
"value" : "Checkbox Item"
908908
}
909909
},
910910
"fr" : {
911911
"stringUnit" : {
912-
"state" : "translated",
912+
"state" : "needs_review",
913913
"value" : "Checkbox Item"
914914
}
915915
}
@@ -2347,23 +2347,24 @@
23472347
"localizations" : {
23482348
"ar" : {
23492349
"stringUnit" : {
2350-
"state" : "translated",
2350+
"state" : "needs_review",
23512351
"value" : "Switch Item"
23522352
}
23532353
},
23542354
"en" : {
23552355
"stringUnit" : {
23562356
"state" : "translated",
2357-
"value" : "Switch item"
2357+
"value" : "Switch Item"
23582358
}
23592359
},
23602360
"fr" : {
23612361
"stringUnit" : {
2362-
"state" : "translated",
2362+
"state" : "needs_review",
23632363
"value" : "Switch Item"
23642364
}
23652365
}
2366-
}
2366+
},
2367+
"shouldTranslate" : false
23672368
},
23682369
"app_tokens_border_description_text" : {
23692370
"comment" : "Tokens - Border",

DesignToolbox/DesignToolboxUITests/Components/Checkboxes/CheckboxItemUITests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class CheckboxItemUITests: AppTestCase {
2626
let app = launchApp()
2727
goToComponentsSheet(app)
2828
tapButton(withWording: "app_components_checkbox_label", app)
29+
waitForButtonToAppear(withWording: "Checkbox Item", app)
2930
tapButton(withWording: "Checkbox Item", app)
3031

3132
let checkbox = otherElements(withA11yIdentifier: A11YIdentifiers.componentCheckboxItem, app).firstMatch

DesignToolbox/DesignToolboxUITests/Components/Checkboxes/CheckboxPickerUITests.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,13 @@ final class CheckboxPickerUITests: AppTestCase {
7171
tapButton(withWording: "app_components_checkbox_label", app)
7272
tapButton(withWording: "app_components_checkboxPicker_label", app)
7373

74-
check(value: selectedA11Yvalue, ofElementWithIdentifier: firstItemA11YIdentifier, app)
75-
check(value: unselectedA11Yvalue, ofElementWithIdentifier: secondItemA11YIdentifier, app)
76-
check(value: unselectedA11Yvalue, ofElementWithIdentifier: thirdItemA11YIdentifier, app)
77-
78-
// WHEN
79-
80-
var itemToSelect = otherElements(withA11yIdentifier: firstItemA11YIdentifier, app).firstMatch
81-
itemToSelect.tap()
82-
83-
// THEN
84-
85-
check(value: pickerRootItemA11yValue(with: 0), ofElementWithLabel: rootItemA11YLabel, app)
8674
check(value: unselectedA11Yvalue, ofElementWithIdentifier: firstItemA11YIdentifier, app)
8775
check(value: unselectedA11Yvalue, ofElementWithIdentifier: secondItemA11YIdentifier, app)
8876
check(value: unselectedA11Yvalue, ofElementWithIdentifier: thirdItemA11YIdentifier, app)
8977

9078
// WHEN
9179

92-
itemToSelect = otherElements(withA11yIdentifier: firstItemA11YIdentifier, app).firstMatch
80+
var itemToSelect = otherElements(withA11yIdentifier: firstItemA11YIdentifier, app).firstMatch
9381
itemToSelect.tap()
9482

9583
// THEN

DesignToolbox/DesignToolboxUITests/Components/Switches/SwitchItemUITests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class SwitchItemUITests: AppTestCase {
2828
swipeFromDownToUp(app)
2929
swipeFromDownToUp(app)
3030
tapButton(withWording: "app_components_switch_label", app)
31+
waitForButtonToAppear(withWording: "Switch Item", app)
3132
tapButton(withWording: "Switch Item", app)
3233

3334
let switchItem = otherElements(withA11yIdentifier: A11YIdentifiers.componentSwitchItem, app).firstMatch

DesignToolbox/DesignToolboxUITests/Utils/AppTestCase.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ open class AppTestCase: XCTestCase {
117117

118118
// MARK: - Helpers
119119

120+
@MainActor func waitForButtonToAppear(withWording key: String, _ app: XCUIApplication, _ timeout: TimeInterval = 5) {
121+
let wording = wording(for: key)
122+
let buttonToWaitFor = app.buttons[wording]
123+
let doesButtonExist = buttonToWaitFor.waitForExistence(timeout: timeout)
124+
XCTAssertTrue(doesButtonExist, "The button with wording '\(wording)' did not appear after \(timeout) seconds")
125+
}
126+
120127
/// Checks if the first element with this a11y identifier exists and has the wording with the given value as key
121128
@MainActor func check(value: String, ofElementWithIdentifier identifier: String, _ app: XCUIApplication) {
122129
let element = otherElements(withA11yIdentifier: identifier, app).firstMatch
@@ -126,7 +133,7 @@ open class AppTestCase: XCTestCase {
126133
XCTAssertTrue(currentValue == expectedValue,
127134
"The expected accessible value for the element is '\(expectedValue)' and not '\(currentValue)'")
128135
} else {
129-
XCTFail("The value to comapre does not exist!")
136+
XCTFail("The value to compare does not exist!")
130137
}
131138
} else {
132139
XCTFail("The element does not exists or the demo has been changed since!")

0 commit comments

Comments
 (0)