Skip to content

Petr/qae 487 add accessibility identifiers #798

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

Merged
merged 2 commits into from
Jun 13, 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
7 changes: 7 additions & 0 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -951,13 +951,15 @@ final class StatusTableViewController: LoopChartsTableViewController {
let attributedString = NSMutableAttributedString(attachment: symbolAttachment)
attributedString.append(NSAttributedString(string: NSLocalizedString(" Pre-meal Preset", comment: "Status row title for premeal override enabled (leading space is to separate from symbol)")))
cell.titleLabel.attributedText = attributedString
cell.titleLabel.accessibilityIdentifier = "text_PreMealPresetCellTitle"
case .legacyWorkout:
let symbolAttachment = NSTextAttachment()
symbolAttachment.image = UIImage(named: "workout-symbol")?.withTintColor(.white)

let attributedString = NSMutableAttributedString(attachment: symbolAttachment)
attributedString.append(NSAttributedString(string: NSLocalizedString(" Workout Preset", comment: "Status row title for workout override enabled (leading space is to separate from symbol)")))
cell.titleLabel.attributedText = attributedString
cell.titleLabel.accessibilityIdentifier = "text_WorkoutPresetCellTitle"
case .preset(let preset):
cell.titleLabel.text = String(format: NSLocalizedString("%@ %@", comment: "The format for an active custom preset. (1: preset symbol)(2: preset name)"), preset.symbol, preset.name)
case .custom:
Expand All @@ -967,13 +969,16 @@ final class StatusTableViewController: LoopChartsTableViewController {
if override.isActive() {
if let preset = temporaryPresetsManager.selectablePresets.first(where: { $0.id == override.presetId }), case .preMeal(_) = preset {
cell.subtitleLabel.text = NSLocalizedString("on until carbs added", comment: "The format for the description of a premeal preset end date")
cell.subtitleLabel.accessibilityIdentifier = "text_PresetActiveOn"
} else {
switch override.duration {
case .finite:
let endTimeText = DateFormatter.localizedString(from: override.activeInterval.end, dateStyle: .none, timeStyle: .short)
cell.subtitleLabel.text = String(format: NSLocalizedString("on until %@", comment: "The format for the description of a finite custom preset end date"), endTimeText)
cell.subtitleLabel.accessibilityIdentifier = "text_PresetActiveOn"
case .indefinite:
cell.subtitleLabel.text = NSLocalizedString("on indefinitely", comment: "The format for the description of an indefinite custom preset end date")
cell.subtitleLabel.accessibilityIdentifier = "text_PresetActiveOn"
}
}
} else {
Expand Down Expand Up @@ -1204,6 +1209,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.leading, 36)
.padding(.vertical)
.accessibilityIdentifier("text_ActiveInsulinFooter")
}
}

Expand All @@ -1229,6 +1235,7 @@ final class StatusTableViewController: LoopChartsTableViewController {
case .iob:
if let currentIOB = currentIOBDescription {
cell.setSubtitleLabel(label: currentIOB)
cell.setTitleLabelAccessibilityIdentifier("ActiveInsulin_\(currentIOB.string)")
} else {
cell.setSubtitleLabel(label: nil)
}
Expand Down
1 change: 1 addition & 0 deletions Loop/Views/BolusEntryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct BolusEntryView: View {
Text(viewModel.recommendedBolusString)
.font(.title)
.foregroundColor(Color(.label))
.accessibilityIdentifier("staticText_RecommendedBolus")
bolusUnitsLabel
}
}
Expand Down
1 change: 1 addition & 0 deletions Loop/Views/ManualGlucoseEntryRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct ManualGlucoseEntryRow: View {
unitsChanged()
})
.accessibilityIdentifier("textField_FingerstickGlucose")

Text(displayGlucosePreference.formatter.localizedUnitStringWithPlurality())
.foregroundColor(Color(.secondaryLabel))
}
Expand Down
7 changes: 4 additions & 3 deletions Loop/Views/Presets/Components/CorrectionRangePreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public struct CorrectionRangePreview: View {
HStack(alignment: .top, spacing: 12) {
Text(Image(systemName: "exclamationmark.triangle.fill"))
.foregroundColor(color)
Text(SafetyClassification.captionForCrossedThresholds(crossedThresholds, isRange: true));
Text(SafetyClassification.captionForCrossedThresholds(crossedThresholds, isRange: true))
.accessibilityIdentifier("text_CorrectionRangeWarning");
}
.padding(12)
.background(color.opacity(0.1))
Expand All @@ -104,10 +105,10 @@ public struct CorrectionRangePreview: View {
}.padding(.bottom, 10)
VStack(spacing: 4) {
if let range {
correctionRangeLabel(range: range)
correctionRangeLabel(range: range).accessibilityIdentifier("text_CorrectionRangePreview")
Text("Adjusted Range")
} else {
correctionRangeLabel(range: scheduledRange)
correctionRangeLabel(range: scheduledRange).accessibilityIdentifier("text_CorrectionRangePreview")
Text("Scheduled Range")
}
}
Expand Down
1 change: 1 addition & 0 deletions Loop/Views/Presets/Components/EditPresetDurationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct EditPresetDurationView: View {
.padding([.top, .horizontal])
.background(Color(UIColor.secondarySystemBackground))
.disabled(buttonDisabled)
.accessibilityIdentifier("button_Save")
}
}
.onAppear {
Expand Down
1 change: 1 addition & 0 deletions Loop/Views/Presets/Components/PresetCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct PresetCard: View {

Text(presetName)
.fontWeight(.semibold)
.accessibilityIdentifier("text_Preset\(presetName)")
}
}

