From 2df016bbbeee5d62f2790a1609b93b96c4f37d43 Mon Sep 17 00:00:00 2001 From: Zoya Garg <125168583+zoyagarg@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:11:33 -0700 Subject: [PATCH] KATE IS A GOD --- Intake.xcodeproj/project.pbxproj | 4 +++ .../xcshareddata/xcschemes/Intake.xcscheme | 16 +++++++-- Intake/Allergy Records/AddAllergy.swift | 1 + Intake/Allergy Records/AllergyRecords.swift | 6 +++- Intake/Home.swift | 11 ++++-- Intake/SharedContext/FeatureFlags.swift | 3 ++ Intake/SocialHistory/MenstrualHistory.swift | 9 +++-- Intake/SocialHistory/SmokingHistory.swift | 9 +++-- IntakeUITests/AllergyTests.swift | 36 +++++++++++++++++++ 9 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 IntakeUITests/AllergyTests.swift diff --git a/Intake.xcodeproj/project.pbxproj b/Intake.xcodeproj/project.pbxproj index a615ee0..805524a 100644 --- a/Intake.xcodeproj/project.pbxproj +++ b/Intake.xcodeproj/project.pbxproj @@ -115,6 +115,7 @@ A9DFE8A92ABE551400428242 /* AccountButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9DFE8A82ABE551400428242 /* AccountButton.swift */; }; A9FE7AD02AA39BAB0077B045 /* AccountSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */; }; ACAA47812B571C800032D21F /* Questionnaire.json in Resources */ = {isa = PBXBuildFile; fileRef = ACAA47802B571C7F0032D21F /* Questionnaire.json */; }; + ACBC9D1D2BA2B3F6003E2581 /* AllergyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */; }; ACDF32ED2B9D0F4300B127E2 /* MenstrualHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACFFA1D02B8FD8BB0006E6D4 /* MenstrualHistory.swift */; }; ACF862BE2B96E29600ACBA1E /* ExportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF862BD2B96E29600ACBA1E /* ExportView.swift */; }; ACFFA1CE2B8FD7190006E6D4 /* SmokingHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACFFA1CD2B8FD7190006E6D4 /* SmokingHistory.swift */; }; @@ -235,6 +236,7 @@ A9DFE8A82ABE551400428242 /* AccountButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountButton.swift; sourceTree = ""; }; A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSheet.swift; sourceTree = ""; }; ACAA47802B571C7F0032D21F /* Questionnaire.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Questionnaire.json; sourceTree = ""; }; + ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllergyTests.swift; sourceTree = ""; }; ACF862BD2B96E29600ACBA1E /* ExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportView.swift; sourceTree = ""; }; ACFFA1CD2B8FD7190006E6D4 /* SmokingHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmokingHistory.swift; sourceTree = ""; }; ACFFA1D02B8FD8BB0006E6D4 /* MenstrualHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenstrualHistory.swift; sourceTree = ""; }; @@ -563,6 +565,7 @@ children = ( 2F4E237D2989A2FE0013F3D9 /* LaunchTests.swift */, 510CAAF02BA0DFFB00872B1A /* MedicationTests.swift */, + ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */, ); path = IntakeUITests; sourceTree = ""; @@ -931,6 +934,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + ACBC9D1D2BA2B3F6003E2581 /* AllergyTests.swift in Sources */, 510CAAF12BA0DFFB00872B1A /* MedicationTests.swift in Sources */, 2F4E237E2989A2FE0013F3D9 /* LaunchTests.swift in Sources */, ); diff --git a/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme b/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme index c545dfe..80f2f6b 100644 --- a/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme +++ b/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme @@ -82,13 +82,25 @@ isEnabled = "YES"> + + + + + + diff --git a/Intake/Allergy Records/AddAllergy.swift b/Intake/Allergy Records/AddAllergy.swift index 339b95a..e56b862 100644 --- a/Intake/Allergy Records/AddAllergy.swift +++ b/Intake/Allergy Records/AddAllergy.swift @@ -28,6 +28,7 @@ struct EditAllergyView: View { TextField("Allergy Name", text: $data.allergyData[index].allergy) .textFieldStyle(RoundedBorderTextFieldStyle()) .padding([.horizontal, .top]) + .accessibilityLabel("Add Allergy Field") ReactionSectionView(index: index) Spacer() saveButton diff --git a/Intake/Allergy Records/AllergyRecords.swift b/Intake/Allergy Records/AllergyRecords.swift index 4a6e639..e015d25 100644 --- a/Intake/Allergy Records/AllergyRecords.swift +++ b/Intake/Allergy Records/AllergyRecords.swift @@ -56,7 +56,11 @@ struct AllergyList: View { VStack { allergyForm /**/ - if data.generalData.sex == "Female" { + if FeatureFlags.skipToScrollable { + SubmitButton(nextView: NavigationViews.pdfs) + .padding() + } + else if data.generalData.sex == "Female" { SubmitButton(nextView: NavigationViews.menstrual) .padding() } else { diff --git a/Intake/Home.swift b/Intake/Home.swift index 48d7326..c5827ac 100644 --- a/Intake/Home.swift +++ b/Intake/Home.swift @@ -33,8 +33,15 @@ struct StartButton: View { var body: some View { Button(action: { if FeatureFlags.testMedication { - navigationPath.append(NavigationViews.medication) - } else { + navigationPath.append(NavigationViews.medication) + } else if FeatureFlags.testAllergy { + navigationPath.append(NavigationViews.allergies) + } else if FeatureFlags.testMenstrual { + navigationPath.append(NavigationViews.menstrual) + } else if FeatureFlags.testSmoking { + navigationPath.append(NavigationViews.smoking) + } + else { navigationPath.append(NavigationViews.general) } }) { diff --git a/Intake/SharedContext/FeatureFlags.swift b/Intake/SharedContext/FeatureFlags.swift index 0fa3839..99c8028 100644 --- a/Intake/SharedContext/FeatureFlags.swift +++ b/Intake/SharedContext/FeatureFlags.swift @@ -24,6 +24,9 @@ enum FeatureFlags { /// Adds a test task to the schedule at the current time static let testSchedule = CommandLine.arguments.contains("--testSchedule") static let testPatient = CommandLine.arguments.contains("--testPatient") + static let testAllergy = CommandLine.arguments.contains("--testAllergy") + static let testMenstrual = CommandLine.arguments.contains("--testMenstrual") + static let testSmoking = CommandLine.arguments.contains("--testSmoking") static let testMedication = CommandLine.arguments.contains("--testMedication") static let skipToScrollable = CommandLine.arguments.contains("--skipToScrollable") } diff --git a/Intake/SocialHistory/MenstrualHistory.swift b/Intake/SocialHistory/MenstrualHistory.swift index 110c288..0b559d2 100644 --- a/Intake/SocialHistory/MenstrualHistory.swift +++ b/Intake/SocialHistory/MenstrualHistory.swift @@ -55,8 +55,13 @@ struct SocialHistoryQuestionView: View { .onDisappear { data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails) } - SubmitButton(nextView: NavigationViews.smoking) - .padding() + if FeatureFlags.skipToScrollable { + SubmitButton(nextView: NavigationViews.pdfs) + .padding() + } else { + SubmitButton(nextView: NavigationViews.smoking) + .padding() + } } } } diff --git a/Intake/SocialHistory/SmokingHistory.swift b/Intake/SocialHistory/SmokingHistory.swift index 78e723a..ae2bfd5 100644 --- a/Intake/SocialHistory/SmokingHistory.swift +++ b/Intake/SocialHistory/SmokingHistory.swift @@ -36,8 +36,13 @@ struct SmokingHistoryView: View { .onDisappear { storeSmokingHistory() } - SubmitButton(nextView: NavigationViews.chat) - .padding() + if FeatureFlags.skipToScrollable { + SubmitButton(nextView: NavigationViews.pdfs) + .padding() + } else { + SubmitButton(nextView: NavigationViews.chat) + .padding() + } } } } diff --git a/IntakeUITests/AllergyTests.swift b/IntakeUITests/AllergyTests.swift new file mode 100644 index 0000000..0514ec2 --- /dev/null +++ b/IntakeUITests/AllergyTests.swift @@ -0,0 +1,36 @@ +// +// AllergyTests.swift +// IntakeUITests +// +// Created by Zoya Garg on 3/13/24. +// + +import Foundation +import XCTest + +class AllergyTests: XCTestCase { + override func setUpWithError() throws { + try super.setUpWithError() + + continueAfterFailure = false + + let app = XCUIApplication() + app.launchArguments = ["--skipOnboarding", "--disableFirebase", "--testPatient", "--testAllergy", "--skipToScrollable"] + app.launch() + } + + func testAllergy() throws { + let app = XCUIApplication() + + sleep(8) + + XCTAssertEqual(app.state, .runningForeground) + + app.buttons["Create New Form"].tap() + XCUIApplication().navigationBars["Allergies"].tap() + app.buttons["Add_allergy"].tap() + app.textFields["Allergy Name"].tap() + app.textFields["Allergy Name"].typeText("Peanut") + app.buttons["Save"].tap() + } +}