forked from stripe/stripe-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add screenshot tests for add screens. (stripe#9167)
- Loading branch information
1 parent
504a714
commit 1f2f3a5
Showing
19 changed files
with
263 additions
and
123 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
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
18 changes: 0 additions & 18 deletions
18
...rc/test/java/com/stripe/android/paymentsheet/navigation/FakeAddPaymentMethodInteractor.kt
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...ndroid/paymentsheet/navigation/PaymentSheetScreenAddAnotherPaymentMethodScreenshotTest.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,58 @@ | ||
package com.stripe.android.paymentsheet.navigation | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.stripe.android.core.strings.resolvableString | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory | ||
import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen.AddAnotherPaymentMethod | ||
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor | ||
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor.Companion.createState | ||
import com.stripe.android.paymentsheet.ui.PaymentSheetFlowType | ||
import com.stripe.android.paymentsheet.ui.PaymentSheetScreen | ||
import com.stripe.android.paymentsheet.utils.ViewModelStoreOwnerContext | ||
import com.stripe.android.paymentsheet.viewmodels.FakeBaseSheetViewModel | ||
import com.stripe.android.screenshottesting.PaparazziRule | ||
import com.stripe.android.testing.CoroutineTestRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class PaymentSheetScreenAddAnotherPaymentMethodScreenshotTest { | ||
@get:Rule | ||
val paparazziRule = PaparazziRule( | ||
boxModifier = Modifier | ||
.padding(16.dp) | ||
) | ||
|
||
@get:Rule | ||
val coroutineRule = CoroutineTestRule() | ||
|
||
@Test | ||
fun displaysCard() { | ||
val metadata = PaymentMethodMetadataFactory.create() | ||
val interactor = FakeAddPaymentMethodInteractor(initialState = createState()) | ||
val initialScreen = AddAnotherPaymentMethod(interactor) | ||
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen) | ||
|
||
paparazziRule.snapshot { | ||
ViewModelStoreOwnerContext { | ||
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun displaysError() { | ||
val metadata = PaymentMethodMetadataFactory.create() | ||
val interactor = FakeAddPaymentMethodInteractor(initialState = createState()) | ||
val initialScreen = AddAnotherPaymentMethod(interactor) | ||
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen) | ||
viewModel.onError("An error occurred.".resolvableString) | ||
|
||
paparazziRule.snapshot { | ||
ViewModelStoreOwnerContext { | ||
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete) | ||
} | ||
} | ||
} | ||
} |
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
58 changes: 58 additions & 0 deletions
58
.../android/paymentsheet/navigation/PaymentSheetScreenAddFirstPaymentMethodScreenshotTest.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,58 @@ | ||
package com.stripe.android.paymentsheet.navigation | ||
|
||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.stripe.android.core.strings.resolvableString | ||
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory | ||
import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen.AddFirstPaymentMethod | ||
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor | ||
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor.Companion.createState | ||
import com.stripe.android.paymentsheet.ui.PaymentSheetFlowType | ||
import com.stripe.android.paymentsheet.ui.PaymentSheetScreen | ||
import com.stripe.android.paymentsheet.utils.ViewModelStoreOwnerContext | ||
import com.stripe.android.paymentsheet.viewmodels.FakeBaseSheetViewModel | ||
import com.stripe.android.screenshottesting.PaparazziRule | ||
import com.stripe.android.testing.CoroutineTestRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class PaymentSheetScreenAddFirstPaymentMethodScreenshotTest { | ||
@get:Rule | ||
val paparazziRule = PaparazziRule( | ||
boxModifier = Modifier | ||
.padding(16.dp) | ||
) | ||
|
||
@get:Rule | ||
val coroutineRule = CoroutineTestRule() | ||
|
||
@Test | ||
fun displaysCard() { | ||
val metadata = PaymentMethodMetadataFactory.create() | ||
val interactor = FakeAddPaymentMethodInteractor(initialState = createState()) | ||
val initialScreen = AddFirstPaymentMethod(interactor) | ||
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen) | ||
|
||
paparazziRule.snapshot { | ||
ViewModelStoreOwnerContext { | ||
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun displaysError() { | ||
val metadata = PaymentMethodMetadataFactory.create() | ||
val interactor = FakeAddPaymentMethodInteractor(initialState = createState()) | ||
val initialScreen = AddFirstPaymentMethod(interactor) | ||
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen) | ||
viewModel.onError("An error occurred.".resolvableString) | ||
|
||
paparazziRule.snapshot { | ||
ViewModelStoreOwnerContext { | ||
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.