Skip to content

Commit

Permalink
added selfie capture screen ui and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jumaallan committed Sep 19, 2024
1 parent 3aa7882 commit 18d2ede
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.smileidentity.compose.document
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import com.smileidentity.compose.components.LocalMetadata
import com.smileidentity.models.JobType
import com.smileidentity.util.randomUserId
import com.smileidentity.viewmodel.document.DocumentVerificationViewModel
Expand All @@ -29,6 +30,7 @@ class OrchestratedDocumentVerificationScreenTest {
countryCode = "254",
documentType = "NATIONAL_ID",
captureBothSides = false,
metadata = LocalMetadata.current

Check failure on line 33 in lib/src/androidTest/java/com/smileidentity/compose/document/OrchestratedDocumentVerificationScreenTest.kt

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma before ")"
),
)
}
Expand All @@ -53,6 +55,7 @@ class OrchestratedDocumentVerificationScreenTest {
countryCode = "254",
documentType = "NATIONAL_ID",
captureBothSides = false,
metadata = LocalMetadata.current

Check failure on line 58 in lib/src/androidTest/java/com/smileidentity/compose/document/OrchestratedDocumentVerificationScreenTest.kt

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma before ")"
),
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.smileidentity.compose.selfie.v3

import android.Manifest
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.rule.GrantPermissionRule
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionState
import com.google.accompanist.permissions.rememberPermissionState
import com.smileidentity.compose.grantPermissionInDialog
import org.junit.Rule
import org.junit.Test

class SelfieCaptureScreenV3Test {
@get:Rule
val composeTestRule = createComposeRule()

@get:Rule
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
Manifest.permission.CAMERA,
Manifest.permission.POST_NOTIFICATIONS,
)

@OptIn(ExperimentalPermissionsApi::class)
private lateinit var permissionState: PermissionState

@OptIn(ExperimentalPermissionsApi::class)
@Test
fun shouldShowInstructions() {
// given
val instructionsSubstring =
"Position your head in the camera view. Then move in the direction that is indicated"

// when
composeTestRule.setContent {
permissionState = rememberPermissionState(Manifest.permission.CAMERA)
SelfieCaptureScreenV3()
}

grantPermissionInDialog()

// then
composeTestRule.onNodeWithText(instructionsSubstring, substring = true).assertIsDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
Expand All @@ -13,15 +14,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.smileidentity.R
import com.smileidentity.compose.components.LoadingButton
import com.smileidentity.compose.components.LottieInstruction
import com.smileidentity.compose.components.SmileIDAttribution

@Composable
fun SelfieCaptureScreenV3(
modifier: Modifier = Modifier,
) {
fun SelfieCaptureScreenV3(modifier: Modifier = Modifier) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -31,13 +32,19 @@ fun SelfieCaptureScreenV3(
.verticalScroll(rememberScrollState())
.padding(16.dp),
) {
LottieInstruction(
modifier = Modifier.size(200.dp),
)
Text(
text = stringResource(R.string.si_smart_selfie_v3_instructions),
style = MaterialTheme.typography.titleLarge,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(top = 16.dp),
modifier = Modifier.padding(24.dp),
)
LoadingButton(
buttonText = stringResource(R.string.si_smart_selfie_v3_get_started),
onClick = {},
)
SmileIDAttribution()
}
}

1 change: 1 addition & 0 deletions lib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<string name="si_smart_selfie_v2_submission_failed">Submission Failed</string>

<!-- SmartSelfie V2 -->
<string name="si_smart_selfie_v3_get_started">Get Started</string>
<string name="si_smart_selfie_v3_instructions">Position your head in the camera view. Then move in the direction that is indicated</string>

<!-- Document Verification -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SelfieCaptureScreenV3Test {
@Test
fun testInstructionsScreen() {
paparazzi.snapshot {
SelfieCaptureScreenV3(userId = "")
SelfieCaptureScreenV3()
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18d2ede

Please sign in to comment.