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

Espresso dependencies and Login tests #1003

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ buildscript {
maven{ url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0'
classpath 'com.palantir:jacoco-coverage:0.4.0'
classpath 'com.palantir.jacoco-coverage:com.palantir.jacoco-coverage.gradle.plugin:0.4.0'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath 'com.google.gms:google-services:4.3.5'
classpath 'io.fabric.tools:gradle:1.31.2'
Expand Down
Binary file added libs/circleprogressbar-1.0.7.aar
Binary file not shown.
6 changes: 6 additions & 0 deletions opensrp-anc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@



buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -181,6 +184,7 @@ tasks.withType(Test) {

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation files('../libs/circleprogressbar-1.0.7.aar')
implementation('org.smartregister:opensrp-client-native-form:3.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
Expand All @@ -191,6 +195,7 @@ dependencies {
exclude group: 'com.android.support', module: 'design'
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
exclude group: 'io.ona.CircleProgressbar', module: 'lib'
}
implementation('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
transitive = true
Expand Down Expand Up @@ -229,6 +234,7 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.9'
implementation 'junit:junit:4.12'
implementation 'androidx.test:core:1.4.0'
testImplementation project(':opensrp-anc')
annotationProcessor 'com.jakewharton:butterknife:10.2.3'
implementation 'net.zetetic:android-database-sqlcipher:4.4.0@aar'
implementation 'commons-validator:commons-validator:1.7'
Expand Down
41 changes: 27 additions & 14 deletions reference-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ android {
* This allows you to run the app in the release variant. make sure to add this configs to the
* local.properties files when you need to use them
* */
signingConfigs {
release {
//Store your local.properties file in the project root folder
v1SigningEnabled true
v2SigningEnabled true
keyAlias System.getenv("KEYSTORE_ALIAS") ?: project.KEYSTORE_ALIAS
keyPassword System.getenv("KEY_PASSWORD") ?: project.KEY_PASSWORD
storePassword System.getenv("KEYSTORE_PASSWORD") ?: project.KEYSTORE_PASSWORD
//Save your keystore file as ~/opensrp-release-upload-key.jks (in your home directory)
storeFile file(System.getProperty("user.home") + "/anckey.keystore.jks")
}
}
signingConfigs {
release {
//Store your local.properties file in the project root folder
v1SigningEnabled true
v2SigningEnabled true
keyAlias System.getenv("KEYSTORE_ALIAS") ?: project.KEYSTORE_ALIAS
keyPassword System.getenv("KEY_PASSWORD") ?: project.KEY_PASSWORD
storePassword System.getenv("KEYSTORE_PASSWORD") ?: project.KEYSTORE_PASSWORD
//Save your keystore file as ~/opensrp-release-upload-key.jks (in your home directory)
storeFile file(System.getProperty("user.home") + "/anckey.keystore.jks")
}
}
useLibrary 'org.apache.http.legacy'
compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
Expand Down Expand Up @@ -224,9 +224,23 @@ tasks.withType(Test) {
}

dependencies {

// AndroidX Test libraries
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test:rules:1.5.0'

// AndroidX Core testing libraries
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation project(':reference-app')
debugImplementation "androidx.test:monitor:1.6.0"
androidTestImplementation 'androidx.test:core:1.4.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
def powerMockVersion = '2.0.7'
implementation project(":opensrp-anc")
implementation files('../libs/circleprogressbar-1.0.7.aar')
implementation('org.smartregister:opensrp-client-native-form:3.1.1-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
Expand All @@ -237,6 +251,7 @@ dependencies {
exclude group: 'com.android.support', module: 'design'
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
exclude group: 'io.ona.CircleProgressbar', module: 'lib'
}

implementation('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
Expand Down Expand Up @@ -299,8 +314,6 @@ dependencies {
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'org.jeasy:easy-rules-core:3.3.0'
implementation 'org.jeasy:easy-rules-mvel:3.3.0'
implementation 'com.flurry.android:analytics:11.6.0@aar'
implementation 'com.flurry.android:analytics:11.6.0@aar'
implementation 'androidx.multidex:multidex:2.0.1'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.3.1')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package org.smartregister.anc.activity.anc;


import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.scrollTo;
import static androidx.test.espresso.action.ViewActions.swipeUp;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom;
import static androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
import static androidx.test.espresso.matcher.ViewMatchers.withHint;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withParent;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

import static org.hamcrest.Matchers.anything;
import static org.hamcrest.core.AllOf.allOf;

import android.view.View;
import android.widget.DatePicker;

import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.contrib.PickerActions;
import androidx.test.espresso.contrib.RecyclerViewActions;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.espresso.matcher.ViewMatchers;

import org.hamcrest.CoreMatchers;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.smartregister.anc.R;
import org.smartregister.anc.activity.LoginActivity;
import org.smartregister.anc.activity.utils.Configs;
import org.smartregister.anc.activity.utils.Constants;
import org.smartregister.anc.activity.utils.Utils;

@LargeTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(AndroidJUnit4.class)


public class AdvancedSearchTests {
@Rule
public ActivityScenarioRule<LoginActivity> mActivityScenario = new ActivityScenarioRule<>(LoginActivity.class);

private final Utils utils = new Utils();

@Test
public void A_setUp() throws InterruptedException {
utils.logIn(Constants.ancConstants.ancUsername, Constants.ancConstants.ancPassword);
}

@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByFirstName() throws InterruptedException {
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withId(R.id.first_name)).perform(typeText(Configs.TestDataConfigs.firstNameA),ViewActions.closeSoftKeyboard());
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText("Terence Howard")))).check(matches(isDisplayed()));

}
@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByLastName() throws InterruptedException {
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withId(R.id.last_name)).perform(typeText(Configs.TestDataConfigs.lastNameA),ViewActions.closeSoftKeyboard());
onView(withId(R.id.search)).perform(click());
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
Thread.sleep(5000);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText("Two Direction")))).check(matches(isDisplayed()));

}

@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByANCID() throws InterruptedException {
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(allOf(withId(R.id.anc_id),isDescendantOfA(withId(R.id.nested_scroll_view)), withHint("ANC ID"))).perform(typeText(Configs.TestDataConfigs.clientID),ViewActions.closeSoftKeyboard());
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText("ID: 7138845")))).check(matches(isDisplayed()));

}

