Reorganize docs and update reader search flows
This commit is contained in:
@@ -56,23 +56,30 @@ final class BookmarkTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testBookmarksPanelIsAccessible() {
|
||||
app.launchAndOpenSampleBook()
|
||||
// 不重置状态,利用已有的持久化书签来测试面板
|
||||
app.launchAndOpenSampleBook(resetsReaderState: false)
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let bookmarkButton = app.buttons[IDs.readerBookmark]
|
||||
XCTAssertTrue(bookmarkButton.waitForExistence(timeout: 5), "书签按钮未出现")
|
||||
bookmarkButton.tap()
|
||||
// 如果没有书签,先添加一个
|
||||
let state = app.currentDemoReaderState()
|
||||
if state?.bookmarks == 0 || state?.bookmarks == nil {
|
||||
let bookmarkButton = app.buttons[IDs.readerBookmark]
|
||||
if bookmarkButton.waitForExistence(timeout: 5) {
|
||||
bookmarkButton.tap()
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(1.5))
|
||||
}
|
||||
}
|
||||
|
||||
app.showReaderChromeIfNeeded()
|
||||
let bookmarksListButton = app.buttons[IDs.readerBookmarks]
|
||||
XCTAssertTrue(bookmarksListButton.waitForExistence(timeout: 5), "书签列表按钮未出现")
|
||||
|
||||
// 等待按钮变为可用(有书签时)
|
||||
let enabledPredicate = NSPredicate(format: "isEnabled == true")
|
||||
expectation(for: enabledPredicate, evaluatedWith: bookmarksListButton)
|
||||
waitForExpectations(timeout: 10)
|
||||
|
||||
XCTAssertTrue(bookmarksListButton.isEnabled, "书签列表按钮未启用")
|
||||
bookmarksListButton.tap()
|
||||
|
||||
let bookmarksPanel = app.tables[IDs.readerBookmarksTable]
|
||||
|
||||
@@ -18,8 +18,8 @@ final class ReaderAnnotationTests: XCTestCase {
|
||||
|
||||
app.waitForReaderState(containing: "toolbar=hidden", timeout: 5)
|
||||
|
||||
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.45))
|
||||
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.68, dy: 0.45))
|
||||
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.2, dy: 0.5))
|
||||
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.8, dy: 0.5))
|
||||
start.press(forDuration: 0.8, thenDragTo: end)
|
||||
|
||||
app.waitForReaderState(containing: "selection=1", timeout: 5)
|
||||
@@ -48,8 +48,8 @@ final class ReaderAnnotationTests: XCTestCase {
|
||||
|
||||
app.waitForReaderState(containing: "toolbar=hidden", timeout: 5)
|
||||
|
||||
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.45))
|
||||
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.68, dy: 0.45))
|
||||
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.2, dy: 0.5))
|
||||
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.8, dy: 0.5))
|
||||
start.press(forDuration: 0.8, thenDragTo: end)
|
||||
|
||||
app.waitForReaderState(containing: "selection=1", timeout: 8)
|
||||
|
||||
@@ -67,6 +67,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchFindsMatchesAndShowsCount() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10), "匹配计数标签应出现")
|
||||
@@ -83,6 +84,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchNavigatesToFirstMatch() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10), "匹配计数应出现")
|
||||
@@ -94,6 +96,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchNextButtonAdvancesMatch() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10))
|
||||
@@ -109,6 +112,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchPreviousButtonGoesBack() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10))
|
||||
@@ -129,6 +133,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchNextWrapsAround() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10))
|
||||
@@ -158,6 +163,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchWithNoResultsShowsZeroCount() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "xyzzy_nonexistent_keyword_12345")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10), "计数标签应出现")
|
||||
@@ -167,6 +173,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchNavigationDisabledWhenNoResults() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "xyzzy_nonexistent_keyword_12345")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10))
|
||||
@@ -185,6 +192,7 @@ final class SearchTests: XCTestCase {
|
||||
func testCloseSearchClearsState() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let countLabel = app.staticTexts[IDs.searchCount]
|
||||
XCTAssertTrue(countLabel.waitForExistence(timeout: 10))
|
||||
@@ -206,6 +214,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchBarHidesWhenToolbarsHide() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let searchBar = app.otherElements[IDs.searchBar]
|
||||
XCTAssertTrue(searchBar.waitForExistence(timeout: 10), "搜索栏应可见")
|
||||
@@ -219,6 +228,7 @@ final class SearchTests: XCTestCase {
|
||||
func testSearchBarRestoresWhenToolbarsShow() {
|
||||
app.launchAndOpenSampleBook(searchKeyword: "的")
|
||||
app.waitForReader()
|
||||
app.showReaderChromeIfNeeded()
|
||||
|
||||
let searchBar = app.otherElements[IDs.searchBar]
|
||||
XCTAssertTrue(searchBar.waitForExistence(timeout: 10))
|
||||
|
||||
Reference in New Issue
Block a user