@@ -19,7 +19,8 @@ import XCTest
1919/// Tests the accessibility identifiers, labels or values of the items depending to their states and user actions.
2020final class CheckboxPickerUITests : AppTestCase {
2121
22- /// Select several items and checks if the counter in the root item is updated with the suitable value
22+ /// Select several items and checks if the counter in the root item is updated with the suitable values.
23+ /// beware, we test the accessiiblity value here as until now label is not dynamically updated with count.
2324 @MainActor func testCheckboxPickerRootItemCount( ) throws {
2425
2526 // GIVEN
@@ -29,27 +30,23 @@ final class CheckboxPickerUITests: AppTestCase {
2930 tapButton ( withWording: " app_components_checkbox_label " , app)
3031 tapButton ( withWording: " app_components_checkboxPicker_label " , app)
3132
32- // By default, one element is selected in the picker, wording cannot be used as is
33- var expectedPickerRootItemString = wording ( for: " app_components_checkboxPicker_root " ) + " (1) "
34- assertStaticTextExists ( expectedPickerRootItemString, app)
33+ // By default, no element is selected in the picker, wording cannot be used as is
34+ check ( value: pickerRootItemA11yValue ( with: 0 ) , ofElementWithIdentifier: pickerRootItemA11yIdentifier ( with: 0 ) , app)
3535
3636 // WHEN, THEN
3737
38- // Select all
3938 tapImage ( withName: " dog.fill " , app)
4039 tapImage ( withName: " waterbottle.fill " , app)
41- expectedPickerRootItemString = wording ( for: " app_components_checkboxPicker_root " ) + " (3) "
42- assertStaticTextExists ( expectedPickerRootItemString, app)
40+ check ( value: pickerRootItemA11yValue ( with: 2 ) , ofElementWithIdentifier: pickerRootItemA11yIdentifier ( with: 2 ) , app)
4341
44- // Unselect some
4542 tapImage ( withName: " dog.fill " , app)
46- expectedPickerRootItemString = wording ( for: " app_components_checkboxPicker_root " ) + " (2) "
47- assertStaticTextExists ( expectedPickerRootItemString, app)
43+ check ( value: pickerRootItemA11yValue ( with: 1 ) , ofElementWithIdentifier: pickerRootItemA11yIdentifier ( with: 1 ) , app)
4844
49- // Unselect all
5045 tapImage ( withName: " flame " , app)
51- tapImage ( withName: " waterbottle.fill " , app)
52- expectedPickerRootItemString = wording ( for: " app_components_checkboxPicker_root " )
46+ check ( value: pickerRootItemA11yValue ( with: 2 ) , ofElementWithIdentifier: pickerRootItemA11yIdentifier ( with: 2 ) , app)
47+
48+ tapImage ( withName: " dog.fill " , app)
49+ check ( value: pickerRootItemA11yValue ( with: 3 ) , ofElementWithIdentifier: pickerRootItemA11yIdentifier ( with: 3 ) , app)
5350 }
5451
5552 /// Given the checkbox picker of the demo app,
@@ -71,25 +68,13 @@ final class CheckboxPickerUITests: AppTestCase {
7168 tapButton ( withWording: " app_components_checkbox_label " , app)
7269 tapButton ( withWording: " app_components_checkboxPicker_label " , app)
7370
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)
8671 check ( value: unselectedA11Yvalue, ofElementWithIdentifier: firstItemA11YIdentifier, app)
8772 check ( value: unselectedA11Yvalue, ofElementWithIdentifier: secondItemA11YIdentifier, app)
8873 check ( value: unselectedA11Yvalue, ofElementWithIdentifier: thirdItemA11YIdentifier, app)
8974
9075 // WHEN
9176
92- itemToSelect = otherElements ( withA11yIdentifier: firstItemA11YIdentifier, app) . firstMatch
77+ var itemToSelect = otherElements ( withA11yIdentifier: firstItemA11YIdentifier, app) . firstMatch
9378 itemToSelect. tap ( )
9479
9580 // THEN
0 commit comments