Skip to content

Commit

Permalink
Keep showing Search Box after experiment ends (#3594)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/72649045549333/1208836242994116/f

Description:
If the experiment is not reporting pixels anymore (past 7-day deadline), we want to keep showing
search box to the users.
  • Loading branch information
ayoy authored Nov 25, 2024
1 parent 4a3dae4 commit c2bd650
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ final class NewTabPageSearchBoxExperiment {
}

var cohort: Cohort? {
isActive ? dataStore.experimentCohort : nil
dataStore.experimentCohort
}

var onboardingCohort: PixelExperiment? {
Expand Down
11 changes: 6 additions & 5 deletions DuckDuckGo/NavigationBar/View/AddressBarTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ final class AddressBarTextField: NSTextField {

private func navigate(suggestion: Suggestion?) {
let ntpExperiment = NewTabPageSearchBoxExperiment()
let ntpExperimentCohort: NewTabPageSearchBoxExperiment.Cohort? = ntpExperiment.isActive ? ntpExperiment.cohort : nil
let source: NewTabPageSearchBoxExperiment.SearchSource? = {
guard ntpExperiment.isActive else {
return nil
Expand All @@ -349,17 +350,17 @@ final class AddressBarTextField: NSTextField {
let autocompletePixel: GeneralPixel? = {
switch suggestion {
case .phrase:
return .autocompleteClickPhrase(from: source, cohort: ntpExperiment.cohort, onboardingCohort: ntpExperiment.onboardingCohort)
return .autocompleteClickPhrase(from: source, cohort: ntpExperimentCohort, onboardingCohort: ntpExperiment.onboardingCohort)
case .website:
return .autocompleteClickWebsite(from: source, cohort: ntpExperiment.cohort, onboardingCohort: ntpExperiment.onboardingCohort)
return .autocompleteClickWebsite(from: source, cohort: ntpExperimentCohort, onboardingCohort: ntpExperiment.onboardingCohort)
case .bookmark(_, _, let isFavorite, _):
if isFavorite {
return .autocompleteClickFavorite(from: source, cohort: ntpExperiment.cohort, onboardingCohort: ntpExperiment.onboardingCohort)
return .autocompleteClickFavorite(from: source, cohort: ntpExperimentCohort, onboardingCohort: ntpExperiment.onboardingCohort)
} else {
return .autocompleteClickBookmark(from: source, cohort: ntpExperiment.cohort, onboardingCohort: ntpExperiment.onboardingCohort)
return .autocompleteClickBookmark(from: source, cohort: ntpExperimentCohort, onboardingCohort: ntpExperiment.onboardingCohort)
}
case .historyEntry:
return .autocompleteClickHistory(from: source, cohort: ntpExperiment.cohort, onboardingCohort: ntpExperiment.onboardingCohort)
return .autocompleteClickHistory(from: source, cohort: ntpExperimentCohort, onboardingCohort: ntpExperiment.onboardingCohort)
default:
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/HomePage/NewTabPageSearchBoxExperimentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ final class NewTabPageSearchBoxExperimentTests: XCTestCase {
XCTAssertFalse(experiment.isActive)
}

func testWhenExperimentIsInactiveThenCohortIsNil() {
func testWhenExperimentIsInactiveThenCohortStays() {
dataStore.didRunEnrollment = true
dataStore.experimentCohort = .experiment
dataStore.enrollmentDate = Date.daysAgo(NewTabPageSearchBoxExperiment.Const.experimentDurationInDays)

XCTAssertNil(experiment.cohort)
XCTAssertEqual(experiment.cohort, .experiment)
}

func testWhenExperimentIsInactiveThenOnboardingExperimentCohortIsNil() {
Expand Down

0 comments on commit c2bd650

Please sign in to comment.