Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QAE-446] Add identifiers for new test #637

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LoopKitUI/Views/CardList/CardList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public struct CardList<Trailer: View>: View {
VStack(spacing: 4) {
titleText
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier("titleText_TherapySettings")

cards
if let trailer = trailer {
Expand Down
2 changes: 2 additions & 0 deletions LoopKitUI/Views/ChartTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public final class ChartTableViewCell: UITableViewCell {
public var doesNavigate: Bool = true {
didSet {
rightArrowHint?.isHidden = !doesNavigate
rightArrowHint?.accessibilityIdentifier =
"image_navigateToGlucoseDetails_\(doesNavigate)"
}
}

Expand Down
1 change: 1 addition & 0 deletions LoopKitUI/Views/ConfigurationPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public struct ConfigurationPage<ActionAreaContent: View>: View {
.buttonStyle(ActionButtonStyle(.primary))
.disabled(actionButtonState != .enabled)
.padding()
.accessibilityIdentifier("button_confirmSave")
}
.padding(.bottom) // FIXME: unnecessary on iPhone 8 size devices
.background(Color(.secondarySystemGroupedBackground).shadow(radius: 5))
Expand Down
21 changes: 21 additions & 0 deletions LoopKitUI/Views/GuardrailConstraintedQuantityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ public struct GuardrailConstrainedQuantityView: View {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(warningColor)
.transition(.springInDisappear)
.accessibilityIdentifier(accessibilityIdentifier)
}

Text(formatter.string(from: value!.doubleValue(for: unit)) ?? "\(value!.doubleValue(for: unit))")
.foregroundColor(warningColor)
.fixedSize(horizontal: true, vertical: false)
.accessibilityIdentifier("text_setGlucoseValue")
} else {
Text("–")
.foregroundColor(.secondary)
Expand Down Expand Up @@ -109,6 +111,25 @@ public struct GuardrailConstrainedQuantityView: View {
}
}
}

private var accessibilityIdentifier: String {
guard let value = value else {
return "noWarningImage"
}


switch guardrail.classification(for: value) {
case .withinRecommendedRange:
return "noWarningImage"
case .outsideRecommendedRange(let threshold):
switch threshold {
case .minimum, .maximum:
return "imageNextToText_warningTriangleRed"
case .belowRecommended, .aboveRecommended:
return "imageNextToText_warningTriangleOrange"
}
}
}
}

fileprivate extension AnyTransition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public struct GlucoseTherapySettingInformationView<Content: View>: View {
Text(therapySetting.guardrailInformationText)
}
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier(
"text_\(self.therapySetting.title.replacing(" ", with: ""))Information"
)
}

private var illustrationImageName: String {
Expand Down
4 changes: 3 additions & 1 deletion LoopKitUI/Views/Information Screens/InformationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,18 @@ struct InformationView<InformationalContent: View> : View {
.font(.largeTitle)
.bold()
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier("titleText_therapySettingsEducationTitle")
}

private var cancelButton: some View {
Button(action: onExit, label: { Text(LocalizedString("Close", comment: "Text to close informational page")) })
.accessibilityIdentifier("button_close")
}

private var nextPageButton: some View {
Button(action: onExit) {
buttonText
.actionButtonStyle(.primary)
}
}.accessibilityIdentifier("button_continue")
}
}
4 changes: 2 additions & 2 deletions LoopKitUI/Views/NewScheduleItemEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ struct NewScheduleItemEditor<Value, ValuePicker: View>: View {
var body: some View {
VStack(spacing: 0) {
ModalHeaderButtonBar(
leading: { cancelButton },
leading: { cancelButton.accessibilityIdentifier("button_cancelNewEntry") },
center: {
Text(LocalizedString("New Entry", comment: "Title for mini-modal to add a new schedule entry"))
.font(.headline)
},
trailing: { addButton }
trailing: { addButton.accessibilityIdentifier("button_addNewEntry") }
)

ScheduleItemPicker(
Expand Down
9 changes: 5 additions & 4 deletions LoopKitUI/Views/ScheduleEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ struct ScheduleEditor<Value: Equatable, ValueContent: View, ValuePicker: View, A
)
}
)
}
.accessibility(identifier: "schedule_item_\(index)")
}.accessibility(identifier: "schedule_item_\(index)")
}

private func isEditing(_ index: Int) -> Binding<Bool> {
Expand Down Expand Up @@ -365,7 +364,7 @@ struct ScheduleEditor<Value: Equatable, ValueContent: View, ValuePicker: View, A
.fontWeight(.regular)
}
.offset(x: -6, y: 0)
}
}.accessibilityIdentifier("button_back")
}

private var backButtonTitle: String { LocalizedString("Back", comment: "Back navigation button title") }
Expand All @@ -386,6 +385,7 @@ struct ScheduleEditor<Value: Equatable, ValueContent: View, ValuePicker: View, A
}
)
.disabled(scheduleItems.count == 1)
.accessibilityIdentifier("button_edit")
}

var doneButton: some View {
Expand All @@ -398,7 +398,7 @@ struct ScheduleEditor<Value: Equatable, ValueContent: View, ValuePicker: View, A
label: {
Text(LocalizedString("Done", comment: "Text for done button")).bold()
}
)
).accessibilityIdentifier("button_done")
}

var addButton: some View {
Expand All @@ -415,6 +415,7 @@ struct ScheduleEditor<Value: Equatable, ValueContent: View, ValuePicker: View, A
}
)
.disabled(tableDeletionState != .disabled || scheduleItems.count >= scheduleItemLimit)
.accessibilityIdentifier("button_add")
}

