Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide previous and next button #2397

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class QuestionnaireFragment : Fragment() {
reviewModeEditButton.visibility = View.GONE

if (displayMode.pagination.isPaginated) {
paginationPreviousButton.visibility = View.VISIBLE
paginationPreviousButton.isEnabled = displayMode.pagination.hasPreviousPage
paginationPreviousButton.visibility =
if (displayMode.pagination.hasPreviousPage) View.VISIBLE else View.GONE
paginationNextButton.visibility =
if (displayMode.pagination.hasNextPage) View.VISIBLE else View.GONE
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Google LLC
* Copyright 2022-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -139,6 +139,153 @@ class QuestionnaireFragmentTest {
.isEqualTo(View.VISIBLE)
}

@Test
fun `should hide next button on last page`() {
val questionnaireJson =
"""{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "1.1",
"type": "display",
"text": "Item 1"
}
]
},
{
"linkId": "2",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "2.1",
"type": "display",
"text": "Item 2"
}
]
}
]
}
"""
val scenario =
launchFragmentInContainer<QuestionnaireFragment>(
bundleOf(
EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJson,
),
)
scenario.moveToState(Lifecycle.State.RESUMED)
val view = scenario.withFragment { requireView() }
view.findViewById<Button>(R.id.pagination_next_button).performClick()
assertThat(view.findViewById<Button>(R.id.pagination_next_button).visibility)
.isEqualTo(View.GONE)
}

@Test
fun `should hide previous button on first page`() {
val questionnaireJson =
"""{
"resourceType": "Questionnaire",
"item": [
{
"linkId": "1",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "1.1",
"type": "display",
"text": "Item 1"
}
]
},
{
"linkId": "2",
"type": "group",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/questionnaire-item-control",
"code": "page",
"display": "Page"
}
],
"text": "Page"
}
}
],
"item": [
{
"linkId": "2.1",
"type": "display",
"text": "Item 2"
}
]
}
]
}
"""
val scenario =
launchFragmentInContainer<QuestionnaireFragment>(
bundleOf(
EXTRA_QUESTIONNAIRE_JSON_STRING to questionnaireJson,
),
)
scenario.moveToState(Lifecycle.State.RESUMED)
val view = scenario.withFragment { requireView() }
assertThat(view.findViewById<Button>(R.id.pagination_previous_button).visibility)
.isEqualTo(View.GONE)
}

@Test
fun `questionnaireItemViewHolderFactoryMatchersProvider should have custom QuestionnaireItemViewHolderFactoryMatchers `() {
ApplicationProvider.getApplicationContext<DataCaptureTestApplication>()
Expand Down
Loading