Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (71 sloc) 2.62 KB
package com.github.johnnysc.tutor.presentation.add
import com.github.johnnysc.tutor.presentation.core.*
import org.junit.Test
/**
* 1. Check all the initial data in case if there is nothing in database
* 2. Check the second radio button is not getting enabled after click
* 3. Check all the possible invalid inputs produce toast
*
* @author Asatryan on 18.06.19
*/
class AddNewPairInvalidDataTest : BaseTest() {
@Test
fun test_invalid_data_to_create_new_pair() {
//1. Go to the page
mainPage.addButton.click()
with(addNewPairPage) {
// Check initial data
checkViewsAreVisible(getAllVisibleViews())
addCategoryEditText.checkInputHint("Category name")
sourceValueEditText.checkInputHint("Source")
translationValueEditText.checkInputHint("Translation")
chooseCategorySpinner.checkViewIsNotVisible()
with(addCategoryRadioButton) {
checkViewIsEnabled()
checkRadioButtonIsChecked()
}
with(chooseExistingCategoryRadioButton) {
checkViewIsNotEnabled()
checkRadioButtonIsNotChecked()
//2. Check the second radio button is not getting enabled after click
click()
}
with(addCategoryRadioButton) {
checkViewIsEnabled()
checkRadioButtonIsChecked()
}
chooseCategorySpinner.checkViewIsNotVisible()
with(chooseExistingCategoryRadioButton) {
checkViewIsNotEnabled()
checkRadioButtonIsNotChecked()
}
//3. Check all the possible invalid inputs produce toast
val ids = getInputFields()
ids.forEach { it.checkText("") }
saveButton.click()
checkToast(invalidDataErrorMessage)
ids.forEachIndexed { index, _ ->
for (i in 0..2) {
if (index == i) {
ids[i].typeText(" ")
} else {
ids[i].typeText("some")
}
}
saveButton.click()
checkToast(invalidDataErrorMessage)
}
ids.forEachIndexed { index, _ ->
for (i in 0..2) {
if (index != i) {
ids[i].typeText(" ")
} else {
ids[i].typeText("thing")
}
}
saveButton.click()
checkToast(invalidDataErrorMessage)
}
}
}
}
You can’t perform that action at this time.