Introduce a StartChatFlowCoordinator instead of handing a navigation stack to the Screen Coordinator. (#4674)

* Introduce a basic StartChatFlowCoordinator.

* Move the rest of the start chat flow from the screen coordinator into the flow coordinator.

* Add a UI test for the entire start chat flow.

* Refactor CreateRoom… to CreateRoomScreen…
This commit is contained in:
Doug
2025-10-30 16:12:56 +00:00
committed by GitHub
parent 1e124792de
commit b3d4ed0274
68 changed files with 764 additions and 789 deletions

View File

@@ -1,33 +0,0 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import XCTest
@MainActor
class CreateRoomScreenUITests: XCTestCase {
func testLanding() async throws {
let app = Application.launch(.createRoom)
try await app.assertScreenshot()
}
func testLandingWithoutUsers() async throws {
let app = Application.launch(.createRoomNoUsers)
try await app.assertScreenshot()
}
func testLongInputNameText() async throws {
let app = Application.launch(.createRoom)
// typeText sometimes misses letters but it's faster than typing one letter at a time
// repeat the same letter enough times to avoid that but also to work on iPads
app.textFields[A11yIdentifiers.createRoomScreen.roomName].tap()
app.textFields[A11yIdentifiers.createRoomScreen.roomName].typeText(.init(repeating: "x", count: 200))
app.textFields[A11yIdentifiers.createRoomScreen.roomName].typeText("\n")
try await app.assertScreenshot()
}
}

View File

@@ -1,34 +0,0 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import XCTest
@MainActor
class StartChatScreenUITests: XCTestCase {
func testLanding() async throws {
let app = Application.launch(.startChat)
try await app.assertScreenshot()
}
func testSearchWithNoResults() async throws {
let app = Application.launch(.startChat)
let searchField = app.searchFields.firstMatch
searchField.clearAndTypeText("None\n", app: app)
XCTAssert(app.staticTexts[A11yIdentifiers.startChatScreen.searchNoResults].waitForExistence(timeout: 1.0))
try await app.assertScreenshot()
}
func testSearchWithResults() async throws {
let app = Application.launch(.startChatWithSearchResults)
let searchField = app.searchFields.firstMatch
searchField.clearAndTypeText("Bob\n", app: app)
XCTAssertFalse(app.staticTexts[A11yIdentifiers.startChatScreen.searchNoResults].waitForExistence(timeout: 1.0))
XCTAssertEqual(app.collectionViews.firstMatch.cells.count, 2)
try await app.assertScreenshot()
}
}

View File

@@ -0,0 +1,73 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import XCTest
@MainActor
class StartChatTests: XCTestCase {
enum Step {
static let startChat = 1
static let startChatWithResults = 2
static let createRoom = 3
static let createRoomAvatarPicker = 4
static let createRoomFilled = 5
static let inviteUsers = 6
static let inviteUsersWithResults = 7
static let inviteUsersSelectedResults = 8
static let dismissed = 99
}
func testFlow() async throws {
let app = Application.launch(.startChatFlow)
try await app.assertScreenshot(step: Step.startChat)
let startChatSearchField = app.searchFields.firstMatch
startChatSearchField.clearAndTypeText("Bob\n", app: app)
XCTAssertFalse(app.staticTexts[A11yIdentifiers.startChatScreen.searchNoResults].waitForExistence(timeout: 1.0))
XCTAssertEqual(app.collectionViews.firstMatch.cells.count, 2)
try await app.assertScreenshot(step: Step.startChatWithResults)
startChatSearchField.clearAndTypeText("\n", app: app)
app.buttons[A11yIdentifiers.startChatScreen.createRoom].firstMatch.tap()
XCTAssertTrue(app.textFields[A11yIdentifiers.createRoomScreen.roomName].waitForExistence(timeout: 1.0))
try await app.assertScreenshot(step: Step.createRoom)
app.buttons[A11yIdentifiers.createRoomScreen.roomAvatar].tap()
app.popovers.buttons.element(boundBy: 2).tap() // There are 2 buttons with the accessibility identifier, so use the index to get the right one.
let cancelButton = app.buttons["Cancel"]
XCTAssertTrue(cancelButton.waitForExistence(timeout: 1.0))
try await app.assertScreenshot(step: Step.createRoomAvatarPicker)
cancelButton.tap()
// typeText sometimes misses letters but it's faster than typing one letter at a time
// repeat the same letter enough times to avoid that but also to work on iPads
app.textFields[A11yIdentifiers.createRoomScreen.roomName].tap()
app.textFields[A11yIdentifiers.createRoomScreen.roomName].typeText(.init(repeating: "x", count: 200))
app.textFields[A11yIdentifiers.createRoomScreen.roomName].typeText("\n")
try await app.assertScreenshot(step: Step.createRoomFilled)
app.buttons[A11yIdentifiers.createRoomScreen.create].tap()
XCTAssertTrue(app.buttons[A11yIdentifiers.inviteUsersScreen.proceed].waitForExistence(timeout: 1.0))
try await app.assertScreenshot(step: Step.inviteUsers)
let inviteUsersSearchField = app.searchFields.firstMatch
inviteUsersSearchField.clearAndTypeText("Bob\n", app: app)
let cells = app.collectionViews.firstMatch.cells
XCTAssertEqual(cells.count, 2)
try await app.assertScreenshot(step: Step.inviteUsersWithResults)
cells.element(boundBy: 0).tap()
// Selecting the first member has inserted the horizontal collection view above the list.
// So to select the second member we now need to increment the index by 2 instead of 1.
cells.element(boundBy: 2).tap()
try await app.assertScreenshot(step: Step.inviteUsersSelectedResults)
app.buttons[A11yIdentifiers.inviteUsersScreen.proceed].tap()
try await app.assertScreenshot(step: Step.dismissed)
}
}

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71edb284338fe1a3d118141aa237617536b72a31d13333e7148dd2d33ccff1b1
size 152332

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9c6fcc3f0eea9bb87f6b5fa2c5b652496ca44eee846d3231e4c1446a1a3da2e3
size 188761

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c7a86c8bd9795786c49bace089439a3e8e0677bae255eba332b2175e89ab3f2b
size 131545

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:660beea7152721b0ba27876b1f7d9e34035c21abc188c3ab3953552655041dca
size 160050

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2e8ebe176c64660475fdb46016a66ddaa502d30d1c60f6ccc4a52c05ca5412ed
size 149193

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4afad7f48503b599fb30a0e4c593079249d6c70f64770d53ce63398a89d245af
size 183810

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a1f07788317f9ed52b340b6e3233d50be4f82a047e6233d6abc656c6e1ba0c65
size 167782

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9543933266405ba35494e5bac5e1b403b0f388657b36b1689a3f27834dd27133
size 164831

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5201d5b8492dadaa23efd16a5e74ca96e23ce972abe4cd76a20533246a9381af
size 198236

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d0f8aff85f5930db29bc103b67ae2ea3bd793e6da755b74b3ec4bc3294a24664
size 2332509

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:be0bc089efe8628afef744ec9e171a1d3f54b5ac81f3515369a58237c553da0a
size 196815

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:02b9e0a8a3ae860c6afe7541021ec11529fb810f13ed7468ed4fbb87d7277e3e
size 147056

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6e2ec6a46ee642ad8235dc6cb777330bdeb8a240138409fa88fa9d1f3cc7516b
size 166249

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:abe91d1332e9da181baa07576006a411ad36aa23dcd664341f9c1cf1e28c4a57
size 175690

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:10eb8f7c10d0eb6a493c33fc223a96276897f5a8db969d7e07694c9872b47485
size 122115

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5bebd60c5ddaaf7d4af54563587c51f44816ac8fe5a621632a14374ca639b66b
size 114369

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f6a481a1eebb2bdc2a51b69da7867d330fd15b465ec66dda9a7775ea81bebc27
size 170910

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c0f51cb1e35bb75ae45f2f909e45f809febe00c86f7b7d88e63e9cdfb322043b
size 2458946

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ab217745f60435fc6251221d5650a25e4ce00153cf78ed72021e05c666d19703
size 166171

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7899f024d4aa043b2e318ef188bb992301aa02bc4a92fd5b59215e907272bde2
size 88945

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b788bbcc940303b16942de95cfcbb142e04ecc60634e409f091a20cf3fe8cef1
size 116322

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:125138db4c413fa5ffc104694cb5400373d86faee69d0c755e2ffe992211f0ab
size 128890

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d3e4caed4cef8b0ad70f747bb98a7e205c0b4f1c3df6083f341a9ac5bebe6e31
size 108047

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:63a31b32e399472a8206f234665a11bb929403b5902856b85cd4f19373d0fd0a
size 120156

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3156d4c72c601cfbe7584cd73f516a4a32a95e6149dbd7ef31fdd4bba7d14fbf
size 88278

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8744cb36bbdd2afb7809f2682e00d6a3f2d1f3e2e6dfa329a50e97c76d8e9e63
size 90212

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b97677b7315b1d9298468da64358299ef0674644d3042fe23d9e10396131c92a
size 101718

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dd670a1f21b71bf5ddc7d317054145c2a049eb16fa09d6cd6f8be589d5ec45e9
size 112321