use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class SearchViewModelTest method testProjectPage_whenFeatureFlagOn_shouldEmitProjectPage.
@Test
public void testProjectPage_whenFeatureFlagOn_shouldEmitProjectPage() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
final TestScheduler scheduler = new TestScheduler();
final List<Project> projects = Arrays.asList(ProjectFactory.allTheWayProject(), ProjectFactory.almostCompletedProject(), ProjectFactory.backedProject());
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<DiscoverEnvelope> fetchProjects(@NonNull final DiscoveryParams params) {
return Observable.just(DiscoverEnvelopeFactory.discoverEnvelope(projects));
}
};
final Environment env = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).scheduler(scheduler).apiClient(apiClient).build();
setUpEnvironment(env);
// populate search and overcome debounce
this.vm.inputs.search("");
scheduler.advanceTimeBy(300, TimeUnit.MILLISECONDS);
this.vm.inputs.projectClicked(projects.get(2));
this.goToProject.assertValues(projects.get(2));
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testStartProjectActivity_whenViewingFeatureFlagOn_shouldEmitProjectPageActivity.
@Test
public void testStartProjectActivity_whenViewingFeatureFlagOn_shouldEmitProjectPageActivity() {
final CurrentUserType currentUser = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
this.setUpEnvironment(this.environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
// Load editorial params and root categories from activity.
final DiscoveryParams editorialParams = DiscoveryParams.builder().tagId(Editorial.GO_REWARDLESS.getTagId()).sort(DiscoveryParams.Sort.MAGIC).build();
this.vm.inputs.paramsFromActivity(editorialParams);
this.vm.inputs.rootCategories(CategoryFactory.rootCategories());
// Click on project
final Project project = ProjectFactory.project();
this.vm.inputs.projectCardViewHolderClicked(project);
this.startProjectActivity.assertValueCount(1);
assertEquals(this.startProjectActivity.getOnNextEvents().get(0).first, project);
assertEquals(this.startProjectActivity.getOnNextEvents().get(0).second, RefTag.collection(518));
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CARD_CLICKED.getEventName(), EventName.CTA_CLICKED.getEventName());
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_featureDisabled.
@Test
public void testShouldShowEditorial_featureDisabled() {
final MockCurrentUser user = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature, @NotNull final ExperimentData experimentData) {
return false;
}
};
final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
setUpEnvironment(environment);
setUpInitialHomeAllProjectsParams();
this.shouldShowEditorial.assertValue(null);
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testClickingInterfaceElements_shouldEmitProjectPage.
@Test
public void testClickingInterfaceElements_shouldEmitProjectPage() {
final CurrentUserType currentUser = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
this.setUpEnvironment(this.environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
this.goToDiscovery.assertNoValues();
this.goToLogin.assertNoValues();
this.goToProject.assertNoValues();
this.startUpdateActivity.assertNoValues();
// Empty activity feed clicks do not trigger events yet.
this.vm.inputs.emptyActivityFeedDiscoverProjectsClicked(null);
this.goToDiscovery.assertValueCount(1);
this.vm.inputs.emptyActivityFeedLoginClicked(null);
this.goToLogin.assertValueCount(1);
this.vm.inputs.friendBackingClicked(null, ActivityFactory.friendBackingActivity());
this.vm.inputs.projectStateChangedClicked(null, ActivityFactory.projectStateChangedActivity());
this.vm.inputs.projectStateChangedPositiveClicked(null, ActivityFactory.projectStateChangedPositiveActivity());
this.vm.inputs.projectUpdateProjectClicked(null, ActivityFactory.updateActivity());
this.goToProject.assertValueCount(4);
// this.goToProject.assertValues(); TODO
this.vm.inputs.projectUpdateClicked(null, ActivityFactory.activity());
this.startUpdateActivity.assertValueCount(1);
this.segmentTrack.assertValues(EventName.PAGE_VIEWED.getEventName(), EventName.CTA_CLICKED.getEventName(), EventName.CARD_CLICKED.getEventName(), EventName.CARD_CLICKED.getEventName(), EventName.CARD_CLICKED.getEventName(), EventName.CARD_CLICKED.getEventName());
}
use of com.kickstarter.mock.MockExperimentsClientType in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testStartFixPledge_shouldEmitToFixPledgeProjectPage.
@Test
public void testStartFixPledge_shouldEmitToFixPledgeProjectPage() {
final CurrentUserType currentUser = new MockCurrentUser();
final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {
@Override
public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
return true;
}
};
this.setUpEnvironment(this.environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
final String projectSlug = "slug";
this.vm.inputs.managePledgeClicked(projectSlug);
this.startFixPledge.assertValueCount(1);
assertTrue(this.startFixPledge.getOnNextEvents().get(0) == projectSlug);
}
Aggregations