-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# *Heart Health* ## ⚙️ Release Notes **New Heart Health Data Page:** Consists of 4 subpages: - Symptoms - Heart Rate - Blood Pressure - Weight **Each subpage includes:** - A chart for data visualization - A table displaying detailed data - Filtering options to refine data display **New Repository:** - A new repository has been created for data retrieval, ensuring efficient and seamless access to the necessary data for visualization. ## ✅ Testing as soon as the basic structure has been checked, further tests are added ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --------- Signed-off-by: Basler182 <[email protected]> Co-authored-by: Eldi Cano <[email protected]>
- Loading branch information
Showing
63 changed files
with
3,702 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
app/src/androidTest/kotlin/edu/stanford/bdh/engagehf/health/HealthPageTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
package edu.stanford.bdh.engagehf.health | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.health.connect.client.records.WeightRecord | ||
import androidx.health.connect.client.units.Mass | ||
import edu.stanford.bdh.engagehf.simulator.HealthPageSimulator | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import java.time.ZonedDateTime | ||
|
||
class HealthPageTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun `test health page root is displayed`() { | ||
// given | ||
setState(state = getSuccessState()) | ||
|
||
// then | ||
healthPage { | ||
assertIsDisplayed() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page error message is displayed`() { | ||
// given | ||
val message = "Error message" | ||
|
||
// when | ||
setState(state = HealthUiState.Error(message)) | ||
|
||
// then | ||
healthPage { | ||
assertErrorMessage(message) | ||
assertCenteredContent() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page no data message is displayed`() { | ||
// given | ||
val message = "No data available" | ||
|
||
// when | ||
setState(state = HealthUiState.NoData(message)) | ||
|
||
// then | ||
healthPage { | ||
assertNoDataMessage(message) | ||
assertCenteredContent() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health chart is displayed`() { | ||
// given | ||
setState(state = getSuccessState()) | ||
|
||
// then | ||
healthPage { | ||
assertHealthChartIsDisplayed() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health header is displayed`() { | ||
// given | ||
setState(state = getSuccessState()) | ||
// then | ||
healthPage { | ||
assertHealthHeaderIsDisplayed() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health progress indicator is displayed`() { | ||
// given | ||
setState(state = HealthUiState.Loading) | ||
// then | ||
healthPage { | ||
assertHealthProgressIndicatorIsDisplayed() | ||
assertCenteredContent() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health history table is displayed`() { | ||
// given | ||
val entryId = "entry-id" | ||
|
||
// when | ||
setState(state = getSuccessState(entryId = entryId)) | ||
|
||
// then | ||
healthPage { | ||
assertHistoryTableItemDisplayed(id = entryId) | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health history text is displayed`() { | ||
// given | ||
setState(state = getSuccessState()) | ||
// then | ||
healthPage { | ||
assertHealthHistoryTextIsDisplayed() | ||
} | ||
} | ||
|
||
@Test | ||
fun `test health page health history text is displayed with text`() { | ||
// given | ||
setState(state = getSuccessState()) | ||
// then | ||
healthPage { | ||
assertHealthHistoryText("History") | ||
} | ||
} | ||
|
||
private fun setState(state: HealthUiState) { | ||
composeTestRule.setContent { | ||
HealthPage(uiState = state, onAction = {}) | ||
} | ||
} | ||
|
||
private fun healthPage(block: HealthPageSimulator.() -> Unit) { | ||
HealthPageSimulator(composeTestRule).apply(block) | ||
} | ||
|
||
private fun getSuccessState(entryId: String? = null): HealthUiState { | ||
return HealthUiState.Success( | ||
data = HealthUiData( | ||
infoRowData = InfoRowData( | ||
selectedTimeRange = TimeRange.MONTHLY, | ||
formattedValue = "70.0 kg", | ||
formattedDate = "Jan 2022", | ||
isSelectedTimeRangeDropdownExpanded = false | ||
), | ||
records = listOf( | ||
WeightRecord( | ||
time = ZonedDateTime.now().toInstant(), | ||
zoneOffset = ZonedDateTime.now().offset, | ||
weight = @Suppress("MagicNumber") Mass.pounds(154.0) | ||
) | ||
), | ||
tableData = listOf( | ||
TableEntryData( | ||
value = 70.0f, | ||
formattedValues = "70.0 kg", | ||
date = ZonedDateTime.now(), | ||
formattedDate = "Jan 2022", | ||
trend = 0f, | ||
formattedTrend = "0.0 kg", | ||
secondValue = null, | ||
id = entryId | ||
) | ||
) | ||
) | ||
) | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
app/src/androidTest/kotlin/edu/stanford/bdh/engagehf/simulator/HealthPageSimulator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package edu.stanford.bdh.engagehf.simulator | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertTextEquals | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import edu.stanford.bdh.engagehf.health.HealthPageTestIdentifier | ||
import edu.stanford.spezi.core.testing.onNodeWithIdentifier | ||
|
||
class HealthPageSimulator( | ||
private val composeTestRule: ComposeTestRule, | ||
) { | ||
private val root = composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.ROOT) | ||
|
||
private val centeredContent = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.CENTERED_CONTENT) | ||
|
||
private val errorMessage = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.ERROR_MESSAGE) | ||
|
||
private val noDataMessage = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.NO_DATA_MESSAGE) | ||
|
||
private val healthChart = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.HEALTH_CHART) | ||
|
||
private val healthHeader = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.HEALTH_HEADER) | ||
|
||
private val healthProgressIndicator = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.PROGRESS_INDICATOR) | ||
|
||
private val healthHistoryText = | ||
composeTestRule.onNodeWithIdentifier(HealthPageTestIdentifier.HEALTH_HISTORY_TEXT) | ||
|
||
fun assertIsDisplayed() { | ||
root.assertIsDisplayed() | ||
} | ||
|
||
fun assertErrorMessage(text: String) { | ||
errorMessage.assertIsDisplayed().assertTextEquals(text) | ||
} | ||
|
||
fun assertNoDataMessage(text: String) { | ||
noDataMessage.assertIsDisplayed().assertTextEquals(text) | ||
} | ||
|
||
fun assertCenteredContent() { | ||
centeredContent.assertIsDisplayed() | ||
} | ||
|
||
fun assertHealthChartIsDisplayed() { | ||
healthChart.assertIsDisplayed() | ||
} | ||
|
||
fun assertHealthHeaderIsDisplayed() { | ||
healthHeader.assertIsDisplayed() | ||
} | ||
|
||
fun assertHealthProgressIndicatorIsDisplayed() { | ||
healthProgressIndicator.assertIsDisplayed() | ||
} | ||
|
||
fun assertHistoryTableItemDisplayed(id: String) { | ||
composeTestRule.onNodeWithIdentifier( | ||
HealthPageTestIdentifier.HEALTH_HISTORY_TABLE_ITEM, id) | ||
.assertIsDisplayed() | ||
} | ||
|
||
fun assertHealthHistoryTextIsDisplayed() { | ||
healthHistoryText.assertIsDisplayed() | ||
} | ||
|
||
fun assertHealthHistoryText(text: String) { | ||
healthHistoryText.assertIsDisplayed().assertTextEquals(text) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rements/MeasurementToObservationMapper.kt → ...rements/MeasurementToObservationMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.