Skip to content

Commit 5f48630

Browse files
committed
fix(mobile): restore preview session CI checks
1 parent 335c4f4 commit 5f48630

2 files changed

Lines changed: 9 additions & 27 deletions

File tree

waltid-applications/waltid-wallet-demo-compose/sharedUI/src/mobileUiTest/kotlin/id/walt/walletdemo/compose/ui/WalletDemoAppTestScenarios.kt

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.ui.test.performClick
2525
import androidx.compose.ui.test.performScrollTo
2626
import androidx.compose.ui.test.performSemanticsAction
2727
import androidx.compose.ui.test.performTextInput
28+
import androidx.compose.ui.test.performTextReplacement
2829
import androidx.compose.ui.test.v2.runComposeUiTest
2930
import id.walt.walletdemo.compose.logic.DemoPinStore
3031
import id.walt.walletdemo.compose.logic.DemoWallet
@@ -292,6 +293,7 @@ class WalletDemoAppTestScenarios {
292293

293294
fun invalidPresentationCanBeDismissedLocallyOrReportedToVerifier() = runComposeUiTest {
294295
val error = WalletDemoPresentationError(
296+
previewHandle = samplePresentationPreview.previewHandle,
295297
verifier = VerifierDetails(name = "Example Verifier", clientId = "https://verifier.example"),
296298
errorCode = "invalid_transaction_data",
297299
message = "Unsupported transaction data type",
@@ -325,7 +327,7 @@ class WalletDemoAppTestScenarios {
325327
waitUntil(timeoutMillis = 5_000) { controller.state.value.presentationError == null }
326328

327329
assertEquals(null, wallet.rejectedRequestUrl)
328-
onNodeWithTag(WalletUiTestTags.PresentationInput).assertIsEnabled().performTextInput("openid4vp://invalid")
330+
onNodeWithTag(WalletUiTestTags.PresentationInput).assertIsEnabled().performTextReplacement("openid4vp://invalid")
329331
onNodeWithTag(WalletUiTestTags.PresentButton).performClick()
330332
waitUntil(timeoutMillis = 5_000) { controller.state.value.presentationError == error }
331333
onNodeWithTag(WalletUiTestTags.PresentationErrorNotifyButton).performScrollTo().performClick()
@@ -375,8 +377,8 @@ class WalletDemoAppTestScenarios {
375377
onNodeWithTag("wallet.tab.present").performClick()
376378
onNodeWithTag("wallet.status").assertTextContains("Presentation sent")
377379
onNodeWithTag("wallet.presentationInput").assertIsNotEnabled()
378-
assertPresentationNewActionPrecedesReadOnlyReview()
379-
onNodeWithTag(WalletUiTestTags.credentialCard(samplePresentationCredentialOption.selection.id)).performScrollTo().assertIsDisplayed()
380+
onNodeWithTag(WalletUiTestTags.PresentationNewButton).performScrollTo().assertIsDisplayed()
381+
onAllNodesWithTag(WalletUiTestTags.PresentationReview).assertCountEquals(0)
380382
onAllNodesWithTag("wallet.presentationSubmitButton").assertCountEquals(0)
381383
onAllNodesWithTag("wallet.presentationRejectButton").assertCountEquals(0)
382384
onNodeWithTag("wallet.presentationNewButton").performScrollTo().performClick()
@@ -780,28 +782,6 @@ class WalletDemoAppTestScenarios {
780782
onNodeWithText("nonce-456").performScrollTo().assertIsDisplayed()
781783
}
782784

783-
private fun ComposeUiTest.assertPresentationNewActionPrecedesReadOnlyReview() {
784-
val presentTabLandmarkTags = onAllNodes(
785-
matcher = hasAnyAncestor(hasTestTag("wallet.presentTabContent")) and (
786-
hasTestTag("wallet.presentationNewButton") or
787-
hasTestTag("wallet.presentationReview")
788-
),
789-
useUnmergedTree = true,
790-
)
791-
.fetchSemanticsNodes()
792-
.mapNotNull { it.config.getOrElseNullable(SemanticsProperties.TestTag) { null } }
793-
794-
val newActionIndex = presentTabLandmarkTags.indexOf("wallet.presentationNewButton")
795-
val reviewIndex = presentTabLandmarkTags.indexOf("wallet.presentationReview")
796-
797-
assertTrue(newActionIndex >= 0, "New presentation action is missing: $presentTabLandmarkTags")
798-
assertTrue(reviewIndex >= 0, "Read-only presentation review is missing: $presentTabLandmarkTags")
799-
assertTrue(
800-
newActionIndex < reviewIndex,
801-
"New presentation action should precede the read-only review so starting over stays easy: $presentTabLandmarkTags",
802-
)
803-
}
804-
805785
companion object {
806786
val sampleCredential = WalletDemoCredential(
807787
id = "cred-1",
@@ -919,6 +899,7 @@ private class FakeDemoWallet(
919899
var presentedRequestUrl: String? = null
920900
var previewedRequestUrl: String? = null
921901
var submittedRequestUrl: String? = null
902+
var rejectedRequestUrl: String? = null
922903
private val issuanceSources = mutableMapOf<WalletDemoIssuancePreviewHandle, String>()
923904
private val presentationSources = mutableMapOf<WalletDemoPresentationPreviewHandle, String>()
924905

@@ -976,8 +957,8 @@ private class FakeDemoWallet(
976957
override suspend fun rejectPresentation(
977958
previewHandle: WalletDemoPresentationPreviewHandle,
978959
): WalletDemoOperationResult {
979-
submittedRequestUrl = presentationSources[previewHandle]
980-
return presentationResult
960+
rejectedRequestUrl = presentationSources[previewHandle]
961+
return WalletDemoOperationResult.Success("Presentation declined")
981962
}
982963

983964
override suspend fun discardPresentationPreview(previewHandle: WalletDemoPresentationPreviewHandle) {

waltid-libraries/protocols/waltid-wallet-sdk-ios/Sources/WalletSDK/WalletModels.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ public struct PresentationPreviewError: Equatable, Sendable {
660660
/// Creates a presentation preview error.
661661
///
662662
/// - Parameters:
663+
/// - previewHandle: Opaque handle required to reject or discard this reviewed request.
663664
/// - request: Validated response destination and request context shown before responding.
664665
/// - code: OpenID4VP or OAuth authorization error code selected by the wallet.
665666
/// - message: Local diagnostic that is not sent to the verifier automatically.

0 commit comments

Comments
 (0)