Skip to content

Commit

Permalink
testing hail mary (#86)
Browse files Browse the repository at this point in the history
# *Zoya Tests*

## ♻️ 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.*


## ⚙️ 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.*


## 📚 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.*


## ✅ 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.*


## 📝 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).
  • Loading branch information
zoyagarg authored Mar 14, 2024
1 parent 319d4b5 commit e8691ca
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Intake.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -238,6 +239,7 @@
A9DFE8A82ABE551400428242 /* AccountButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountButton.swift; sourceTree = "<group>"; };
A9FE7ACF2AA39BAB0077B045 /* AccountSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSheet.swift; sourceTree = "<group>"; };
ACAA47802B571C7F0032D21F /* Questionnaire.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Questionnaire.json; sourceTree = "<group>"; };
ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllergyTests.swift; sourceTree = "<group>"; };
ACF862BD2B96E29600ACBA1E /* ExportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportView.swift; sourceTree = "<group>"; };
ACFFA1CD2B8FD7190006E6D4 /* SmokingHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmokingHistory.swift; sourceTree = "<group>"; };
ACFFA1D02B8FD8BB0006E6D4 /* MenstrualHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenstrualHistory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -566,6 +568,7 @@
children = (
2F4E237D2989A2FE0013F3D9 /* LaunchTests.swift */,
510CAAF02BA0DFFB00872B1A /* MedicationTests.swift */,
ACBC9D1C2BA2B3F6003E2581 /* AllergyTests.swift */,
3CD23D632BA14D6D00AB9914 /* NinasTests.swift */,
);
path = IntakeUITests;
Expand Down Expand Up @@ -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 */,
Expand Down
12 changes: 12 additions & 0 deletions Intake.xcodeproj/xcshareddata/xcschemes/Intake.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
argument = "--disableFirebase"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--testAllergy"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--testMenstrual"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--testSmoking"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--skipToScrollable"
isEnabled = "NO">
Expand Down
1 change: 1 addition & 0 deletions Intake/Allergy Records/AddAllergy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Intake/Allergy Records/AllergyRecords.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 8 additions & 2 deletions Intake/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}) {
Expand Down
3 changes: 3 additions & 0 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
},
"Active" : {

},
"Add Allergy Field" : {

},
"Add Field" : {

Expand Down
3 changes: 3 additions & 0 deletions Intake/SharedContext/FeatureFlags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
9 changes: 7 additions & 2 deletions Intake/SocialHistory/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions Intake/SocialHistory/SmokingHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions IntakeUITests/AllergyTests.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit e8691ca

Please sign in to comment.