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

Revert "Disable automatic opt-in screen display." #4892

Merged
merged 5 commits into from
Jan 10, 2022
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
1 change: 1 addition & 0 deletions changelog.d/4892.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display Analytics opt-in screen at first start-up of the app
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import im.vector.app.activityIdlingResource
import im.vector.app.waitForView
import im.vector.app.withIdlingResource
import org.hamcrest.Matcher
import org.hamcrest.Matchers.not

inline fun <reified T : Activity> waitUntilActivityVisible(noinline block: (() -> Unit) = {}) {
withIdlingResource(activityIdlingResource(T::class.java), block)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.app.ui.robot

import androidx.test.espresso.matcher.ViewMatchers.withId
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.analytics.ui.consent.AnalyticsOptInActivity

class AnalyticsRobot {
Copy link
Contributor

Choose a reason for hiding this comment

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

💯


fun optIn() {
answerOptIn(true)
}

fun optOut() {
answerOptIn(false)
}

private fun answerOptIn(optIn: Boolean) {
waitUntilActivityVisible<AnalyticsOptInActivity> {
waitUntilViewVisible(withId(R.id.title))
}
assertDisplayed(R.id.title, R.string.analytics_opt_in_title)
if (optIn) {
clickOn(R.id.submit)
} else {
clickOn(R.id.later)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.createdirect.CreateDirectRoomActivity
import im.vector.app.features.home.HomeActivity
import im.vector.app.features.login.LoginActivity
import im.vector.app.features.onboarding.OnboardingActivity
import im.vector.app.initialSyncIdlingResource
import im.vector.app.ui.robot.settings.SettingsRobot
import im.vector.app.withIdlingResource
Expand All @@ -43,6 +43,8 @@ class ElementRobot {
fun signUp(userId: String) {
val onboardingRobot = OnboardingRobot()
onboardingRobot.createAccount(userId = userId)
val analyticsRobot = AnalyticsRobot()
analyticsRobot.optOut()
waitForHome()
}

Expand Down Expand Up @@ -121,7 +123,7 @@ class ElementRobot {
clickDialogPositiveButton()
}

waitUntilActivityVisible<LoginActivity> {
waitUntilActivityVisible<OnboardingActivity> {
assertDisplayed(R.id.loginSplashLogo)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ class OnboardingRobot {
homeServerUrl: String) {
waitUntilViewVisible(withId(R.id.loginSplashSubmit))
assertDisplayed(R.id.loginSplashSubmit, R.string.login_splash_submit)
clickOn(R.id.loginSplashSubmit)
if (createAccount) {
clickOn(R.id.loginSplashSubmit)
} else {
clickOn(R.id.loginSplashAlreadyHaveAccount)
}
assertDisplayed(R.id.loginServerTitle, R.string.login_server_title)
// Chose custom server
clickOn(R.id.loginServerChoiceOther)
Expand All @@ -54,17 +58,7 @@ class OnboardingRobot {
assertEnabled(R.id.loginServerUrlFormSubmit)
closeSoftKeyboard()
clickOn(R.id.loginServerUrlFormSubmit)
onView(isRoot()).perform(waitForView(withId(R.id.loginSignupSigninSubmit)))

if (createAccount) {
// Click on the signup button
assertDisplayed(R.id.loginSignupSigninSubmit)
clickOn(R.id.loginSignupSigninSubmit)
} else {
// Click on the signin button
assertDisplayed(R.id.loginSignupSigninSignIn)
clickOn(R.id.loginSignupSigninSignIn)
}
onView(isRoot()).perform(waitForView(withId(R.id.loginField)))

// Ensure password flow supported
assertDisplayed(R.id.loginField)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,9 @@ class HomeActivityViewModel @AssistedInject constructor(
observeInitialSync()
checkSessionPushIsOn()
observeCrossSigningReset()
// Disable Analytics opt-in automatic display
// Waiting for translation and for analytic events to be actually sent
// observeAnalytics()
observeAnalytics()
}

@Suppress("unused")
private fun observeAnalytics() {
if (analyticsConfig.isEnabled) {
analyticsStore.didAskUserConsentFlow
Expand Down