From fc6c881ee2db3854d001085f48d600014d5c2327 Mon Sep 17 00:00:00 2001 From: Pratyaksh Khurana Date: Wed, 5 Oct 2022 08:17:17 +0530 Subject: [PATCH] Fix #4352: Spelling mistake when setting up pin in "Enter a New Pin" dialog box (#4487) * added test and localised string * changed test name * fixed lint checks * fixed lint checks * changed test name * updated test * fixed CI checks * fixed lint check * fix CI checks --- .../ResetPinDialogFragmentPresenter.kt | 6 +++- app/src/main/res/values/strings.xml | 1 + .../app/profile/PinPasswordActivityTest.kt | 32 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt index 0b6d5beb5b6..bf81773b519 100644 --- a/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/profile/ResetPinDialogFragmentPresenter.kt @@ -68,7 +68,11 @@ class ResetPinDialogFragmentPresenter @Inject constructor( val dialog = AlertDialog.Builder(activity, R.style.OppiaAlertDialogTheme) .setTitle(R.string.reset_pin_enter) .setView(binding.root) - .setMessage("This PIN wil be $name's new PIN and will be required when signing in.") + .setMessage( + resourceHandler.getStringInLocaleWithWrapping( + R.string.reset_pin_enter_dialog_message, name + ) + ) .setPositiveButton(R.string.admin_settings_submit, null) .setNegativeButton(R.string.admin_settings_cancel) { dialog, _ -> dialog.dismiss() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4754785c4a9..801e4285c43 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -326,6 +326,7 @@ %1$s\'s New PIN. Enter a New Pin + This PIN will be %s\'s new PIN and will be required when signing in. My Downloads Downloads diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt index 29a35a72de5..a9e7bd27c0f 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt @@ -27,6 +27,7 @@ import androidx.test.rule.ActivityTestRule import com.google.android.material.textfield.TextInputEditText import com.google.common.truth.Truth.assertThat import dagger.Component +import org.hamcrest.CoreMatchers.containsString import org.hamcrest.Matchers.allOf import org.junit.After import org.junit.Before @@ -1136,6 +1137,37 @@ class PinPasswordActivityTest { } } + @Test + fun testPinPassword_clickForgotPin_enterAdminPin_clickSubmit_dialogMessageIsCorrect() { + ActivityScenario.launch( + PinPasswordActivity.createPinPasswordActivityIntent( + context = context, + adminPin = adminPin, + profileId = userId + ) + ).use { + onView(withId(R.id.forgot_pin)).perform(click()) + onView( + allOf( + withId(R.id.admin_settings_input_pin_edit_text), + isDescendantOfA(withId(R.id.admin_settings_input_pin)) + ) + ).inRoot(isDialog()) + .perform(editTextInputAction.appendText("12345"), closeSoftKeyboard()) + onView(withText(context.getString(R.string.admin_settings_submit))) + .inRoot(isDialog()) + .perform(click()) + testCoroutineDispatchers.runCurrent() + onView( + withText( + containsString( + context.resources.getString(R.string.reset_pin_enter_dialog_message, "Ben") + ) + ) + ).inRoot(isDialog()).check(matches(isDisplayed())) + } + } + private fun getAppName(): String = context.resources.getString(R.string.app_name) private fun getPinPasswordForgotMessage(): String =