Created
February 9, 2017 21:17
-
-
Save jraczak/714cec4965a5fd73a87afda1914e6530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.groupon.test.rc.tests; | |
import android.support.test.InstrumentationRegistry; | |
import android.support.test.espresso.ViewInteraction; | |
import android.support.test.filters.LargeTest; | |
import android.support.test.rule.ActivityTestRule; | |
import android.util.Log; | |
import com.groupon.ABTest; | |
import com.groupon.R; | |
import com.groupon.home.main.activities.Carousel; | |
import com.groupon.test.common.CustomAnnotations; | |
import com.groupon.test.common.constants.GrouponData; | |
import com.groupon.test.common.constants.Priority; | |
import com.groupon.test.common.constants.Timeouts; | |
import com.groupon.test.common.helpers.AndroidOdoHelper; | |
import com.groupon.test.rc.TestBases.EspressoTestBase; | |
import com.groupon.test.rc.generics.EspressoClassRunner; | |
import com.groupon.test.rc.helpers.UiUtils; | |
import com.groupon.test.rc.screens.GlobalSearch; | |
import com.groupon.testrailapi.TestRailRunner; | |
import org.junit.Assert; | |
import org.junit.After; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import static android.support.test.espresso.Espresso.onView; | |
import static android.support.test.espresso.action.ViewActions.click; | |
import static android.support.test.espresso.action.ViewActions.scrollTo; | |
import static android.support.test.espresso.assertion.ViewAssertions.matches; | |
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition; | |
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; | |
import static android.support.test.espresso.matcher.ViewMatchers.withId; | |
import static android.support.test.espresso.matcher.ViewMatchers.withParent; | |
import static android.support.test.espresso.matcher.ViewMatchers.withText; | |
import static com.groupon.test.rc.helpers.EspressoOdoHelper.setCustomResponseFromAssets; | |
import static org.hamcrest.Matchers.allOf; | |
import android.support.test.runner.AndroidJUnit4; | |
import com.xamarin.testcloud.espresso.Factory; | |
import com.xamarin.testcloud.espresso.ReportHelper; | |
@RunWith(EspressoClassRunner.class) | |
@LargeTest | |
public class SearchTest extends EspressoTestBase { | |
public static final String TAG = "ExposedFilterTest"; | |
public static final String SEARCH_QUERY = "Food & Drink"; | |
@Rule | |
public ActivityTestRule<Carousel> mActivityRule = new ActivityTestRule(Carousel.class, true, true); | |
@Rule | |
public ReportHelper reportHelper = Factory.getReportHelper(); | |
@After | |
public void TearDown(){ | |
reportHelper.label("Stopping App"); | |
} | |
@Test(timeout = Timeouts.TEST_TIMEOUT_VERY_LONG) | |
@CustomAnnotations.Priority(Priority.P1) | |
@CustomAnnotations.ExperimentMatrix({ | |
ABTest.ExposedFilters1611USCA.EXPERIMENT_NAME + "." + ABTest.ExposedFilters1611USCA.VARIANT_NAME | |
}) | |
@TestRailRunner.TestCases(cases = {@TestRailRunner.TestCase(ID = "67622653", comment = "Automark 1", locale = {GrouponData.CountryCodes.US}, retest = false)}) | |
public void testExposedFiltersHappyPath() throws Exception { | |
// wait for Home Tab | |
com.groupon.test.rc.screens.HomeTab.waitFor(); | |
// Global Search | |
Log.d(TAG, "Click on search bar"); | |
GlobalSearch.navigateTo(); | |
GlobalSearch.waitForSearchEditText(); | |
setCustomResponseFromAssets(odoclient, AndroidOdoHelper.Paths.CARDS_SEARCH, AndroidOdoHelper.StubFiles.CARDS_SEARCH_FOODS_AND_DRINKS_RESPONSE); | |
Log.d(TAG, "Search Food and Drink"); | |
GlobalSearch.typeQueryAndHitSearch(SEARCH_QUERY); | |
com.groupon.test.rc.screens.GlobalSearch.waitForExposedFilters(); | |
// Scroll to Distance Exposed Filter | |
String distanceFilter = InstrumentationRegistry.getTargetContext().getResources().getString(R.string.filters_sort_distance); | |
Log.d(TAG, "Scroll to and click on Distance Exposed Filter: " + distanceFilter); | |
GlobalSearch.selectFilter(distanceFilter); | |
// Verify Filter sheet is displayed | |
ViewInteraction filterSheet = onView( | |
allOf(withId(R.id.single_filter_options_list), isDisplayed())); | |
// Select the first option | |
filterSheet.perform(actionOnItemAtPosition(1, click())); | |
// Click on DONE | |
GlobalSearch.clickDone(); | |
// verify filter count is applied | |
ViewInteraction filterApplied = onView( | |
allOf(withText("ALL FILTERS (1)"), | |
withParent(allOf(withId(R.id.exposed_filters_container), | |
withParent(withId(R.id.exposed_filters_scroll_view)))))); | |
filterApplied.perform(scrollTo()); | |
filterApplied.check(matches(isDisplayed())); | |
Log.d(TAG, "Click Map View and Select All Filters"); | |
GlobalSearch.clickMapView(); | |
filterApplied.perform(scrollTo(), click()); | |
GlobalSearch.clickDone(); | |
} | |
@Test(timeout = Timeouts.TEST_TIMEOUT_MEDIUM) | |
@CustomAnnotations.Priority(Priority.P1) | |
@CustomAnnotations.ExperimentMatrix({ABTest.ExposedFilters1611USCA.EXPERIMENT_NAME + "." + ABTest.ExposedFilters1611USCA.VARIANT_NAME}) | |
@TestRailRunner.TestCases(cases = {@TestRailRunner.TestCase(ID = "67622637", comment = "Automark 1", locale = {GrouponData.CountryCodes.US}, retest = false)}) | |
public void testExposedFiltersDisplayedWhenEnabled() throws Exception { | |
// Global Search | |
Log.d(TAG, "Click on search bar"); | |
GlobalSearch.navigateTo(); | |
GlobalSearch.waitForSearchEditText(); | |
Log.d(TAG, "Search Food and Drink"); | |
GlobalSearch.typeQueryAndHitSearch(SEARCH_QUERY); | |
Log.d(TAG, "Variant is on . Should show exposed Filters"); | |
GlobalSearch.waitForExposedFilters(); | |
} | |
@Test(timeout = Timeouts.TEST_TIMEOUT_MEDIUM) | |
@CustomAnnotations.Priority(Priority.P1) | |
@CustomAnnotations.ExperimentMatrix({ABTest.ExposedFilters1611USCA.EXPERIMENT_NAME + "." + ABTest.VARIANT_NAME_ORIGINAL}) | |
@TestRailRunner.TestCases(cases = {@TestRailRunner.TestCase(ID = "67622637", comment = "Automark 1", locale = {GrouponData.CountryCodes.US}, retest = false)}) | |
public void testExposedFiltersNotDisplayedWhenDisabled() throws Exception { | |
// Global Search | |
Log.d(TAG, "Click on search bar"); | |
GlobalSearch.navigateTo(); | |
GlobalSearch.waitForSearchEditText(); | |
Log.d(TAG, "Search Food and Drink"); | |
GlobalSearch.typeQueryAndHitSearch(SEARCH_QUERY); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment