Skip to content

Commit

Permalink
[NT-514] "View your rewards" creator CTA (#939)
Browse files Browse the repository at this point in the history
* Strings

* Adding viewYourRewards cta state

* VM tests

* “You launched this project on” translations

* Screenshots updated for translations

* Formatting

* Tracking event test
  • Loading branch information
Isabel Barrera authored Nov 12, 2019
1 parent 3409c87 commit 680f982
Show file tree
Hide file tree
Showing 37 changed files with 100 additions and 12 deletions.
1 change: 1 addition & 0 deletions Kickstarter-iOS/Locales/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"View_rewards" = "View rewards";
"View_your_pledge" = "View your pledge";
"View_your_reward" = "View your reward";
"View_your_rewards" = "View your rewards";
"Watch_live" = "Watch live";
"We_couldnt_find_anything_for_search_term" = "We couldn't find anything for “%{search_term}”.";
"We_couldnt_process_your_pledge" = "We couldn't process your pledge.";
Expand Down
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"View_rewards" = "Belohnungen ansehen";
"View_your_pledge" = "Deinen Finanzierungsbeitrag ansehen";
"View_your_reward" = "Belohnung ansehen";
"View_your_rewards" = "Deine Belohnungen ansehen";
"Watch_live" = "Live ansehen";
"We_couldnt_find_anything_for_search_term" = "Es wurden keine Ergebnisse für die Suche \"%{search_term}\" gefunden.";
"We_couldnt_process_your_pledge" = "Dein Finanzierungsbeitrag konnte nicht bearbeitet werden.";
Expand Down Expand Up @@ -566,7 +567,7 @@
"You_backed_this_project" = "Du hast dieses Projekt unterstützt.";
"You_cant_use_this_credit_card_to_back_a_project_from_project_country" = "Diese Karte kann nicht verwendet werden, um ein Projekt aus dem folgenden Land zu unterstützen: %{project_country}.";
"You_have_successfully_backed_project_html" = "Dank deiner Unterstützung ist <b>%{project_name}</b> seiner Verwirklichung einen Schritt näher. Sag es weiter!";
"You_launched_this_project_on_launch_date" = "You launched this project on %{launch_date}.";
"You_launched_this_project_on_launch_date" = "Du hast dieses Projekt am %{launch_date} veröffentlicht.";
"You_need_to_pledge_at_least_reward_minimum_for_this_reward" = "Diese Belohnung hat einen Mindestfinanzierungsbeitrag von %{reward_minimum}.";
"You_pledged_on_date" = "<b>Finanzierungsbeitrag geleistet</b> im %{pledge_date}";
"You_pledged_without_a_reward" = "Unterstützt ohne Belohnung";
Expand Down
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"View_rewards" = "Ver recompensas";
"View_your_pledge" = "Revisa tu contribución";
"View_your_reward" = "Mostrar recompensa";
"View_your_rewards" = "Ver tus recompensas";
"Watch_live" = "Ver en vivo";
"We_couldnt_find_anything_for_search_term" = "La búsqueda \"%{search_term}\" no dio resultados.";
"We_couldnt_process_your_pledge" = "No pudimos procesar tu contribución.";
Expand Down Expand Up @@ -566,7 +567,7 @@
"You_backed_this_project" = "Patrocinaste este proyecto.";
"You_cant_use_this_credit_card_to_back_a_project_from_project_country" = "No puedes usar esta tarjeta de crédito para patrocinar un proyecto de %{project_country}.";
"You_have_successfully_backed_project_html" = "Has patrocinado <b>%{project_name}</b> con éxito. Gracias a ti, este proyecto está ahora un paso más cerca de hacerse realidad. ¡Corre la voz!";
"You_launched_this_project_on_launch_date" = "You launched this project on %{launch_date}.";
"You_launched_this_project_on_launch_date" = "Publicaste el proyecto el: %{launch_date}.";
"You_need_to_pledge_at_least_reward_minimum_for_this_reward" = "Debes contribuir, al menos, %{reward_minimum} para obtener esta recompensa.";
"You_pledged_on_date" = "<b>Contribuiste</b> el %{pledge_date}";
"You_pledged_without_a_reward" = "Contribuiste sin recompensa";
Expand Down
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"View_rewards" = "Afficher les récompenses";
"View_your_pledge" = "Afficher mon engagement";
"View_your_reward" = "Afficher ma récompense";
"View_your_rewards" = "Afficher mes récompenses";
"Watch_live" = "Regarder en direct";
"We_couldnt_find_anything_for_search_term" = "Pas de résultats pour « %{search_term} ».";
"We_couldnt_process_your_pledge" = "Impossible de traiter votre engagement.";
Expand Down Expand Up @@ -566,7 +567,7 @@
"You_backed_this_project" = "Vous avez soutenu ce projet.";
"You_cant_use_this_credit_card_to_back_a_project_from_project_country" = "Impossible d'accepter cette carte pour soutenir un projet depuis le pays suivant : %{project_country}.";
"You_have_successfully_backed_project_html" = "Vous vous êtes engagé à soutenir le projet <b>%{project_name}</b>. Ce projet se rapproche tout doucement de son objectif grâce à vous. Parlez-en à votre entourage !";
"You_launched_this_project_on_launch_date" = "You launched this project on %{launch_date}.";
"You_launched_this_project_on_launch_date" = "Vous avez lancé ce projet le %{launch_date}.";
"You_need_to_pledge_at_least_reward_minimum_for_this_reward" = "Vous devez vous engager à hauteur de %{reward_minimum} ou plus pour sélectionner cette récompense.";
"You_pledged_on_date" = "<b>Votre engagement</b> du %{pledge_date}";
"You_pledged_without_a_reward" = "Engagement sans récompense";
Expand Down
3 changes: 2 additions & 1 deletion Kickstarter-iOS/Locales/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
"View_rewards" = "リワードを見る";
"View_your_pledge" = "プレッジをみる";
"View_your_reward" = "リワードをみる";
"View_your_rewards" = "View your rewards";
"Watch_live" = "ライブをみる";
"We_couldnt_find_anything_for_search_term" = "「%{search_term}」に一致するものがありませんでした。";
"We_couldnt_process_your_pledge" = "プレッジを処理できませんでした。";
Expand Down Expand Up @@ -567,7 +568,7 @@
"You_backed_this_project" = "バック済";
"You_cant_use_this_credit_card_to_back_a_project_from_project_country" = "%{project_country} のプロジェクトをバックするのにこのクレジットカードを利用することはできません。";
"You_have_successfully_backed_project_html" = "<b>%{project_name}</b>へのバックが完了しました。このプロジェクトは、成功に一歩近づきました!ありがとうございます。";
"You_launched_this_project_on_launch_date" = "You launched this project on %{launch_date}.";
"You_launched_this_project_on_launch_date" = "このプロジェクトを %{launch_date} にローンチしました。";
"You_need_to_pledge_at_least_reward_minimum_for_this_reward" = "このリワードには、最低%{reward_minimum}のプレッジが必要です。";
"You_pledged_on_date" = "%{pledge_date} に<b>プレッジ</b>";
"You_pledged_without_a_reward" = "リワードなしでプレッジしました";
Expand Down
2 changes: 2 additions & 0 deletions Library/Koala/Koala.swift
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ public final class Koala {
self.track(event: "View Your Pledge Button Clicked", properties: props)
case .viewRewards:
self.track(event: "View Rewards Button Clicked", properties: props)
case .viewYourRewards:
self.track(event: "View Your Rewards Button Clicked", properties: props)
}
}

Expand Down
16 changes: 16 additions & 0 deletions Library/Koala/KoalaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,22 @@ final class KoalaTests: TestCase {
XCTAssertEqual("Project page", properties?["screen"] as? String)
}

func testTrackPledgeCTAButtonClicked_ViewYourRewardsState() {
let client = MockTrackingClient()
let user = User.template |> \.id .~ 42
let project = Project.template
|> Project.lens.creator .~ user

let koala = Koala(client: client, loggedInUser: user)

koala.trackPledgeCTAButtonClicked(stateType: .viewYourRewards, project: project, screen: .projectPage)

let properties = client.properties.last

XCTAssertEqual(["View Your Rewards Button Clicked"], client.events)
XCTAssertEqual("Project page", properties?["screen"] as? String)
}

func testTrackSelectRewardButtonClicked() {
let client = MockTrackingClient()
let reward = Reward.template
Expand Down
9 changes: 6 additions & 3 deletions Library/PledgeStateCTAType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public enum PledgeStateCTAType {
case manage
case viewBacking
case viewRewards
case viewYourRewards

public var buttonTitle: String {
switch self {
Expand All @@ -19,6 +20,8 @@ public enum PledgeStateCTAType {
return Strings.View_your_pledge()
case .viewRewards:
return Strings.View_rewards()
case .viewYourRewards:
return Strings.View_your_rewards()
}
}

Expand All @@ -30,14 +33,14 @@ public enum PledgeStateCTAType {
return .green
case .manage:
return .blue
case .viewBacking, .viewRewards:
case .viewBacking, .viewRewards, .viewYourRewards:
return .black
}
}

public var stackViewIsHidden: Bool {
switch self {
case .pledge, .viewBacking, .viewRewards:
case .pledge, .viewBacking, .viewRewards, .viewYourRewards:
return true
case .fix, .manage:
return false
Expand Down Expand Up @@ -66,7 +69,7 @@ public enum PledgeStateCTAType {

public var stackViewAndSpacerAreHidden: Bool {
switch self {
case .pledge, .viewBacking, .viewRewards:
case .pledge, .viewBacking, .viewRewards, .viewYourRewards:
return true
case .fix, .manage:
return false
Expand Down
25 changes: 21 additions & 4 deletions Library/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8824,6 +8824,23 @@ catch your eye?"
substitutions: [:]
)
}
/**
"View your rewards"

- **en**: "View your rewards"
- **de**: "Deine Belohnungen ansehen"
- **es**: "Ver tus recompensas"
- **fr**: "Afficher mes récompenses"
- **ja**: "View your rewards"
*/
public static func View_your_rewards() -> String {
return localizedString(
key: "View_your_rewards",
defaultValue: "View your rewards",
count: nil,
substitutions: [:]
)
}
/**
"Watch live"

Expand Down Expand Up @@ -9293,10 +9310,10 @@ Veuillez réessayer ultérieurement."
"You launched this project on %{launch_date}."

- **en**: "You launched this project on %{launch_date}."
- **de**: "You launched this project on %{launch_date}."
- **es**: "You launched this project on %{launch_date}."
- **fr**: "You launched this project on %{launch_date}."
- **ja**: "You launched this project on %{launch_date}."
- **de**: "Du hast dieses Projekt am %{launch_date} veröffentlicht."
- **es**: "Publicaste el proyecto el: %{launch_date}."
- **fr**: "Vous avez lancé ce projet le %{launch_date}."
- **ja**: "このプロジェクトを %{launch_date} にローンチしました。"
*/
public static func You_launched_this_project_on_launch_date(launch_date: String) -> String {
return localizedString(
Expand Down
4 changes: 4 additions & 0 deletions Library/ViewModels/PledgeCTAContainerViewViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public final class PledgeCTAContainerViewViewModel: PledgeCTAContainerViewViewMo

private func pledgeCTA(project: Project, backing: Backing?) -> PledgeStateCTAType {
guard let projectBacking = backing, project.personalization.isBacking == .some(true) else {
if currentUserIsCreator(of: project) {
return PledgeStateCTAType.viewYourRewards
}

return project.state == .live ? PledgeStateCTAType.pledge : PledgeStateCTAType.viewRewards
}

Expand Down
30 changes: 30 additions & 0 deletions Library/ViewModels/PledgeCTAContainerViewViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ internal final class PledgeCTAContainerViewViewModelTests: TestCase {
self.stackViewIsHidden.assertValues([true])
}

func testPledgeCTA_LiveProject_UserIsCreator() {
let user = User.template |> User.lens.id .~ 5
let project = Project.template
|> Project.lens.creator.id .~ 5
|> Project.lens.state .~ .live

withEnvironment(currentUser: user) {
self.vm.inputs.configureWith(value: (.left(project), false))
self.buttonStyleType.assertValues([ButtonStyleType.black])
self.buttonTitleText.assertValues(["View your rewards"])
self.spacerIsHidden.assertValues([true])
self.stackViewIsHidden.assertValues([true])
}
}

func testPledgeCTA_NonLiveProject_UserIsCreator() {
let user = User.template |> User.lens.id .~ 5
let project = Project.template
|> Project.lens.creator.id .~ 5
|> Project.lens.state .~ .successful

withEnvironment(currentUser: user) {
self.vm.inputs.configureWith(value: (.left(project), false))
self.buttonStyleType.assertValues([ButtonStyleType.black])
self.buttonTitleText.assertValues(["View your rewards"])
self.spacerIsHidden.assertValues([true])
self.stackViewIsHidden.assertValues([true])
}
}

func testPledgeCTA_activityIndicator() {
let project = Project.template
|> Project.lens.state .~ .live
Expand Down
2 changes: 1 addition & 1 deletion Library/ViewModels/ProjectPamphletViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public final class ProjectPamphletViewModel: ProjectPamphletViewModelType, Proje
.skipNil()

let shouldGoToRewards = ctaButtonTappedWithType
.filter { $0 == .pledge || $0 == .viewRewards }
.filter { [.pledge, .viewRewards, .viewYourRewards].contains($0) }
.ignoreValues()
.filter(userCanSeeNativeCheckout)

Expand Down
11 changes: 11 additions & 0 deletions Library/ViewModels/ProjectPamphletViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ final class ProjectPamphletViewModelTests: TestCase {
[.discovery, .discovery],
"Tapping 'View rewards' emits the refTag"
)

self.vm.inputs.pledgeCTAButtonTapped(with: .viewYourRewards)

self.goToRewardsProject.assertValues(
[project, project, project],
"Tapping 'View your rewards' emits the project"
)
self.goToRewardsRefTag.assertValues(
[.discovery, .discovery, .discovery],
"Tapping 'View your rewards' emits the refTag"
)
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 680f982

Please sign in to comment.