-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFeatureFormViewTests.swift
More file actions
2084 lines (1501 loc) · 70.1 KB
/
FeatureFormViewTests.swift
File metadata and controls
2084 lines (1501 loc) · 70.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2023 Esri
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import XCTest
@MainActor
final class FeatureFormViewTests: XCTestCase {
override func setUp() async throws {
continueAfterFailure = false
}
func assertFormOpened(titleElement: XCUIElement) {
XCTAssertTrue(
titleElement.waitForExistence(timeout: 30),
"The form failed to open after 30 seconds."
)
}
func openTestCase(id: String = #function) {
let app = XCUIApplication()
let formViewTestsButton = app.buttons["Feature Form Tests"]
// Pass the name of the test function as the testCase, dropping the parentheses.
let testCaseArgument = ["-testCase", "\(id.dropLast(2))"]
app.launchArguments.append(contentsOf: testCaseArgument)
// Open tests
app.launch()
formViewTestsButton.tap()
}
func testAttachmentRenaming() {
let app = XCUIApplication()
let activityIndicator = app.activityIndicators.firstMatch
let attachmentLabel = app.staticTexts["EsriHQ.jpeg"]
let elementTitle = "Attachments"
let formTitle = app.staticTexts["Esri Location"]
let nameField = app.textFields["New name"]
let okButton = app.buttons["OK"]
let renamedAttachmentLabel = app.staticTexts["EsriHQ\(#function).jpeg"]
#if targetEnvironment(macCatalyst)
let rename = app.menuItems["Rename"]
#else
let rename = app.buttons["Rename"]
#endif
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
activityIndicator.assertNonExistence()
attachmentLabel.assertExistence()
#if targetEnvironment(macCatalyst)
attachmentLabel.rightClick()
#else
attachmentLabel.press(forDuration: 1)
#endif
rename.assertExistenceAndTap()
nameField.assertExistenceAndTap()
app.typeText(#function)
okButton.assertExistenceAndTap()
renamedAttachmentLabel.assertExistence()
}
// - MARK: Test case 1: Text Box with no hint, no description, value not required
/// Test case 1.1: unfocused and focused state, no value
func testCase_1_1() throws {
let app = XCUIApplication()
let characterIndicator = app.staticTexts["Single Line No Value, Placeholder or Description Character Indicator"]
let elementTitle = "Single Line No Value, Placeholder or Description"
let elementValue = app.staticTexts[elementTitle]
let footer = app.staticTexts["Single Line No Value, Placeholder or Description Footer"]
let formTitle = app.staticTexts["InputValidation"]
let textField = app.textFields["Single Line No Value, Placeholder or Description Text Input"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementValue.assertExistence()
#if !targetEnvironment(macCatalyst)
XCTAssertFalse(
textField.hasFocus,
"The target text field has focus."
)
#endif
XCTAssertFalse(
footer.isHittable,
"The footer isn't hittable."
)
// Give focus to the target text field.
textField.tap()
elementValue.assertExistence()
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Maximum 256 characters"
)
characterIndicator.assertExistence()
XCTAssertEqual(
characterIndicator.label,
"0"
)
}
/// Test case 1.2: focused and unfocused state, with value (populated)
func testCase_1_2() throws {
let app = XCUIApplication()
let characterIndicator = app.staticTexts["Single Line No Value, Placeholder or Description Character Indicator"]
let clearButton = app.buttons["Single Line No Value, Placeholder or Description Clear Button"]
let elementTitle = "Single Line No Value, Placeholder or Description"
let elementLabel = app.staticTexts[elementTitle]
let footer = app.staticTexts["Single Line No Value, Placeholder or Description Footer"]
let formTitle = app.staticTexts["InputValidation"]
let textField = app.textFields["Single Line No Value, Placeholder or Description Text Input"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
textField.assertExistenceAndTap()
app.typeText("Sample text")
elementLabel.assertExistence()
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Maximum 256 characters"
)
characterIndicator.assertExistence()
characterIndicator.assertLabel("11")
clearButton.assertExistence()
app.typeText("\r")
elementLabel.assertHittable()
XCTAssertFalse(
footer.isHittable,
"The footer is hittable."
)
clearButton.assertHittable()
textField.assertHittable()
}
/// Test case 1.3: unfocused and focused state, with error value (> 256 chars)
func testCase_1_3() throws {
let app = XCUIApplication()
let characterIndicator = app.staticTexts["Single Line No Value, Placeholder or Description Character Indicator"]
let clearButton = app.buttons["Single Line No Value, Placeholder or Description Clear Button"]
let footer = app.staticTexts["Single Line No Value, Placeholder or Description Footer"]
let formTitle = app.staticTexts["InputValidation"]
let elementTitle = "Single Line No Value, Placeholder or Description"
let elementLabel = app.staticTexts[elementTitle]
let textField = app.textFields["Single Line No Value, Placeholder or Description Text Input"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
textField.tap()
app.typeText(.loremIpsum257)
elementLabel.assertExistence()
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Maximum 256 characters"
)
characterIndicator.assertExistence()
characterIndicator.assertLabel("257")
clearButton.assertExistence()
app.typeText("\r")
elementLabel.assertExistence()
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Maximum 256 characters"
)
characterIndicator.assertNonExistence()
clearButton.assertHittable()
textField.assertHittable()
}
func testCase_1_4() {
let app = XCUIApplication()
let footer = app.staticTexts["numbers Footer"]
let formTitle = app.staticTexts["Domain"]
let textField = app.textFields["numbers Text Input"]
openTestCase()
assertFormOpened(titleElement: formTitle)
XCTAssertTrue(textField.stringValue?.isEmpty ?? false)
XCTAssertEqual(
footer.label,
"Range domain 2-5"
)
textField.tap()
textField.typeText("1")
XCTAssertEqual(
footer.label,
"Enter value from 2.0 to 5.0"
)
// Replace the current value with 3
textField.typeText(XCUIKeyboardKey.delete.rawValue)
textField.typeText("3")
footer.assertLabel("Range domain 2-5")
// Replace the current value with 6
textField.typeText(XCUIKeyboardKey.delete.rawValue)
textField.typeText("6")
XCTAssertEqual(
footer.label,
"Enter value from 2.0 to 5.0"
)
}
// - MARK: Test case 2: DateTime picker input type
/// Test case 2.1: Unfocused and focused state, no value, date required
func testCase_2_1() throws {
let app = XCUIApplication()
let elementTitle = "Required Date"
let calendarImage = app.images["\(elementTitle) Calendar Image"]
let clearButton = app.buttons["\(elementTitle) Clear Button"]
let datePicker = app.datePickers["\(elementTitle) Date Picker"]
let elementValue = app.staticTexts["\(elementTitle) Value"]
let footer = app.staticTexts["\(elementTitle) Footer"]
let formTitle = app.staticTexts["DateTimePoint"]
let nowButton = app.buttons["\(elementTitle) Now Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
if elementValue.label != "No Value" {
clearButton.tap()
}
XCTAssertEqual(
elementValue.label,
"No Value"
)
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Date Entry is Required"
)
calendarImage.assertExistence()
elementValue.tap()
datePicker.assertExistence()
XCTAssertEqual(
elementValue.label,
Date.now.formatted()
)
nowButton.assertHittable()
elementValue.tap()
XCTAssertEqual(
footer.label,
"Date Entry is Required"
)
}
/// Test case 2.2: Focused and unfocused state, with value (populated)
func testCase_2_2() {
let app = XCUIApplication()
let elementTitle = "Launch Date and Time for Apollo 11"
let datePicker = app.datePickers["\(elementTitle) Date Picker"]
let elementLabel = app.staticTexts[elementTitle]
let elementValue = app.staticTexts["\(elementTitle) Value"]
let footer = app.staticTexts["\(elementTitle) Footer"]
let formTitle = app.staticTexts["DateTimePoint"]
let nowButton = app.buttons["\(elementTitle) Now Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
XCTAssertEqual(
footer.label,
"Enter the launch date and time (July 16, 1969 13:32 UTC)"
)
elementValue.tap()
datePicker.assertExistence()
let localDate = Calendar.current.date(
from: DateComponents(
timeZone: .gmt, year: 1969, month: 7, day: 16, hour: 13, minute: 32
)
)
XCTAssertEqual(
elementValue.label,
localDate?.formatted()
)
nowButton.assertHittable()
elementValue.tap()
elementValue.assertHittable()
XCTAssertFalse(
datePicker.isHittable,
"The date picker was hittable."
)
}
/// Test case 2.3: Date only, no time
func testCase_2_3() {
let app = XCUIApplication()
let datePicker = app.datePickers["Launch Date for Apollo 11 Date Picker"]
let elementValue = app.staticTexts["Launch Date for Apollo 11 Value"]
let footer = app.staticTexts["Launch Date for Apollo 11 Footer"]
let formTitle = app.staticTexts["DateTimePoint"]
let todayButton = app.buttons["Launch Date for Apollo 11 Today Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
footer.assertExistence()
elementValue.tap()
XCTAssertEqual(
footer.label,
"Enter the Date for the Apollo 11 launch"
)
elementValue.assertHittable()
let localDate = Calendar.current.date(
from: DateComponents(
timeZone: .gmt, year: 2023, month: 7, day: 15, hour: 3, minute: 53
)
)
XCTAssertEqual(
elementValue.label,
localDate?.formatted(.dateTime.day().month().year())
)
datePicker.assertHittable()
todayButton.assertHittable()
}
/// Test case 2.4: Maximum date
func testCase_2_4() {
let app = XCUIApplication()
let elementTitle = "Launch Date Time End"
let clearButton = app.buttons["\(elementTitle) Clear Button"]
let elementValue = app.staticTexts["\(elementTitle) Value"]
let footer = app.staticTexts["\(elementTitle) Footer"]
let formTitle = app.staticTexts["DateTimePoint"]
let nowButton = app.buttons["\(elementTitle) Now Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
if elementValue.label != "No Value" {
clearButton.tap()
}
footer.assertExistence()
elementValue.tap()
nowButton.assertExistenceAndTap()
elementValue.assertExistenceAndTap()
XCTAssertEqual(
footer.label,
"End date and Time 7/27/1969 12:00:00 AM"
)
let localDate = Calendar.current.date(
from: DateComponents(
timeZone: .gmt, year: 1969, month: 7, day: 27, hour: 7
)
)
XCTAssertEqual(
elementValue.label,
localDate?.formatted()
)
}
/// Test case 2.5: Minimum date
func testCase_2_5() {
let app = XCUIApplication()
let elementTitle = "start and end date time"
let datePicker = app.datePickers["\(elementTitle) Date Picker"]
let elementValue = app.staticTexts["\(elementTitle) Value"]
let footer = app.staticTexts["\(elementTitle) Footer"]
let formTitle = app.staticTexts["DateTimePoint"]
let nowButton = app.buttons["\(elementTitle) Now Button"]
let previousMonthButton = datePicker.buttons["Previous Month"]
let julyFirstButton = datePicker.collectionViews.staticTexts["1"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementValue.assertExistence()
footer.assertExistence()
elementValue.tap()
XCTAssertEqual(
footer.label,
"""
Form with Start date and End date defined
Start July 1, 1969
End July 31, 1969
"""
)
nowButton.tap()
XCTAssertTrue(julyFirstButton.waitForExistence(timeout: 5))
julyFirstButton.tap()
let localDate = Calendar.current.date(
from: DateComponents(
timeZone: .gmt, year: 1969, month: 7, day: 1, hour: 7
)
)
elementValue.assertLabel(localDate!.formatted())
XCTAssertFalse(
previousMonthButton.isEnabled,
"The user was able to view June 1969 in the calendar."
)
}
/// Test case 2.6: Clear date
func testCase_2_6() {
let app = XCUIApplication()
let clearButton = app.buttons["Launch Date and Time for Apollo 11 Clear Button"]
let elementLabel = app.staticTexts["Launch Date and Time for Apollo 11"]
let elementValue = app.staticTexts["Launch Date and Time for Apollo 11 Value"]
let formTitle = app.staticTexts["DateTimePoint"]
openTestCase()
assertFormOpened(titleElement: formTitle)
elementLabel.assertHittable()
clearButton.assertExistenceAndTap()
XCTAssertEqual(
elementValue.label,
"No Value"
)
}
// - MARK: Test case 3: Combo Box input type
/// Test case 3.1: Pre-existing value, description, clear button, no value label
func testCase_3_1() {
let app = XCUIApplication()
let elementTitle = "Combo String"
let clearButton = app.buttons["\(elementTitle) Clear Button"]
let elementLabel = app.staticTexts[elementTitle]
let elementValue = app.staticTexts["\(elementTitle) Combo Box Value"]
let formTitle = app.staticTexts["comboBox"]
let footer = app.staticTexts["\(elementTitle) Footer"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertHittable()
elementValue.assertHittable()
XCTAssertEqual(
elementValue.label,
"String 3"
)
clearButton.assertExistenceAndTap()
elementValue.assertLabel("No value")
footer.assertExistence()
XCTAssertEqual(
footer.label,
"Combo Box of Field Type String"
)
}
/// Test case 3.2: No pre-existing value, no value label, options button
func testCase_3_2() {
let app = XCUIApplication()
let elementLabel = app.staticTexts["Combo Integer"]
let elementValue = app.staticTexts["Combo Integer Combo Box Value"]
let formTitle = app.staticTexts["comboBox"]
let optionsButton = app.images["Combo Integer Options Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
elementLabel.assertHittable()
elementValue.assertHittable()
XCTAssertEqual(
elementValue.label,
"No value"
)
optionsButton.assertHittable()
}
/// Test case 3.3: Pick a value
func testCase_3_3() {
let app = XCUIApplication()
let elementLabel = app.staticTexts["Combo String"]
let elementValue = app.staticTexts["Combo String Combo Box Value"]
let firstOptionButton = app.buttons["String 1"]
let formTitle = app.staticTexts["comboBox"]
openTestCase()
assertFormOpened(titleElement: formTitle)
elementLabel.assertHittable()
elementValue.assertHittable()
XCTAssertEqual(
elementValue.label,
"String 3"
)
elementValue.tap()
firstOptionButton.assertExistenceAndTap()
app.doneButton.assertExistenceAndTap()
XCTAssertEqual(
elementValue.label,
"String 1"
)
}
/// Test case 3.4: Picker with a noValueLabel row
func testCase_3_4() {
let app = XCUIApplication()
let elementLabel = app.staticTexts["Combo String"]
let elementValue = app.staticTexts["Combo String Combo Box Value"]
let formTitle = app.staticTexts["comboBox"]
openTestCase()
assertFormOpened(titleElement: formTitle)
elementLabel.assertHittable()
XCTAssertEqual(
elementValue.label,
"String 3"
)
elementValue.tap()
XCTAssertTrue(
app.noValueComboBoxOption.waitForExistence(timeout: 1),
"The no value button doesn't exist."
)
app.noValueComboBoxOption.tap()
app.doneButton.assertExistenceAndTap()
XCTAssertEqual(
elementValue.label,
"No value"
)
}
/// Test case 3.5: Required Value
func testCase_3_5() {
let app = XCUIApplication()
let elementTitle = "Required Combo Box"
let clearButton = app.buttons["\(elementTitle) Clear Button"]
let elementLabel = app.staticTexts["\(elementTitle) *"]
let elementValue = app.staticTexts["\(elementTitle) Combo Box Value"]
let footer = app.staticTexts["\(elementTitle) Footer"]
let formTitle = app.staticTexts["comboBox"]
let oakButton = app.buttons["Oak"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
XCTAssertEqual(
elementValue.label,
"Pine"
)
XCTAssertFalse(
clearButton.isHittable,
"The clear button is hittable."
)
footer.assertExistence()
elementValue.tap()
app.noValueComboBoxOption.assertNonExistence()
oakButton.assertExistenceAndTap()
app.doneButton.assertExistenceAndTap()
XCTAssertEqual(
elementValue.label,
"Oak"
)
}
/// Test case 3.6: noValueOption is 'Hide'
func testCase_3_6() throws {
let app = XCUIApplication()
let elementTitle = "Combo No Value False"
let elementLabel = app.staticTexts[elementTitle]
let elementValue = app.staticTexts["Combo No Value False Combo Box Value"]
let firstOption = app.buttons["First"]
let formTitle = app.staticTexts["comboBox"]
let noValueButton = app.buttons["No Value"]
let optionsButton = app.images["Combo No Value False Options Button"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
XCTAssertTrue(elementValue.label.isEmpty)
optionsButton.assertExistenceAndTap()
firstOption.assertExistence()
noValueButton.assertNonExistence()
firstOption.assertExistenceAndTap()
app.doneButton.assertExistenceAndTap()
XCTAssertEqual(
elementValue.label,
"First"
)
}
/// Test case 3.7: Unsupported value
func testCase_3_7() throws {
let app = XCUIApplication()
let elementTitle = "Unsupported Value"
let elementLabel = app.staticTexts[elementTitle]
let elementValue = app.staticTexts["\(elementTitle) Combo Box Value"]
let formTitle = app.staticTexts["comboBox"]
let unsupportedValueSectionHeader = app.staticTexts["\(elementTitle) Unsupported Value Section"]
let unsupportedValue = app.buttons["0"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
XCTAssertEqual(
elementValue.label,
"0"
)
elementValue.tap()
unsupportedValueSectionHeader.assertExistence()
unsupportedValue.assertExistence()
app.noValueComboBoxOption.assertExistenceAndTap()
unsupportedValueSectionHeader.assertNonExistence()
}
// - MARK: Test case 4: Radio Buttons input type
/// Test case 4.1: Test regular selection
func testCase_4_1() throws {
let app = XCUIApplication()
let birdOption = app.buttons["bird"]
let dogOption = app.buttons["dog"]
let elementTitle = "Radio Button Text"
let elementLabel = app.staticTexts["\(elementTitle) *"]
let formTitle = app.staticTexts["mainobservation_ExportFeatures"]
let noValueOption = app.buttons["No Value"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
noValueOption.assertExistence()
birdOption.assertExistence()
dogOption.assertExistence()
XCTAssertTrue(birdOption.isSelected)
XCTAssertFalse(dogOption.isSelected)
app.buttons["dog"].tap()
XCTAssertTrue(dogOption.isSelected)
XCTAssertFalse(birdOption.isSelected)
}
/// Test case 4.2: Test radio button fallback to combo box
func testCase_4_2() {
let app = XCUIApplication()
let comboBoxOption = app.buttons["Fallback 1 Combo Box Value-Fallback 1 Options Button"]
let element1Title = "Fallback 1"
let element1Value = app.staticTexts["\(element1Title) Combo Box Value"]
let element2Title = "No Value Enabled"
let element3Title = "No Value Disabled"
let formTitle = app.staticTexts["mainobservation_ExportFeatures"]
let naOption = app.buttons["N/A"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(element1Title)
// Verify the Radio Button fallback to Combo Box was successful.
element1Value.assertExistence()
comboBoxOption.assertExistence()
app.filterElements(element2Title)
// Verify the radio buttons are shown even when the no value option is enabled.
naOption.assertExistence()
XCTAssertTrue(naOption.isSelected)
app.filterElements(element3Title)
// Verify the radio buttons are still shown even when the no value option is disabled.
app.buttons["One"].assertExistence()
}
// - MARK: Test case 5: Switch input type
/// Test case 5.1: Test switch on
func testCase_5_1() {
let app = XCUIApplication()
let elementTitle = "switch integer"
let elementLabel = app.staticTexts[elementTitle]
let formTitle = app.staticTexts["mainobservation_ExportFeatures"]
#if targetEnvironment(macCatalyst)
let switchView = app.checkBoxes["\(elementTitle) Switch"]
#else
let switchView = app.switches["\(elementTitle) Switch"]
#endif
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertExistence()
XCTAssertEqual(
switchView.label,
"2"
)
#if targetEnvironment(macCatalyst) || os(visionOS)
switchView.assertExistenceAndTap()
#else
switchView.switches.firstMatch.assertExistenceAndTap()
#endif
switchView.assertLabel("1")
}
/// Test case 5.2: Test switch off
func testCase_5_2() {
let app = XCUIApplication()
let elementTitle = "switch string"
let elementLabel = app.staticTexts[elementTitle]
let formTitle = app.staticTexts["mainobservation_ExportFeatures"]
#if targetEnvironment(macCatalyst)
let switchView = app.checkBoxes["\(elementTitle) Switch"]
#else
let switchView = app.switches["\(elementTitle) Switch"]
#endif
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(elementTitle)
elementLabel.assertHittable()
XCTAssertEqual(
switchView.label,
"1"
)
#if targetEnvironment(macCatalyst) || os(visionOS)
switchView.assertExistenceAndTap()
#else
switchView.switches.firstMatch.assertExistenceAndTap()
#endif
switchView.assertLabel("2")
}
/// Test case 5.3: Test switch with no value
func testCase_5_3() {
let app = XCUIApplication()
let elementLabel = app.staticTexts["switch double"]
let elementValue = app.staticTexts["switch double Combo Box Value"]
let formTitle = app.staticTexts["mainobservation_ExportFeatures"]
openTestCase()
assertFormOpened(titleElement: formTitle)
elementLabel.assertExistence()
elementValue.assertExistence()
}
/// Test case 6.1: Test initially expanded and collapsed
func testCase_6_1() {
let app = XCUIApplication()
let collapsedGroupFirstElement = app.staticTexts["Single Line Text"]
let collapsedGroupTitle = "Group with Multiple Form Elements 2"
let expandedGroupTitle = "Group with Multiple Form Elements"
let expandedGroupFirstElement = app.staticTexts["MultiLine Text"]
let formTitle = app.staticTexts["group_formelement_UI_not_editable"]
#if targetEnvironment(macCatalyst)
let collapsedGroup = app.buttons["\(collapsedGroupTitle), This group is not expanded for initial state"]
let expandedGroup = app.buttons["\(expandedGroupTitle), This Group is 'Expand initial state'\nThis group is Visible"]
#else
let collapsedGroup = app.staticTexts[collapsedGroupTitle]
let expandedGroup = app.staticTexts[expandedGroupTitle]
#endif
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(expandedGroupTitle)
expandedGroup.assertExistence()
// Confirm the first element of the expanded group exists.
expandedGroupFirstElement.assertExistence()
app.filterElements(collapsedGroupTitle)
collapsedGroup.assertExistence()
// Confirm the first element of the collapsed group doesn't exist.
collapsedGroupFirstElement.assertNonExistence()
}
/// Test case 6.2: Test visibility of empty group
func testCase_6_2() throws {
let app = XCUIApplication()
let group1ElementTitle = "Group with children that are visible dependent"
let group1TextElementLabel = app.staticTexts["single line text 3"]
let group2ElementTitle = "Group with Multiple Form Elements"
let formTitle = app.staticTexts["group_formelement_UI_not_editable"]
let hiddenElementsGroup = app.staticTexts[group1ElementTitle]
let hiddenElementsGroupDescription = app.staticTexts["\(group1ElementTitle) Description"]
let radioOptionA = app.buttons["No value"]
let radioOptionB = app.buttons["Everything is working great"]
let radioOptionC = app.buttons["show invisible form element"]
openTestCase()
assertFormOpened(titleElement: formTitle)
app.filterElements(group1ElementTitle)
hiddenElementsGroup.assertExistence()
hiddenElementsGroupDescription.assertExistence()
XCTAssertEqual(
hiddenElementsGroupDescription.label,
"The Form Elements in this group need the Radio button \"show invisible form elements\" to be selected, if you want to see them"
)
// Confirm the first element of the conditional group doesn't exist.
group1TextElementLabel.assertNonExistence()
app.filterElements(group2ElementTitle)
#if targetEnvironment(macCatalyst)
radioOptionA.swipeUp()
#endif
// Show the invisible elements.
radioOptionB.assertExistenceAndTap()