Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer committed Feb 15, 2023
1 parent 0c76221 commit 5091cdb
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 384 deletions.
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
#
# SPDX-License-Identifier: MIT
#
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
41 changes: 23 additions & 18 deletions PAWS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
2F36AD24299D93E200B1077C /* NotificationsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F36AD23299D93E200B1077C /* NotificationsTests.swift */; };
2F36AD27299D989F00B1077C /* XCTestExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 2F36AD26299D989F00B1077C /* XCTestExtensions */; };
2F49B7762980407C00BCB272 /* CardinalKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2F49B7752980407B00BCB272 /* CardinalKit */; };
2F49B7782980407C00BCB272 /* FHIR in Frameworks */ = {isa = PBXBuildFile; productRef = 2F49B7772980407C00BCB272 /* FHIR */; };
2F49B77A2980407C00BCB272 /* HealthKitDataSource in Frameworks */ = {isa = PBXBuildFile; productRef = 2F49B7792980407C00BCB272 /* HealthKitDataSource */; };
Expand All @@ -18,7 +20,6 @@
2F4E237E2989A2FE0013F3D9 /* OnboardingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4E237D2989A2FE0013F3D9 /* OnboardingTests.swift */; };
2F4E23812989C5930013F3D9 /* XCTHealthKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2F4E23802989C5930013F3D9 /* XCTHealthKit */; };
2F4E23832989D51F0013F3D9 /* PAWSAppTestingSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4E23822989D51F0013F3D9 /* PAWSAppTestingSetup.swift */; };
2F4E23852989D9130013F3D9 /* XCUIApplication+DeleteAndLaunch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4E23842989D9130013F3D9 /* XCUIApplication+DeleteAndLaunch.swift */; };
2F4E23872989DB360013F3D9 /* ContactsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4E23862989DB360013F3D9 /* ContactsTests.swift */; };
2F4E23892989DB400013F3D9 /* HealthKitUploadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F4E23882989DB400013F3D9 /* HealthKitUploadTests.swift */; };
2F59B93D298C628800C5107F /* PAWSContacts in Frameworks */ = {isa = PBXBuildFile; productRef = 2F59B93C298C628800C5107F /* PAWSContacts */; };
Expand All @@ -34,7 +35,6 @@
653A2551283387FE005D4D48 /* PAWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A2550283387FE005D4D48 /* PAWS.swift */; };
653A255528338800005D4D48 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653A255428338800005D4D48 /* Assets.xcassets */; };
653A256228338800005D4D48 /* PAWSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A256128338800005D4D48 /* PAWSTests.swift */; };
653A256C28338800005D4D48 /* SchedulerAndQuestionnaireTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A256B28338800005D4D48 /* SchedulerAndQuestionnaireTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -55,10 +55,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2F36AD23299D93E200B1077C /* NotificationsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsTests.swift; sourceTree = "<group>"; };
2F49B77329803E8F00BCB272 /* PAWSModules */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = PAWSModules; sourceTree = "<group>"; };
2F4E237D2989A2FE0013F3D9 /* OnboardingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTests.swift; sourceTree = "<group>"; };
2F4E23822989D51F0013F3D9 /* PAWSAppTestingSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PAWSAppTestingSetup.swift; sourceTree = "<group>"; };
2F4E23842989D9130013F3D9 /* XCUIApplication+DeleteAndLaunch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIApplication+DeleteAndLaunch.swift"; sourceTree = "<group>"; };
2F4E23862989DB360013F3D9 /* ContactsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsTests.swift; sourceTree = "<group>"; };
2F4E23882989DB400013F3D9 /* HealthKitUploadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthKitUploadTests.swift; sourceTree = "<group>"; };
2F5E32BC297E05EA003432F8 /* PAWSAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PAWSAppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -72,7 +72,6 @@
653A255D28338800005D4D48 /* PAWSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PAWSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
653A256128338800005D4D48 /* PAWSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PAWSTests.swift; sourceTree = "<group>"; };
653A256728338800005D4D48 /* PAWSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PAWSUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
653A256B28338800005D4D48 /* SchedulerAndQuestionnaireTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchedulerAndQuestionnaireTests.swift; sourceTree = "<group>"; };
653A258928339462005D4D48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -111,20 +110,13 @@
buildActionMask = 2147483647;
files = (
2F4E23812989C5930013F3D9 /* XCTHealthKit in Frameworks */,
2F36AD27299D989F00B1077C /* XCTestExtensions in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2F4E238A2989DB470013F3D9 /* Helper Extensions */ = {
isa = PBXGroup;
children = (
2F4E23842989D9130013F3D9 /* XCUIApplication+DeleteAndLaunch.swift */,
);
path = "Helper Extensions";
sourceTree = "<group>";
};
2FC9759D2978E30800BA99FE /* Supporting Files */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -182,10 +174,9 @@
653A256A28338800005D4D48 /* PAWSUITests */ = {
isa = PBXGroup;
children = (
2F4E238A2989DB470013F3D9 /* Helper Extensions */,
2F4E237D2989A2FE0013F3D9 /* OnboardingTests.swift */,
653A256B28338800005D4D48 /* SchedulerAndQuestionnaireTests.swift */,
2F4E23862989DB360013F3D9 /* ContactsTests.swift */,
2F36AD23299D93E200B1077C /* NotificationsTests.swift */,
2F4E23882989DB400013F3D9 /* HealthKitUploadTests.swift */,
);
path = PAWSUITests;
Expand Down Expand Up @@ -270,6 +261,7 @@
name = PAWSUITests;
packageProductDependencies = (
2F4E23802989C5930013F3D9 /* XCTHealthKit */,
2F36AD26299D989F00B1077C /* XCTestExtensions */,
);
productName = TemplateApplicationUITests;
productReference = 653A256728338800005D4D48 /* PAWSUITests.xctest */;
Expand Down Expand Up @@ -310,6 +302,7 @@
packageReferences = (
2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "CardinalKit" */,
2F4E237F2989C5930013F3D9 /* XCRemoteSwiftPackageReference "XCTHealthKit" */,
2F36AD25299D989F00B1077C /* XCRemoteSwiftPackageReference "XCTestExtensions" */,
);
productRefGroup = 653A254E283387FE005D4D48 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -393,10 +386,9 @@
buildActionMask = 2147483647;
files = (
2F4E23872989DB360013F3D9 /* ContactsTests.swift in Sources */,
2F36AD24299D93E200B1077C /* NotificationsTests.swift in Sources */,
2F4E23892989DB400013F3D9 /* HealthKitUploadTests.swift in Sources */,
2F4E237E2989A2FE0013F3D9 /* OnboardingTests.swift in Sources */,
2F4E23852989D9130013F3D9 /* XCUIApplication+DeleteAndLaunch.swift in Sources */,
653A256C28338800005D4D48 /* SchedulerAndQuestionnaireTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -744,25 +736,38 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
2F36AD25299D989F00B1077C /* XCRemoteSwiftPackageReference "XCTestExtensions" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordBDHG/XCTestExtensions";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.3.0;
};
};
2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "CardinalKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordBDHG/CardinalKit";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.2.1;
minimumVersion = 0.3.0;
};
};
2F4E237F2989C5930013F3D9 /* XCRemoteSwiftPackageReference "XCTHealthKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/StanfordBDHG/XCTHealthKit";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.1.0;
minimumVersion = 0.3.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
2F36AD26299D989F00B1077C /* XCTestExtensions */ = {
isa = XCSwiftPackageProductDependency;
package = 2F36AD25299D989F00B1077C /* XCRemoteSwiftPackageReference "XCTestExtensions" */;
productName = XCTestExtensions;
};
2F49B7752980407B00BCB272 /* CardinalKit */ = {
isa = XCSwiftPackageProductDependency;
package = 2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "CardinalKit" */;
Expand Down
4 changes: 1 addition & 3 deletions PAWS.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
}
],
"defaultOptions" : {
"maximumTestRepetitions" : 2,
"targetForVariableExpansion" : {
"containerPath" : "container:PAWS.xcodeproj",
"identifier" : "653A254C283387FE005D4D48",
"name" : "PAWS"
},
"testRepetitionMode" : "retryOnFailure"
}
},
"testTargets" : [
{
Expand Down
2 changes: 1 addition & 1 deletion PAWS/PAWS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ struct PAWS: App {
}
.sheet(isPresented: isSheetPresented) {
OnboardingFlow()
.interactiveDismissDisabled(true)
}
.interactiveDismissDisabled(true)
.testingSetup()
.cardinalKit(appDelegate)
}
Expand Down
2 changes: 1 addition & 1 deletion PAWSModules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
.library(name: "PAWSNotificationScreen", targets: ["PAWSNotificationScreen"])
],
dependencies: [
.package(url: "https://github.com/StanfordBDHG/CardinalKit.git", .upToNextMinor(from: "0.2.1"))
.package(url: "https://github.com/StanfordBDHG/CardinalKit.git", .upToNextMinor(from: "0.3.0"))
],
targets: [
.target(
Expand Down
33 changes: 5 additions & 28 deletions PAWSUITests/ContactsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,13 @@ class ContactsTests: XCTestCase {
func testContacts() throws {
let app = XCUIApplication()

XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Contacts"].waitForExistence(timeout: 0.5))
XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Contacts"].waitForExistence(timeout: 2))
app.tabBars["Tab Bar"].buttons["Contacts"].tap()

// XCTAssertTrue(app.staticTexts["Leland Stanford"].waitForExistence(timeout: 0.5))
// XCTAssertTrue(app.staticTexts["University Founder"].waitForExistence(timeout: 0.5))
// XCTAssertTrue(app.staticTexts["Stanford University"].waitForExistence(timeout: 0.5))
//
// XCTAssertTrue(app.buttons["Call"].waitForExistence(timeout: 0.5))
// app.buttons["Call"].tap()
// app.alerts["Call"].scrollViews.otherElements.buttons["Ok"].tap()
//
// XCTAssertTrue(app.buttons["Text"].waitForExistence(timeout: 0.5))
// app.buttons["Text"].tap()
// app.alerts["Text"].scrollViews.otherElements.buttons["Ok"].tap()
//
// XCTAssertTrue(app.buttons["Email"].waitForExistence(timeout: 0.5))
// app.buttons["Email"].tap()
// app.alerts["Email"].scrollViews.otherElements.buttons["Ok"].tap()
//
// XCTAssertTrue(app.buttons["Website"].waitForExistence(timeout: 0.5))
// app.buttons["Website"].tap()

// let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")
// XCTAssert(safari.wait(for: .runningForeground, timeout: 5.0))
// app.activate()
//
// XCTAssertTrue(app.buttons["Address, 450 Serra Mall\nStanford CA 94305\nUSA"].waitForExistence(timeout: 0.5))
// app.buttons["Address, 450 Serra Mall\nStanford CA 94305\nUSA"].tap()
XCTAssertTrue(app.staticTexts["Scott Ceresnak"].waitForExistence(timeout: 2))

app.swipeUp(velocity: .fast)

// let maps = XCUIApplication(bundleIdentifier: "com.apple.Maps")
// XCTAssert(maps.wait(for: .runningForeground, timeout: 5.0))
XCTAssertTrue(app.staticTexts["Aydin Zahedivash"].waitForExistence(timeout: 2))
}
}
128 changes: 62 additions & 66 deletions PAWSUITests/HealthKitUploadTests.swift
Original file line number Diff line number Diff line change
@@ -1,67 +1,63 @@
////
//// This source file is part of the CS342 2023 PAWS Team Application project
////
//// SPDX-FileCopyrightText: 2023 Stanford University
////
//// SPDX-License-Identifier: MIT
////
//
// import XCTest
// import XCTHealthKit
//
//
// class HealthKitUploadTests: XCTestCase {
// override func setUpWithError() throws {
// try super.setUpWithError()
//
// continueAfterFailure = false
//
// let app = XCUIApplication()
// app.launchArguments = ["--showOnboarding"]
// app.deleteAndLaunch(withSpringboardAppName: "PAWS")
// }
//
//
// func testHealthKitMockUpload() throws {
// let app = XCUIApplication()
//
//// try app.conductOnboardingIfNeeded()
//
// try navigateToMockUpload()
// try assertObservationCellPresent(false)
//
// app.terminate()
//
// try exitAppAndOpenHealth(.steps)
//
// app.activate()
//
//// try navigateToMockUpload()
// try assertObservationCellPresent(true, pressIfPresent: true)
// try assertObservationCellPresent(true, pressIfPresent: false)
// }
//
//
// private func navigateToMockUpload() throws {
// let app = XCUIApplication()
//
//// XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Mock Upload"].waitForExistence(timeout: 0.5))
//// app.tabBars["Tab Bar"].buttons["Mock Upload"].tap()
// }
//
// private func assertObservationCellPresent(_ shouldBePresent: Bool, pressIfPresent: Bool = true) throws {
// let app = XCUIApplication()
//
// let observationText = "/Observation/"
// let predicate = NSPredicate(format: "label CONTAINS[c] %@", observationText)
//
// if shouldBePresent {
// XCTAssertTrue(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5))
// if pressIfPresent {
// app.staticTexts.containing(predicate).firstMatch.tap()
// }
// } else {
// XCTAssertFalse(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5))
// }
// }
// }
// This source file is part of the CS342 2023 PAWS Team Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

import XCTest
import XCTestExtensions
import XCTHealthKit


class HealthKitUploadTests: XCTestCase {
override func setUpWithError() throws {
try super.setUpWithError()

continueAfterFailure = false

let app = XCUIApplication()
app.launchArguments = ["--showOnboarding"]
app.deleteAndLaunch(withSpringboardAppName: "PAWS")
}


func testHealthKitMockUpload() throws {
let app = XCUIApplication()

try app.conductOnboardingIfNeeded()

try app.navigateToMockUpload()
try app.assertObservationCellPresent(false)

try exitAppAndOpenHealth(.electrocardiograms)

app.activate()

try app.navigateToMockUpload()
try app.assertObservationCellPresent(true, pressIfPresent: true)
try app.assertObservationCellPresent(true, pressIfPresent: false)
}
}

extension XCUIApplication {
fileprivate func navigateToMockUpload() throws {
XCTAssertTrue(tabBars["Tab Bar"].buttons["Mock Upload"].waitForExistence(timeout: 0.5))
tabBars["Tab Bar"].buttons["Mock Upload"].tap()
}

fileprivate func assertObservationCellPresent(_ shouldBePresent: Bool, pressIfPresent: Bool = true) throws {
let observationText = "/Observation/"
let predicate = NSPredicate(format: "label CONTAINS[c] %@", observationText)

if shouldBePresent {
XCTAssertTrue(staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5))
if pressIfPresent {
staticTexts.containing(predicate).firstMatch.tap()
}
} else {
XCTAssertFalse(staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5))
}
}
}

This file was deleted.

Loading

0 comments on commit 5091cdb

Please sign in to comment.