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

[πŸ†•] Manage pledge menu #588

Merged
merged 5 commits into from Aug 16, 2019
Merged

[πŸ†•] Manage pledge menu #588

merged 5 commits into from Aug 16, 2019

Conversation

eoji
Copy link
Contributor

@eoji eoji commented Aug 14, 2019

πŸ“² What

Showing an interstitial screen with menu options when the pledge sheet is expanded and the user has backed the project.

πŸ€” Why

MANAGE UR PLEDGE

πŸ›  How

  • ProjectActivity displays BackingFragment as the primary screen when the pledge sheet is opened.
    • When it's visible, an options menu is present in the rewards toolbar.
    • The menu has options for Update pledge, Change payment method, View rewards, Cancel pledge and Contact creator
  • Added PledgeReason that will be used to configure PledgeFragment UI
  • PledgeData.screenLocation is now optional.
  • PledgeFragment hides mini reward if no ScreenLocation.
  • Renamed RewardFragment to RewardsFragment.
  • Renamed RewardFragmentViewModel to RewardsFragmentViewModel.
  • Testz

πŸ‘€ See

Menu❓ Update pledge Change payment method
update payment
View rewards Cancel Pledge Contact creator
viewrewards cancelpledge contact

πŸ“‹ QA

1️⃣When a user has backed a live project, clicking Manage reveals the Manage Your Pledge screen (it's blank for now) with an options menu.
2️⃣ The menu contains Update pledge, Change payment method, View rewards, Cancel pledge and Contact creator.
3️⃣ Update pledge -> Pledge screen (not currently configured)
4️⃣ Change payment method -> Pledge screen (not currently configured)
5️⃣ View rewards -> Rewards screen (scrolled to current reward)
6️⃣ Cancel pledge -> Cancel modal (needs new UI)
7️⃣ Contact creator -> Conversation with creator

Story πŸ“–

https://dripsprint.atlassian.net/browse/NT-108

… the pledge sheet is opened.

  - When it's visible, an options menu is present in the rewards toolbar.
  - The menu has options for Update pledge, Change payment method, View rewards, Cancel pledge and Contact creator
- Added PledgeReason that will be used to configure PledgeFragment UI
- PledgeData.screenLocation is now optional.
- PledgeFragment hides mini reward if no ScreenLocation.
- Renamed RewardFragment to RewardsFragment.
- Renamed RewardFragmentViewModel to RewardsFragmentViewModel.
- Testz
}
}

private fun renderProject(backingFragment: BackingFragment, rewardsFragment: RewardsFragment, project: Project) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when we have two methods with the same name? I see that we have another renderProject above with a different function signature. Is it able to detect which one to invoke based on the arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I was considering naming it renderProjectInFragments but it's kinda long and redundant.

Copy link

@roblum roblum Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm still learning how the files in this codebase are structured and what the purpose of each of these functions are. It looks like the one above renders an action button for the project? Could it be something like renderProjectActionButton or is that too specific? (disregard if I misunderstood)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh it's doing more than that. It's loading the project into the ProjectAdapter, loading the old style rewards if the native checkout flag is off, and configuring the button

}

@Test
fun testManagePledgeMenuIsVisible_whenProjectNotBacked() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding Not to this test name testManagePledgeMenuIsNotVisible_whenProjectNotBacked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to structure tests like test[output]_when[condition]. Does that make sense? Nino and I have been flopping around about it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both make a lot of sense. Personally when I read tests that I'm unfamiliar with, I appreciate being able to get as much context from it without having to read through the whole test body. It saves me some time and allows me to jump back to the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we've been discussing ways to make the tests more readable for people that are unfamiliar with the codebase. The pattern @eoji mentioned above is used on iOS too. Once you get into inputs/outputs it will make more sense, but maybe a discussion about it would be worth it.

Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @eoji . I left a some comments and questions.

interface Outputs {
/** Emits the current project. */
fun project(): Observable<Project>
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is project being sent through input and being emitted as an output without any logic applied to it? Is this for tests purposes? πŸ€”

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just for tests. The designs for this screen aren't done so I just left it blank for now.

@@ -339,21 +351,21 @@ class ProjectViewModelTest : KSRobolectricTestCase() {
}

@Test
fun testHideRewardsFragment() {
fun testExpandPledgeSheet_whenHiding() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be renamed to testExpandPledgeSheet_whenHidingFragment just to be more explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with testExpandPledgeSheet_whenCollapsingSheet

}

@Test
fun testShowRewardsFragment() {
fun testExpandPledgeSheet_whenShowing() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with testExpandPledgeSheet_whenExpandingSheet

@@ -435,13 +447,18 @@ class ProjectViewModelTest : KSRobolectricTestCase() {
}

@Test
fun testScrimIsVisible() {
fun testScrimIsVisible_whenNativeCheckoutDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test the scrimIsVisible when native checkout is enabled as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's what happens in the next 2 tests

@Test
fun testScrimIsVisible_whenNotBackedProject() {
        setUpEnvironment(environmentWithNativeCheckoutEnabled())
@Test
fun testScrimIsVisible_whenBackedProject() {
        setUpEnvironment(environmentWithNativeCheckoutEnabled())

should I rename them?

Copy link
Contributor

@Scollaco Scollaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! (There's a alpha off due a renaming, but aside that it looks good) πŸ˜„

@@ -47,7 +53,7 @@ interface ProjectViewModel {
fun heartButtonClicked()

/** Call when horizontal rewards sheet should hide. */
fun hideRewardsSheetClicked()
fun collapsePledgeSheet()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now the alpha is off lol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL

@eoji eoji merged commit 72d9624 into master Aug 16, 2019
@eoji eoji deleted the manage-pledge-menu branch August 16, 2019 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants