mid commit

This commit is contained in:
2023-06-12 17:18:39 +01:00
parent 786761f67c
commit 2d0d1c973e
6 changed files with 75 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
package h_mal.appttude.com.driver package h_mal.appttude.com.driver
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.view.View import android.view.View
import android.widget.EditText import android.widget.EditText
import android.widget.ImageView import android.widget.ImageView

View File

@@ -1,5 +1,6 @@
package h_mal.appttude.com.driver package h_mal.appttude.com.driver
import androidx.annotation.IdRes
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
@@ -19,7 +20,6 @@ open class FormRobot : BaseTestRobot() {
selectSingleImageFromGallery(filePath) { selectSingleImageFromGallery(filePath) {
onView(withId(imagePickerLauncherViewId)).perform(click()) onView(withId(imagePickerLauncherViewId)).perform(click())
} }
// click ok in date picker
} }
fun selectMultipleImage(imagePickerLauncherViewId: Int, filePaths: Array<String>) { fun selectMultipleImage(imagePickerLauncherViewId: Int, filePaths: Array<String>) {
@@ -28,6 +28,12 @@ open class FormRobot : BaseTestRobot() {
} }
} }
fun assertEmptyForm(@IdRes vararg ids: Int) {
ids.forEach {
matchText(it, "")
}
}
enum class FilePath(val path: String) { enum class FilePath(val path: String) {
PROFILE_PIC("driver_profile_pic.jpg"), PROFILE_PIC("driver_profile_pic.jpg"),
INSURANCE("driver_insurance.jpg"), INSURANCE("driver_insurance.jpg"),

View File

@@ -0,0 +1,19 @@
package h_mal.appttude.com.driver.model
import java.time.LocalDate
data class Date(
val dayOfMonth: Int,
val monthOfYear: Int,
val year: Int
) {
companion object {
@JvmStatic
fun now(): Date {
val date = LocalDate.now()
return Date(date.dayOfMonth, date.month.value, date.year)
}
}
}

View File

@@ -19,6 +19,11 @@ class DriversLicenseRobot : FormRobot() {
submit() submit()
} }
fun validateEmptyPage() {
assertEmptyForm(R.id.lic_no, R.id.lic_expiry)
// Todo: assert imageview has default image
}
fun validate() { fun validate() {
checkImageViewHasImage(R.id.driversli_img) checkImageViewHasImage(R.id.driversli_img)

View File

@@ -2,6 +2,7 @@ package h_mal.appttude.com.driver.robots.driver
import h_mal.appttude.com.driver.FormRobot import h_mal.appttude.com.driver.FormRobot
import h_mal.appttude.com.driver.R import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.model.Date
fun driversProfile(func: DriversProfileRobot.() -> Unit) = DriversProfileRobot().apply { func() } fun driversProfile(func: DriversProfileRobot.() -> Unit) = DriversProfileRobot().apply { func() }
class DriversProfileRobot : FormRobot() { class DriversProfileRobot : FormRobot() {
@@ -10,9 +11,10 @@ class DriversProfileRobot : FormRobot() {
fun enterAddress(address: String) = fillEditText(R.id.address_input, address) fun enterAddress(address: String) = fillEditText(R.id.address_input, address)
fun enterPostcode(postcode: String) = fillEditText(R.id.postcode_input, postcode) fun enterPostcode(postcode: String) = fillEditText(R.id.postcode_input, postcode)
fun enterDateOfBirth(dob: String) = fillEditText(R.id.dob_input, dob) fun enterDateOfBirth(dob: String) = fillEditText(R.id.dob_input, dob)
fun enterDateOfBirth(dob: Date) = setDate(R.id.dob_input, dob.year, dob.monthOfYear, dob.dayOfMonth)
fun enterNINumber(niNumber: String) = fillEditText(R.id.ni_number, niNumber) fun enterNINumber(niNumber: String) = fillEditText(R.id.ni_number, niNumber)
fun enterDateFirstAvailable(year: Int, monthOfYear: Int, dayOfMonth: Int) = fun enterDateFirstAvailable(date: Date) =
setDate(R.id.date_first, year, monthOfYear, dayOfMonth) setDate(R.id.date_first, date.year, date.monthOfYear, date.dayOfMonth)
fun selectImage() = selectSingleImage(R.id.add_photo, FilePath.PROFILE_PIC) fun selectImage() = selectSingleImage(R.id.add_photo, FilePath.PROFILE_PIC)
@@ -20,11 +22,9 @@ class DriversProfileRobot : FormRobot() {
name: String, name: String,
address: String, address: String,
postcode: String, postcode: String,
dob: String, dob: Date,
niNumber: String, niNumber: String,
year: Int, firstDateAvailable: Date
monthOfYear: Int,
dayOfMonth: Int
) { ) {
selectImage() selectImage()
enterName(name) enterName(name)
@@ -32,7 +32,7 @@ class DriversProfileRobot : FormRobot() {
enterPostcode(postcode) enterPostcode(postcode)
enterDateOfBirth(dob) enterDateOfBirth(dob)
enterNINumber(niNumber) enterNINumber(niNumber)
enterDateFirstAvailable(year, monthOfYear, dayOfMonth) enterDateFirstAvailable(firstDateAvailable)
submit() submit()
} }
} }

View File

@@ -1,13 +1,17 @@
package h_mal.appttude.com.driver.tests.newUser package h_mal.appttude.com.driver.tests.newUser
import androidx.test.espresso.Espresso
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import h_mal.appttude.com.driver.FirebaseTest import h_mal.appttude.com.driver.FirebaseTest
import h_mal.appttude.com.driver.R import h_mal.appttude.com.driver.R
import h_mal.appttude.com.driver.model.Date
import h_mal.appttude.com.driver.robots.* import h_mal.appttude.com.driver.robots.*
import h_mal.appttude.com.driver.robots.driver.driversLicense import h_mal.appttude.com.driver.robots.driver.driversLicense
import h_mal.appttude.com.driver.robots.driver.driversProfile
import h_mal.appttude.com.driver.robots.driver.privateHireLicenseRobot
import h_mal.appttude.com.driver.ui.MainActivity import h_mal.appttude.com.driver.ui.MainActivity
import org.junit.* import org.junit.*
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -23,21 +27,50 @@ class SubmitNewDataActivityTest :
GrantPermissionRule.grant(android.Manifest.permission.READ_EXTERNAL_STORAGE) GrantPermissionRule.grant(android.Manifest.permission.READ_EXTERNAL_STORAGE)
@Test @Test
fun verifyUserRegistration_validUsernameAndPassword_loggedIn() { fun newUser_submitDriversDocuments_documentsSubmitted() {
home { home {
waitFor(2500) waitFor(2500)
checkTitleExists(getResourceString(R.string.welcome_title)) checkTitleExists(getResourceString(R.string.welcome_title))
requestProfile() requestProfile()
openDriverProfile() openDriverProfile()
} }
// Submit drivers license
driverScreen { driverScreen {
driverLicense() driverLicense()
} }
driversLicense { driversLicense {
validateEmptyPage()
waitFor(5000)
submitForm("SAMPLE8456310LTU", 2022, 10, 2) submitForm("SAMPLE8456310LTU", 2022, 10, 2)
// Todo: validate successful submission
Espresso.pressBack()
}
// Submit drivers profile
driverScreen {
driverProfile()
}
driversProfile {
// todo: validate empty page
submitForm(
name = "Basic Driver",
address = "123A Random Street, Suburb, County",
postcode = "AB12 3CD",
dob = Date(12, 12, 1989),
niNumber = "AB123456C",
firstDateAvailable = Date.now()
)
// Todo: validate successful submission
Espresso.pressBack()
}
driverScreen {
privateHireLicense()
}
privateHireLicenseRobot {
// todo: validate empty page
submitForm("SAMPLE8456310LTU", 2022, 10, 2)
// Todo: validate successful submission
Espresso.pressBack()
} }
} }
} }