Expand Down
2 changes: 2 additions & 0 deletions Loop/Views/Presets/Components/PresetDetentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct PresetDetentView: View {
case .finite:
let endTimeText = DateFormatter.localizedString(from: activeOverride.activeInterval.end, dateStyle: .none, timeStyle: .short)
Text(String(format: NSLocalizedString("on until %@", comment: "The format for the description of a custom preset end date"), endTimeText))
.accessibilityIdentifier("text_PresetActionSheetActiveOn")
case .indefinite:
EmptyView()
}
Expand Down Expand Up @@ -123,6 +124,7 @@ struct PresetDetentView: View {
}
.tint(.accentColor)
.padding(.bottom, -8)
.accessibilityIdentifier("button_EditPreset")
}
}

Expand Down
4 changes: 2 additions & 2 deletions Loop/Views/Presets/EditPresetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct EditPresetView: View {
scheduledRange: scheduledRange,
showDisclosure: true
)
}
}.accessibilityIdentifier("button_CorrectionRange")
}

CardSection("Preset Details") {
Expand Down Expand Up @@ -305,7 +305,7 @@ struct EditPresetView: View {
case .editInsulinNeeds:
ExistingPresetInsulinNeedsEdit(
insulinScaleFactor: $preset.insulinNeedsScaleFactor,
presetUsesScheduledRange: preset.correctionRange == nil,
presetUsesScheduledRange: preset.correctionRange == nil
)
case .editCorrectionRange:
ExistingPresetRangeEdit(
Expand Down
2 changes: 2 additions & 0 deletions Loop/Views/Presets/ExistingPresetRangeEdit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct ExistingPresetRangeEdit: View {
dismiss()
}
.foregroundColor(.blue)
.accessibilityIdentifier("button_Cancel")
}
}
}
Expand All @@ -87,6 +88,7 @@ struct ExistingPresetRangeEdit: View {
}
.disabled(editedRange == range || (editedRange == nil && !presetAdjustsInsulinNeeds))
.buttonStyle(ActionButtonStyle(.primary))
.accessibilityIdentifier("button_Save")
}


Expand Down
1 change: 1 addition & 0 deletions Loop/Views/Presets/PresetRangeEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct PresetRangeEditor: View {
+
boundText(for: (displayedRange).upperBound)
)
.accessibilityIdentifier("text_AdjustedCorrectionRange")


Text("mg/dL")
Expand Down
5 changes: 4 additions & 1 deletion Loop/Views/Presets/PresetsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct PresetsView: View {
HStack {
Text("All Presets")
.font(.title2.bold())
.accessibilityIdentifier("text_AllPresets")
Spacer()

Button("Sort") {
Expand Down Expand Up @@ -287,7 +288,9 @@ struct PresetsView: View {
private var dismissButton: some View {
Button("Done") {
dismiss()
}.bold()
}
.bold()
.accessibilityIdentifier("button_done")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ extension SettingsView {
private var dismissButton: some View {
Button(action: dismiss) {
Text("Done").bold()
}
}.accessibilityIdentifier("button_done")
}

private var loopSection: some View {
Expand Down
2 changes: 2 additions & 0 deletions Loop/Views/StatusTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct StatusTableView: View {
.sheet(item: $viewModel.pendingPreset) { preset in
// This is the active preset; edit disabled
PresetDetentView(preset: preset, didTapEdit: { })
.accessibilityIdentifier("bar_Presets")
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
Expand Down Expand Up @@ -227,6 +228,7 @@ enum ToolbarAction: String, Identifiable, CaseIterable {
.resizable()
.renderingMode(.template)
.foregroundStyle(Color.presets)
.accessibilityIdentifier("image_\(isActive ? "PresetsSelected" : "Presets")")
case .settings:
Image("settings")
.resizable()
Expand Down