Skip to content

Commit

Permalink
Improve strategy for waiting for an item to disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsimeon authored and Jacob Morris committed Jan 28, 2022
1 parent c907745 commit d409bd3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Pocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/* Begin PBXBuildFile section */
160056F326CC7FFD00700A80 /* FavoriteAnItemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 160056F226CC7FFD00700A80 /* FavoriteAnItemTests.swift */; };
1605237E27A4627F00E09FD2 /* XCTestCase+extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1605237D27A4627F00E09FD2 /* XCTestCase+extensions.swift */; };
1606F21B26EBC1A200238111 /* HomeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1606F21A26EBC1A200238111 /* HomeTests.swift */; };
1612D7E426C32321009A5BFD /* ByteBuffer+read.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1612D7E326C32321009A5BFD /* ByteBuffer+read.swift */; };
1613B2B12755696B0014F301 /* SignOutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1613B2B02755696B0014F301 /* SignOutTests.swift */; };
Expand Down Expand Up @@ -87,6 +88,7 @@

/* Begin PBXFileReference section */
160056F226CC7FFD00700A80 /* FavoriteAnItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteAnItemTests.swift; sourceTree = "<group>"; };
1605237D27A4627F00E09FD2 /* XCTestCase+extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+extensions.swift"; sourceTree = "<group>"; };
1606F21A26EBC1A200238111 /* HomeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTests.swift; sourceTree = "<group>"; };
1612D7E326C32321009A5BFD /* ByteBuffer+read.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ByteBuffer+read.swift"; sourceTree = "<group>"; };
1613B2B02755696B0014F301 /* SignOutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignOutTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -214,6 +216,7 @@
F2A5B6B5271E03C400FB8BF2 /* LaunchEnvironment.swift */,
16E4B16C27A31BEC00E01746 /* RequestMatchers.swift */,
16E4B16E27A3212900E01746 /* Response+factories.swift */,
1605237D27A4627F00E09FD2 /* XCTestCase+extensions.swift */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -412,6 +415,7 @@
166BAD0D2656E76B00E401F0 /* PocketAppElement.swift in Sources */,
164FB66E278F7ECC002959D6 /* MyListFiltersTests.swift in Sources */,
F2843C1E2714D18200E03ED5 /* ReportARecommendationTests.swift in Sources */,
1605237E27A4627F00E09FD2 /* XCTestCase+extensions.swift in Sources */,
1648D5A727024C6400F67C4B /* SlateDetailElement.swift in Sources */,
166BAD0B2656E76B00E401F0 /* ReaderElement.swift in Sources */,
166F8F2726D0488900F898E3 /* XCUIElement+wait.swift in Sources */,
Expand Down
8 changes: 3 additions & 5 deletions Tests iOS/ArchiveAnItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ class ArchiveAnItemTests: XCTestCase {
}

app.archiveButton.wait().tap()
XCTAssertFalse(itemCell.exists)

wait(for: [expectRequest], timeout: 1)
waitForDisappearance(of: itemCell)
}

func test_archivingAnItemFromReader_archivesItem_andPopsBackToList() {
Expand Down Expand Up @@ -95,9 +94,8 @@ class ArchiveAnItemTests: XCTestCase {

app.archiveButton.wait().tap()

listView.wait()
XCTAssertFalse(itemCell.exists)

wait(for: [expectRequest], timeout: 1)
listView.wait()
waitForDisappearance(of: itemCell)
}
}
5 changes: 2 additions & 3 deletions Tests iOS/DeleteAnItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ class DeleteAnItemTests: XCTestCase {

app.deleteButton.wait().tap()
app.alert.yes.wait().tap()
XCTAssertFalse(itemCell.exists)

wait(for: [expectRequest], timeout: 1)
waitForDisappearance(of: itemCell)
}

func test_deletingAnItemFromReader_deletesItem_andPopsBackToList() {
Expand Down Expand Up @@ -103,6 +102,6 @@ class DeleteAnItemTests: XCTestCase {
wait(for: [expectRequest], timeout: 1)

app.myListView.wait()
XCTAssertFalse(itemCell.exists)
waitForDisappearance(of: itemCell)
}
}
13 changes: 13 additions & 0 deletions Tests iOS/Support/XCTestCase+extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import XCTest

extension XCTestCase {
func waitForDisappearance(of element: XCUIElement) {
let doesNotExist = NSPredicate(format: "exists == 0")
let elementToNotExist = expectation(for: doesNotExist, evaluatedWith: element)
wait(for: [elementToNotExist], timeout: 3)
}

func waitForDisappearance(of element: PocketUIElement) {
waitForDisappearance(of: element.element)
}
}

0 comments on commit d409bd3

Please sign in to comment.