|
| 1 | +package org.wikipedia.tests |
| 2 | + |
| 3 | +import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 4 | +import androidx.test.filters.LargeTest |
| 5 | +import org.junit.Test |
| 6 | +import org.junit.runner.RunWith |
| 7 | +import org.wikipedia.base.BaseTest |
| 8 | +import org.wikipedia.main.MainActivity |
| 9 | +import org.wikipedia.robots.DialogRobot |
| 10 | +import org.wikipedia.robots.SystemRobot |
| 11 | +import org.wikipedia.robots.feature.LoginRobot |
| 12 | +import org.wikipedia.robots.feature.ReadingListRobot |
| 13 | +import org.wikipedia.robots.feature.SearchRobot |
| 14 | +import org.wikipedia.robots.navigation.BottomNavRobot |
| 15 | + |
| 16 | +@LargeTest |
| 17 | +@RunWith(AndroidJUnit4::class) |
| 18 | +class ReadingListsTest : BaseTest<MainActivity>( |
| 19 | + activityClass = MainActivity::class.java |
| 20 | +) { |
| 21 | + private val systemRobot = SystemRobot() |
| 22 | + private val bottomNavRobot = BottomNavRobot() |
| 23 | + private val loginRobot = LoginRobot() |
| 24 | + private val searchRobot = SearchRobot() |
| 25 | + private val readingListRobot = ReadingListRobot() |
| 26 | + private val dialogRobot = DialogRobot() |
| 27 | + |
| 28 | + @Test |
| 29 | + fun runTest() { |
| 30 | + systemRobot |
| 31 | + .clickOnSystemDialogWithText("Allow") |
| 32 | + // 1. saved article should be in the "Saved" reading list |
| 33 | + search(SEARCH_QUERY_WATERMELON) |
| 34 | + readingListRobot |
| 35 | + .saveArticleToReadingList() |
| 36 | + .pressBack() |
| 37 | + .pressBack() |
| 38 | + .pressBack() |
| 39 | + bottomNavRobot |
| 40 | + .navigateToSavedPage() |
| 41 | + readingListRobot |
| 42 | + .clickOnReadingLists(LIST_NAME_SAVED) |
| 43 | + .verifySavedArticleExists(SEARCH_QUERY_WATERMELON) |
| 44 | + .pressBack() |
| 45 | + bottomNavRobot |
| 46 | + .navigateToExploreFeed() |
| 47 | + // 2. article saved to a custom list should be in the custom list in the reading list |
| 48 | + search(SEARCH_QUERY_LEMON) |
| 49 | + readingListRobot |
| 50 | + .saveArticleToReadingList() |
| 51 | + .addToReadingList(context) |
| 52 | + .typeNameOfTheList(LIST_NAME_NEW, context) |
| 53 | + .saveTheList(context) |
| 54 | + .pressBack() |
| 55 | + .pressBack() |
| 56 | + .pressBack() |
| 57 | + dialogRobot |
| 58 | + .dismissPromptLogInToSyncDialog(context) |
| 59 | + bottomNavRobot |
| 60 | + .navigateToSavedPage() |
| 61 | + readingListRobot |
| 62 | + .clickOnReadingLists(LIST_NAME_NEW) |
| 63 | + .verifySavedArticleExists(SEARCH_QUERY_LEMON) |
| 64 | + .pressBack() |
| 65 | + // 3. unsaved article should not be in the "Saved" or "custom list" in the reading list |
| 66 | + bottomNavRobot |
| 67 | + .navigateToSavedPage() |
| 68 | + readingListRobot |
| 69 | + .clickOnReadingLists(LIST_NAME_SAVED) |
| 70 | + .clickOnReadingListItem(1) |
| 71 | + .saveArticleToReadingList() |
| 72 | + .removeArticleList(LIST_NAME_SAVED) |
| 73 | + .pressBack() |
| 74 | + .verifySavedArticleDoesNotExists(SEARCH_QUERY_WATERMELON) |
| 75 | + .pressBack() |
| 76 | + .clickOnReadingLists(LIST_NAME_NEW) |
| 77 | + .clickOnReadingListItem(1) |
| 78 | + .saveArticleToReadingList() |
| 79 | + .removeArticleList(LIST_NAME_NEW) |
| 80 | + .pressBack() |
| 81 | + .verifySavedArticleDoesNotExists(SEARCH_QUERY_LEMON) |
| 82 | + .pressBack() |
| 83 | + // 4. can delete lists |
| 84 | + readingListRobot |
| 85 | + .longClickReadingLists(1) |
| 86 | + .deleteList(context) |
| 87 | + dialogRobot |
| 88 | + .click("OK") |
| 89 | + readingListRobot |
| 90 | + .verifyListDoesNotExist(LIST_NAME_NEW) |
| 91 | + } |
| 92 | + |
| 93 | + private fun search(title: String) { |
| 94 | + searchRobot |
| 95 | + .tapSearchView() |
| 96 | + .typeTextInView(title) |
| 97 | + .clickOnItemFromSearchList(0) |
| 98 | + } |
| 99 | + |
| 100 | + companion object { |
| 101 | + private const val LIST_NAME_SAVED = "Saved" |
| 102 | + private const val LIST_NAME_NEW = "new" |
| 103 | + private const val SEARCH_QUERY_WATERMELON = "Watermelon" |
| 104 | + private const val SEARCH_QUERY_LEMON = "Lemon" |
| 105 | + } |
| 106 | +} |
0 commit comments