Skip to content

Commit

Permalink
Bug 1409987 - Adding to reader List from Page Options menu XCUITest (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelrios committed Oct 20, 2017
1 parent 7201a80 commit 4a48c9f
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions XCUITests/ReaderViewUITest.swift
Expand Up @@ -34,6 +34,12 @@ class ReaderViewTest: BaseTestCase {
app.buttons["Add to Reading List"].tap()
}

private func checkReadingListNumberOfItems(items: Int) {
waitforExistence(app.tables["ReadingTable"])
let list = app.tables["ReadingTable"].cells.count
XCTAssertEqual(list, UInt(items), "The number of items in the reading table is not correct")
}

func testAddToReadingList() {
// Initially reading list is empty
navigator.goto(HomePanel_ReadingList)
Expand All @@ -42,10 +48,7 @@ class ReaderViewTest: BaseTestCase {
XCTAssertFalse(app.buttons["HomePanels.ReadingList"].isEnabled)
XCTAssertTrue(app.buttons["HomePanels.Bookmarks"].isEnabled)

let readingtableTable = app.tables["ReadingTable"]
waitforExistence(readingtableTable)
let list = app.tables["ReadingTable"].cells.count
XCTAssertEqual(list, 0, "There should not be any entry in the reading table")
checkReadingListNumberOfItems(items: 0)

// Add item to reading list and check that it appears
addContentToReaderView()
Expand All @@ -55,9 +58,7 @@ class ReaderViewTest: BaseTestCase {
// Check that there is one item
let savedToReadingList = app.tables["ReadingTable"].cells.staticTexts["The Book of Mozilla"]
XCTAssertTrue(savedToReadingList.exists)
waitforExistence(app.tables["ReadingTable"])
let listAfter = app.tables["ReadingTable"].cells.count
XCTAssertEqual(listAfter, 1, "There should not be any entry in the reading table")
checkReadingListNumberOfItems(items: 1)
}

func testMarkAsReadAndUreadFromReaderView() {
Expand Down Expand Up @@ -85,11 +86,7 @@ class ReaderViewTest: BaseTestCase {
navigator.goto(HomePanel_ReadingList)
waitforExistence(app.buttons["HomePanels.ReadingList"])
navigator.goto(HomePanel_ReadingList)

let readingtableTable = app.tables["ReadingTable"]
waitforExistence(readingtableTable)
let list = app.tables["ReadingTable"].cells.count
XCTAssertEqual(list, 0, "There should not be any entry in the reading table")
checkReadingListNumberOfItems(items: 0)
}

func testMarkAsReadAndUnreadFromReadingList() {
Expand Down Expand Up @@ -125,9 +122,22 @@ class ReaderViewTest: BaseTestCase {
XCTAssertFalse(savedToReadingList.exists)

// Reader list view should be empty
let readingtableTable = app.tables["ReadingTable"]
waitforExistence(readingtableTable)
let list = app.tables["ReadingTable"].cells.count
XCTAssertEqual(list, 0, "There should not be any entry in the reading table")
checkReadingListNumberOfItems(items: 0)
}

func testAddToReadingListFromPageOptionsMenu() {
// First time Reading list is empty
navigator.goto(HomePanel_ReadingList)
checkReadingListNumberOfItems(items: 0)

// Add item to Reading List from Page Options Menu
navigator.goto(BrowserTab)
waitUntilPageLoad()
navigator.browserPerformAction(.addReadingListOption)

// Now there should be an item on the list
navigator.nowAt(BrowserTab)
navigator.browserPerformAction(.openReadingListOption)
checkReadingListNumberOfItems(items: 1)
}
}

0 comments on commit 4a48c9f

Please sign in to comment.