From e8691ca42afe9c259e1d2337a48a11cf3abfb667 Mon Sep 17 00:00:00 2001 From: Zoya Garg <125168583+zoyagarg@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:09:11 -0700 Subject: [PATCH] testing hail mary (#86) # *Zoya Tests* ## :recycle: Current situation & Problem *Link any open issues or pull requests (PRs) related to this PR. Please ensure that all non-trivial PRs are first tracked and discussed in an existing GitHub issue or discussion.* ## :gear: Release Notes *Add a bullet point list summary of the feature and possible migration guides if this is a breaking change so this section can be added to the release notes.* *Include code snippets that provide examples of the feature implemented or links to the documentation if it appends or changes the public interface.* ## :books: Documentation *Please ensure that you properly document any additions in conformance to [Spezi Documentation Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).* *You can use this section to describe your solution, but we encourage contributors to document your reasoning and changes using in-line documentation.* ## :white_check_mark: Testing *Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested.* *This section describes important information about the tests and why some elements might not be testable.* ## :pencil: Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [ ] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md). --- Intake.xcodeproj/project.pbxproj | 4 ++ .../xcshareddata/xcschemes/Intake.xcscheme | 12 ++++++ Intake/Allergy Records/AddAllergy.swift | 1 + Intake/Allergy Records/AllergyRecords.swift | 5 ++- Intake/Home.swift | 10 ++++- Intake/Resources/Localizable.xcstrings | 3 ++ Intake/SharedContext/FeatureFlags.swift | 3 ++ Intake/SocialHistory/MenstrualHistory.swift | 9 +++- Intake/SocialHistory/SmokingHistory.swift | 9 +++- IntakeUITests/AllergyTests.swift | 41 +++++++++++++++++++ 10 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 IntakeUITests/AllergyTests.swift diff --git a/Intake.xcodeproj/project.pbxproj b/Intake.xcodeproj/project.pbxproj index e24276b..e4f31c5 100644 --- a/Intake.xcodeproj/project.pbxproj +++ b/Intake.xcodeproj/project.pbxproj @@ -117,6 +117,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 */; }; @@ -238,6 +239,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 = ""; }; @@ -566,6 +568,7 @@ children = ( 2F4E237D2989A2FE0013F3D9 /* LaunchTests.swift */, 510CAAF02BA0DFFB00872B1A /* MedicationTests.swift */, + ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */, 3CD23D632BA14D6D00AB9914 /* NinasTests.swift */, ); path = IntakeUITests; @@ -934,6 +937,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + ACBC9D1D2BA2B3F6003E2581 /* AllergyTests.swift in Sources */, 510CAAF12BA0DFFB00872B1A /* MedicationTests.swift in Sources */, 2F4E237E2989A2FE0013F3D9 /* LaunchTests.swift in Sources */, 3CD23D642BA14D6D00AB9914 /* NinasTests.swift in Sources */, diff --git a/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme b/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme index c545dfe..8b466af 100644 --- a/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme +++ b/Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme @@ -81,6 +81,18 @@ argument = "--disableFirebase" 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 13ed729..30c7323 100644 --- a/Intake/Allergy Records/AllergyRecords.swift +++ b/Intake/Allergy Records/AllergyRecords.swift @@ -56,7 +56,10 @@ 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 ba7c834..50f3311 100644 --- a/Intake/Home.swift +++ b/Intake/Home.swift @@ -33,8 +33,14 @@ 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/Resources/Localizable.xcstrings b/Intake/Resources/Localizable.xcstrings index 74e5dc2..60cfb3d 100644 --- a/Intake/Resources/Localizable.xcstrings +++ b/Intake/Resources/Localizable.xcstrings @@ -76,6 +76,9 @@ }, "Active" : { + }, + "Add Allergy Field" : { + }, "Add Field" : { 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 2211abc..ae2bfd5 100644 --- a/Intake/SocialHistory/SmokingHistory.swift +++ b/Intake/SocialHistory/SmokingHistory.swift @@ -36,8 +36,13 @@ struct SmokingHistoryView: View { .onDisappear { storeSmokingHistory() } - SubmitButton(nextView: NavigationViews.pdfs) - .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..c92e917 --- /dev/null +++ b/IntakeUITests/AllergyTests.swift @@ -0,0 +1,41 @@ +// +// AllergyTests.swift +// IntakeUITests +// +// Created by Zoya Garg on 3/13/24. + +// This source file is part of the Intake based on the Stanford Spezi Template Application project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT + +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() + } +}