This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Issue #10363 - Handle authentication of the credit card selection for a prompt request #10369
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ import mozilla.components.concept.engine.prompt.PromptRequest | |
import mozilla.components.support.test.mock | ||
import mozilla.components.support.test.whenever | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNull | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
@@ -46,7 +47,9 @@ class CreditCardPickerTest { | |
) | ||
|
||
var manageCreditCardsCalled = false | ||
var selectCreditCardCalled = false | ||
private val manageCreditCardsCallback: () -> Unit = { manageCreditCardsCalled = true } | ||
private val selectCreditCardCallback: () -> Unit = { selectCreditCardCalled = true } | ||
|
||
@Before | ||
fun setup() { | ||
|
@@ -56,21 +59,25 @@ class CreditCardPickerTest { | |
creditCardPicker = CreditCardPicker( | ||
store = store, | ||
creditCardSelectBar = creditCardSelectBar, | ||
manageCreditCardsCallback = manageCreditCardsCallback | ||
manageCreditCardsCallback = manageCreditCardsCallback, | ||
selectCreditCardCallback = selectCreditCardCallback | ||
) | ||
|
||
whenever(store.state).thenReturn(state) | ||
} | ||
|
||
@Test | ||
fun `WHEN onOptionSelect is called with a credit card THEN the confirmed credit card is received and prompt is hidden`() { | ||
fun `WHEN onOptionSelect is called with a credit card THEN selectCreditCardCallback is invoked and prompt is hidden`() { | ||
assertNull(creditCardPicker.selectedCreditCard) | ||
|
||
setupSessionState(promptRequest) | ||
|
||
creditCardPicker.onOptionSelect(creditCard) | ||
|
||
verify(creditCardSelectBar).hidePrompt() | ||
|
||
assertEquals(creditCard, confirmedCreditCard) | ||
assertTrue(selectCreditCardCalled) | ||
assertEquals(creditCard, creditCardPicker.selectedCreditCard) | ||
} | ||
|
||
@Test | ||
|
@@ -105,6 +112,32 @@ class CreditCardPickerTest { | |
verify(creditCardSelectBar).showPrompt(promptRequest.creditCards) | ||
} | ||
|
||
@Test | ||
fun `GIVEN a selected credit card WHEN onAuthSuccess is called THEN the confirmed credit card is received`() { | ||
assertNull(creditCardPicker.selectedCreditCard) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also confirm the prompt request was consume and confirmed? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do that by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the clarification, as this value is shared for multiple tests, could be reset it on |
||
|
||
setupSessionState(promptRequest) | ||
|
||
creditCardPicker.onOptionSelect(creditCard) | ||
creditCardPicker.onAuthSuccess() | ||
|
||
assertEquals(creditCard, confirmedCreditCard) | ||
assertNull(creditCardPicker.selectedCreditCard) | ||
gabrielluong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Test | ||
fun `GIVEN a selected credit card WHEN onAuthFailure is called THEN the prompt request is dismissed`() { | ||
assertNull(creditCardPicker.selectedCreditCard) | ||
|
||
setupSessionState(promptRequest) | ||
|
||
creditCardPicker.onOptionSelect(creditCard) | ||
creditCardPicker.onAuthFailure() | ||
|
||
assertNull(creditCardPicker.selectedCreditCard) | ||
assertTrue(onDismissCalled) | ||
} | ||
|
||
private fun setupSessionState(request: PromptRequest? = null): TabSessionState { | ||
val promptRequest: PromptRequest = request ?: mock() | ||
val content: ContentState = mock() | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit on naming: we're sort of lock ourselves into the idea that we always want biometrics for confirmation.
This isn't worth fixing at this point though.