private func startSaving() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public struct InsulinModelSelection: View {
// Styling to mimic the floating button of a ConfigurationPage
.padding(.bottom)
.background(Color(.secondarySystemGroupedBackground).shadow(radius: 5))
.accessibilityIdentifier("button_confirmSave")
}
.supportedInterfaceOrientations(.portrait)
.edgesIgnoringSafeArea(.bottom)
Expand Down
24 changes: 17 additions & 7 deletions LoopKitUI/Views/Settings Editors/TherapySettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public struct TherapySettingsView: View {
}
.buttonStyle(ActionButtonStyle(.primary))
.padding()
.accessibilityIdentifier("button_\(actionButton.localizedString.lowercased())")
}
}
}
Expand All @@ -156,8 +157,10 @@ extension TherapySettingsView {
VStack(alignment: .leading) {
Text(LocalizedString("Prescription", comment: "title for prescription section"))
.bold()
.accessibilityIdentifier("titleText_Prescription")
Spacer()
DescriptiveText(label: prescriptionDescriptiveText)
.accessibilityIdentifier("descriptiveText_Prescription")
}
Spacer()
}
Expand Down Expand Up @@ -211,7 +214,7 @@ extension TherapySettingsView {
isEditing: false,
// Workaround for strange animation behavior on appearance
forceDisableAnimations: true
)
).accessibilityIdentifier("glucoseSafetyLimitValue")
}
}
}
Expand All @@ -229,6 +232,7 @@ extension TherapySettingsView {
range: items[index].value,
unit: glucoseUnit,
guardrail: .correctionRange)
.accessibilityIdentifier("correctionRangeValue")
}
}
}
Expand All @@ -245,7 +249,7 @@ extension TherapySettingsView {
preset: CorrectionRangeOverrides.Preset.preMeal,
suspendThreshold: viewModel.suspendThreshold,
correctionRangeScheduleRange: schedule.scheduleRange()
)
).accessibilityIdentifier("preMealPresetValue")
}
}
}
Expand All @@ -261,7 +265,7 @@ extension TherapySettingsView {
preset: CorrectionRangeOverrides.Preset.workout,
suspendThreshold: self.viewModel.suspendThreshold,
correctionRangeScheduleRange: schedule.scheduleRange()
)
).accessibilityIdentifier("workoutPresetValue")
}
}
}
Expand All @@ -282,17 +286,19 @@ extension TherapySettingsView {
value: items[index].value,
unit: .internationalUnitsPerHour,
guardrail: .basalRate(supportedBasalRates: supportedBasalRates))
.accessibilityIdentifier("basalRateValue")
}
SectionDivider()
HStack {
Text(NSLocalizedString("Total", comment: "The text indicating Total for Daily Schedule Basal"))
.bold()
.foregroundColor(.primary)
Spacer()
Text(String(format: "%.2f ",total))
(Text(String(format: "%.2f ",total))
.foregroundColor(.primary) +
Text(NSLocalizedString("U/day", comment: "The text indicating U/day for Daily Schedule Basal"))
.foregroundColor(.secondary)
.foregroundColor(.secondary))
.accessibilityIdentifier("basalRateTotalValue")
}
}
}
Expand Down Expand Up @@ -322,7 +328,7 @@ extension TherapySettingsView {
isEditing: false,
// Workaround for strange animation behavior on appearance
forceDisableAnimations: true
)
).accessibilityIdentifier("maxBasalRateValue")
}
}
.accessibilityElement(children: .combine)
Expand All @@ -340,7 +346,7 @@ extension TherapySettingsView {
isEditing: false,
// Workaround for strange animation behavior on appearance
forceDisableAnimations: true
)
).accessibilityIdentifier("maxBolusValue")
}
}
.accessibilityElement(children: .combine)
Expand Down Expand Up @@ -385,6 +391,7 @@ extension TherapySettingsView {
value: items[index].value,
unit: .gramsPerUnit,
guardrail: .carbRatio)
.accessibilityIdentifier("carbRatioValue")
}
}
}
Expand All @@ -402,6 +409,7 @@ extension TherapySettingsView {
value: items[index].value,
unit: sensitivityUnit,
guardrail: .insulinSensitivity)
.accessibilityIdentifier("insulinSensitivityValue")
}
}
}
Expand Down Expand Up @@ -577,10 +585,12 @@ struct SectionWithTapToEdit<Content, NavigationDestination>: View where Content:
VStack(alignment: .leading) {
Text(title)
.bold()
.accessibilityIdentifier("titleText_\(title.replacingOccurrences(of: " ", with: ""))")
Spacer()
HStack {
DescriptiveText(label: descriptiveText)
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier("descriptiveText_\(title.replacingOccurrences(of: " ", with: ""))")
Spacer()
if isEnabled {
NavigationLink(destination: destination(onFinish), isActive: $isActive) {
Expand Down
11 changes: 11 additions & 0 deletions LoopKitUI/Views/WarningView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public struct WarningView: View {
HStack(alignment: .center) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(warningColor)
.accessibilityIdentifier(accessibilityIdentifier)

title
.font(Font(UIFont.preferredFont(forTextStyle: .title3)))
.bold()
.fixedSize(horizontal: false, vertical: true)
.accessibilityIdentifier("text_guardrailWarning")
}
.padding(.bottom, 2)

Expand All @@ -63,4 +65,13 @@ public struct WarningView: View {
return guidanceColors.critical
}
}

private var accessibilityIdentifier: String {
switch severity {
case .default:
return "image_warningTriangleOrange"
case .critical:
return "image_warningTriangleRed"
}
}
}