Skip to content
Merged
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions NormalUITests/BlockingUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,52 @@ final class BlockingUITests: XCTestCase {
)
}

func testTurningOffPreventAppDeleteNeedsAKey() {
let app = launch()
blockViaBypass(app)
let toggle = app.switches["home.preventDeleteToggle"]
requireValue("1", of: toggle, "Blocking should disable app deletion")

tapSwitch(toggle)
requireKeyWithoutBypass(app)
requireValue("0", of: toggle, "Passing the key should turn the toggle off")
}

func testBlockAdultWebsitesTurnsOnWithoutAKeyAndOffWithOne() {
let app = launch()
app.buttons["nav.settings"].tap()
let toggle = app.switches["settings.blockAdultContentToggle"]
require(toggle, "Settings should show the adult content toggle")
XCTAssertEqual(toggle.value as? String, "0", "Starts off")

tapSwitch(toggle)
let bypass = app.buttons["keySelect.blockWithoutKey"]
require(bypass, "Turning on should offer blocking without a key")
bypass.tap()
confirmBypass(app)
requireValue("1", of: toggle, "Bypass should turn the filter on")

tapSwitch(toggle)
requireKeyWithoutBypass(app)
requireValue("0", of: toggle, "Passing the key should turn the filter off")
}

private func tapSwitch(_ toggle: XCUIElement) {
toggle.coordinate(withNormalizedOffset: CGVector(dx: 0.92, dy: 0.5)).tap()
}

private func requireKeyWithoutBypass(_ app: XCUIApplication) {
let keyRow = app.buttons["keySelect.row.QR"]
require(keyRow, "Turning off should ask for a key")
XCTAssertFalse(app.buttons["keySelect.blockWithoutKey"].exists, "Turning off must not offer a bypass")
keyRow.tap()
}

private func requireValue(_ value: String, of element: XCUIElement, _ message: String) {
let expectation = XCTNSPredicateExpectation(predicate: NSPredicate(format: "value == %@", value), object: element)
XCTAssertEqual(XCTWaiter().wait(for: [expectation], timeout: timeout), .completed, message)
}

func testTimedUnblockBannerThenBlockNowReblocks() {
let app = launch()
blockViaBypass(app)
Expand Down
Loading