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

[NT-1175] Coalesce experimental variants to control #1173

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/OptimizelyExperiment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ extension OptimizelyExperiment {
static func projectCampaignExperiment(
project: Project,
refTag: RefTag?
) -> OptimizelyExperiment.Variant? {
) -> OptimizelyExperiment.Variant {
return AppEnvironment.current.optimizelyClient?
.variant(
for: OptimizelyExperiment.Key.nativeProjectPageCampaignDetails,
userAttributes: optimizelyUserAttributes(with: project, refTag: refTag)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the function return value can also be changed to OptimizelyExperiment.Variant if we're coalescing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks - I had it like that but then reverted to right a failing test and forgot to switch back 😅

) ?? .control
}
}
8 changes: 4 additions & 4 deletions Library/ViewModels/ProjectPamphletContentViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,24 +310,24 @@ private func projectSummaryQuery(withSlug slug: String) -> NonEmptySet<Query> {

private func projectPageConversionCreatorDetailsExperiment(
project: Project, refTag: RefTag?
) -> OptimizelyExperiment.Variant? {
) -> OptimizelyExperiment.Variant {
let optimizelyVariant = AppEnvironment.current.optimizelyClient?
.variant(
for: OptimizelyExperiment.Key.nativeProjectPageConversionCreatorDetails,
userAttributes: optimizelyUserAttributes(with: project, refTag: refTag)
)
) ?? .control

return optimizelyVariant
}

private func projectPageConversionProjectSummaryExperiment(
project: Project, refTag: RefTag?
) -> OptimizelyExperiment.Variant? {
) -> OptimizelyExperiment.Variant {
let optimizelyVariant = AppEnvironment.current.optimizelyClient?
.variant(
for: OptimizelyExperiment.Key.nativeMeProjectSummary,
userAttributes: optimizelyUserAttributes(with: project, refTag: refTag)
)
) ?? .control

return optimizelyVariant
}
1 change: 0 additions & 1 deletion Library/ViewModels/ProjectPamphletMainCellViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public final class ProjectPamphletMainCellViewModel: ProjectPamphletMainCellView

let projectCampaignExperimentVariant = projectAndRefTag
.map(OptimizelyExperiment.projectCampaignExperiment)
.skipNil()

self.configureCreatorBylineView = Signal.combineLatest(project, creatorDetails)

Expand Down
15 changes: 15 additions & 0 deletions Library/ViewModels/ProjectPamphletMainCellViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,21 @@ final class ProjectPamphletMainCellViewModelTests: TestCase {
}
}

func testProjectCampaignCTA_OptimizelyControl_OptimizelyClientNotConfigured() {
let creatorDetails = ProjectCreatorDetailsEnvelope.template

self.readMoreButtonIsHidden.assertDidNotEmitValue()
self.readMoreButtonLargeIsHidden.assertDidNotEmitValue()

withEnvironment(optimizelyClient: nil) {
self.vm.inputs.configureWith(value: (.template, nil, (creatorDetails, false), []))
self.vm.inputs.awakeFromNib()

self.readMoreButtonIsHidden.assertValues([false])
self.readMoreButtonLargeIsHidden.assertValues([true])
}
}

func testProjectCampaignCTA_OptimizelyExperimental_Variant1() {
let creatorDetails = ProjectCreatorDetailsEnvelope.template
let optimizelyClient = MockOptimizelyClient()
Expand Down