Fixed - #4844 : In peer review, deletion proposal is sent even if no reason is chosen (#4862)

* Fixed - #4844 : [Bug]: In peer review, deletion proposal is sent even if no reason is chosen

* Minor Changes

* Minor Fixes

* added required changes

* added required changes - 1

* Added Test For OK Button

* Minor Fixes
This commit is contained in:
Arin Modi 2022-03-07 14:22:04 +05:30 committed by GitHub
parent 16266975d8
commit c626f97fb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 12 deletions

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.delete
import android.app.AlertDialog
import android.content.Context
import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
@ -15,6 +16,7 @@ import io.reactivex.Observable
import io.reactivex.Single
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@ -142,6 +144,21 @@ class DeleteHelperTest {
deleteHelper.askReasonAndExecute(media, mContext, "My Question", ReviewController.DeleteReason.COPYRIGHT_VIOLATION, callback);
}
@Test
fun alertDialogPositiveButtonDisableTest() {
val mContext = RuntimeEnvironment.getApplication().applicationContext
deleteHelper.askReasonAndExecute(media, mContext, "My Question", ReviewController.DeleteReason.COPYRIGHT_VIOLATION, callback);
assertEquals(false, deleteHelper.dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled)
}
@Test
fun alertDialogPositiveButtonEnableTest() {
val mContext = RuntimeEnvironment.getApplication().applicationContext
deleteHelper.askReasonAndExecute(media, mContext, "My Question", ReviewController.DeleteReason.COPYRIGHT_VIOLATION, callback);
deleteHelper.listener.onClick(deleteHelper.dialog,1,true);
assertEquals(true, deleteHelper.dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled)
}
@Test(expected = RuntimeException::class)
fun makeDeletionForEmptyCreatorName() {
whenever(pageEditClient.prependEdit(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString()))