@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByExpectedDateOfDelivery() throws InterruptedException {
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withHint("Expected date of delivery")).perform(click());
onView(isAssignableFrom(DatePicker.class)).perform(PickerActions.setDate(2025, 4, 25));
onView(withText("OK")).perform(click());
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText(Configs.TestDataConfigs.clientName2)))).check(matches(isDisplayed()));

}
@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByDateOfBirth() throws InterruptedException{
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withHint("Expected date of delivery")).perform(swipeUp());
onView(withId(R.id.dob)).perform(click());
onView(isAssignableFrom(DatePicker.class)).perform(PickerActions.setDate(1992, 7, 19));
onView(withText("OK")).perform(click());
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText(Configs.TestDataConfigs.clientName2)))).check(matches(isDisplayed()));

}
@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByPhoneNumber() throws InterruptedException{
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withHint("Expected date of delivery")).perform(swipeUp());
onView(withId(R.id.dob)).perform(swipeUp());
onView(withId(R.id.phone_number)).perform(typeText(Configs.TestDataConfigs.phoneNumberA));
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText(Configs.TestDataConfigs.clientName2)))).check(matches(isDisplayed()));

}
@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByAlternateName()throws InterruptedException {
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withHint("Expected date of delivery")).perform(swipeUp());
onView(withId(R.id.edd)).perform(swipeUp());
onView(withId(R.id.dob)).perform(swipeUp());
onView(withId(R.id.phone_number)).perform(swipeUp());
onView(withId(R.id.alternate_contact_name)).perform(typeText(Configs.TestDataConfigs.alternateContactName),ViewActions.closeSoftKeyboard());
onView(withId(R.id.search)).perform(click());
Thread.sleep(5000);
Matcher<View> parentMatcher = withId(R.id.list_view_layout);
onView(allOf(withId(R.id.recycler_view), withParent(parentMatcher))).perform(RecyclerViewActions.scrollTo(ViewMatchers.hasDescendant(withText(Configs.TestDataConfigs.clientName2)))).check(matches(isDisplayed()));
}
@Test
public void userCanSearchOutsideAndInsideMyHealthFacilityByScanningAQRCOde() throws InterruptedException{
onView(withId(R.id.action_search)).perform(click());
Thread.sleep(2000);
onView(withId(R.id.qrCodeButton)).perform(click());
onView(withText("Scan QR Code")).check(matches(isDisplayed()));
}
@Test
public void userCanSearchInMyHealthFacilityByFirstName () {
onView(withId(R.id.action_search)).perform(click());
onView(withId(R.id.my_catchment)).perform(click());
onView(withId(R.id.first_name)).perform(typeText(Configs.TestDataConfigs.firstNameA),ViewActions.closeSoftKeyboard());
onView(withId(R.id.search)).perform(click());
}

}
Loading
Loading