Skip to content
Open
Show file tree
Hide file tree
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: were these changes part of automatic linting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some warnings were flagging, tried resolving them.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import Foundation
import WireFoundation

Check warning on line 21 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift

View workflow job for this annotation

GitHub Actions / Test Results

Non-final class 'AuthenticationAPIV0' cannot conform to 'Sendable'; use '@unchecked Sendable'; this is an error in the Swift 6 language mode

Non-final class 'AuthenticationAPIV0' cannot conform to 'Sendable'; use '@unchecked Sendable'; this is an error in the Swift 6 language mode
class AuthenticationAPIV0: AuthenticationAPI, VersionedAPI {

Check warning on line 23 in WireNetwork/Sources/WireNetwork/APIs/Rest/AuthenticationAPI/AuthenticationAPIV0.swift

View workflow job for this annotation

GitHub Actions / Test Results

Stored property 'networkService' of 'Sendable'-conforming class 'AuthenticationAPIV0' has non-Sendable type 'any NetworkServiceProtocol'; this is an error in the Swift 6 language mode

Stored property 'networkService' of 'Sendable'-conforming class 'AuthenticationAPIV0' has non-Sendable type 'any NetworkServiceProtocol'; this is an error in the Swift 6 language mode
let networkService: any NetworkServiceProtocol

init(networkService: any NetworkServiceProtocol) {
Expand Down Expand Up @@ -213,8 +213,7 @@
let (data, response) = try await networkService.executeRequest(request)

guard
let responseURL = response.url,
let responseHeaders = response.allHeaderFields as? [String: String]
response.allHeaderFields is [String: String]
else {
throw AuthenticationAPIError.invalidResponse
}
Expand All @@ -239,7 +238,7 @@
.withBody(body, contentType: .json)
.build()

let (data, response) = try await networkService.executeRequest(request)
let (_, response) = try await networkService.executeRequest(request)

guard
let responseURL = response.url,
Expand Down Expand Up @@ -271,11 +270,12 @@
.withBody(body, contentType: .json)
.build()

let (data, response) = try await networkService.executeRequest(request)
let (_, response) = try await networkService.executeRequest(request)

try ResponseParser()
.success(code: .ok)
.failure(code: .badRequest, label: "bad-request", error: AuthenticationAPIError.invalidEmail)
.parse(code: response.statusCode, data: nil)
}

func requestEmailVerificationCode(for email: String) async throws {
Expand Down
3 changes: 3 additions & 0 deletions WireUI/Sources/WireSidebarUI/Views/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public struct SidebarView<AccountImageView: View, LegalHoldIndicatorView: View>:
let icon: String
var iconHighlighted: String?
let accessibilityLabel: Text
var accessibilityIdentifier: String?
switch menuItem {
case .all:
text = Text(Strings.ConversationFilter.All.title)
Expand Down Expand Up @@ -294,6 +295,7 @@ public struct SidebarView<AccountImageView: View, LegalHoldIndicatorView: View>:
text = Text(Strings.Settings.title)
icon = "gearshape"
accessibilityLabel = Text(Labels.Settings.description)
accessibilityIdentifier = "bottomBarSettingsButton"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: use locator instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be updated accordingly once upcoming Locators.swift will be merged

}

return SidebarMenuItemView(
Expand All @@ -306,6 +308,7 @@ public struct SidebarView<AccountImageView: View, LegalHoldIndicatorView: View>:
accessibilityLabel: { accessibilityLabel },
action: action
)
.accessibilityIdentifier(accessibilityIdentifier ?? "")
}

public typealias AccountImageSource = SidebarAccountInfo.AccountImageSource
Expand Down
4 changes: 2 additions & 2 deletions wire-ios/WireUITests/BackupRestoreHistoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class BackupRestoreHistoryTests: WireUITestCase {
let backupFileName = try XCTUnwrap(saveBackupFileBottomSheetPage.getBackupFileName())

_ = try saveBackupFileBottomSheetPage.tapSaveToFilesOnBottomSheet()
.tapSaveButtonOnMyiPhonePage()
.tapSaveButton()
.goBackToAccountPage()
.logout()
.enterPassword(teamOwner.password)
Expand Down Expand Up @@ -110,7 +110,7 @@ final class BackupRestoreHistoryTests: WireUITestCase {
_ = try setPasswordPage.acceptHistoryrestoredAlert()
.goBackToAccountPage()
.goBackToSettingsPage()
.switchToConversationsTab()
.switchToAllConversations()
.openConversation()

sentMessages = try XCTUnwrap(activeConversationPage.fetchMessages())
Expand Down
6 changes: 3 additions & 3 deletions wire-ios/WireUITests/Helper/UserHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class UserHelper {
email: user.email,
password: user.password
)
cookieStorage.cookies = cookies
try await cookieStorage.storeCookies(cookies)

// Get activation code
let (activationCode, activationKey) = try await authenticationAPI.getActivationCode(
Expand Down Expand Up @@ -306,8 +306,8 @@ enum FilterConversationsByCriteria {
case conversationType(ConversationType?)
}

private final class MockCookieStorage: CookieStorageProtocol {
var cookies: [HTTPCookie]
private actor MockCookieStorage: CookieStorageProtocol {
private var cookies: [HTTPCookie]

init() {
self.cookies = []
Expand Down
4 changes: 2 additions & 2 deletions wire-ios/WireUITests/MultiBackendSupportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class MultiBackendSupportTests: WireUITestCase {

_ = try accountPageBackend1
.backToSettings()
.switchToConversationsTab()
.switchToAllConversations()
.openUserAccountPageForUser(with: userBackend1.name)
.tapAddAccountOrTeamButton()

Expand All @@ -63,7 +63,7 @@ final class MultiBackendSupportTests: WireUITestCase {

accountPageBackend1 = try accountPageBackend2
.backToSettings()
.switchToConversationsTab()
.switchToAllConversations()
.openUserAccountPageForUser(with: userBackend2.name)
.switchUserAccountForUser(withName: userBackend1.name)
.openSettings()
Expand Down
3 changes: 3 additions & 0 deletions wire-ios/WireUITests/Pages/AccountSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class AccountSettingsPage: PageModel {
}

func goBackToSettingsPage() throws -> SettingsPage {
if app.iPadOnly() {
return try SettingsPage()
}
backToPreviousPage.tap()
return try SettingsPage()
}
Expand Down
10 changes: 9 additions & 1 deletion wire-ios/WireUITests/Pages/ActiveConversationPage .swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ class ActiveConversationPage: PageModel {
func sendMessage(_ message: String) throws -> ActiveConversationPage {
try inputMessageField.tapIfKeyboardNotFocused().typeText(message)
sendButton.tap()
// Revert this temporary workaround once WPB-17997 is fixed
// See: https://wearezeta.atlassian.net/browse/WPB-17997
let hideKeyboard = app.buttons["Hide keyboard"]
app.iPadOnly {
hideKeyboard.tap()
}
return self
}

func goBackToConversationPage() throws -> ConversationsPage {
conversationBackButton.tap()
if conversationBackButton.exists {
conversationBackButton.tap()
}
return try ConversationsPage()
}

Expand Down
21 changes: 19 additions & 2 deletions wire-ios/WireUITests/Pages/BackupOrRestorePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,34 @@ class BackupOrRestorePage: PageModel {
app.tabBars.buttons[Locators.BackupOrRestorePage.browse.rawValue].firstMatch
}

var moreButton: XCUIElement {
app.buttons["More"]
}

var sortByDateButton: XCUIElement {
app.buttons["Date"]
}

func tapBackupNow() throws -> SetPasswordPage {
backupNowButton.tap()
return try SetPasswordPage()
}

func tapRestoreFromBackupButton() throws -> OnMyiPhonePage {
func tapRestoreFromBackupButton() throws -> OnMyDevicePage {
restoreFromBackupButton.tap()
sortFiles()
return try OnMyDevicePage()
}

private func sortFiles() {
if app.iPadOnly() {
return
}
if !browseButtonOnBottom.isSelected {
browseButtonOnBottom.tap()
moreButton.tap()
sortByDateButton.tap()
}
return try OnMyiPhonePage()
}

func goBackToAccountPage() throws -> AccountSettingsPage {
Expand Down
52 changes: 43 additions & 9 deletions wire-ios/WireUITests/Pages/ConversationsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@

class ConversationsPage: PageModel {
override var pageMainElement: XCUIElement {
conversationsButton
}

var conversationsButton: XCUIElement {
app.buttons[Locators.ConversationsPage.bottomBarRecentListButton.rawValue]
plusButtonToCreateGroupOrSearch
}

var settingsButton: XCUIElement {
app.buttons[Locators.ConversationsPage.bottomBarSettingsButton.rawValue]
}

var plusButtonToCreateGroup: XCUIElement {
var plusButtonToCreateGroupOrSearch: XCUIElement {
app.descendants(matching: .any)[Locators.ConversationsPage.createGroupOrSearchButton.rawValue].firstMatch
}

Expand All @@ -56,12 +52,30 @@
app.buttons[Locators.ConnectionRequestsPage.connectRequestButton.rawValue]
}

var sidePanel: XCUIElement {
app.otherElements["PopoverDismissRegion"]
}

var sideBarPanel: XCUIElement {
app.buttons["ToggleSidebar"]
}

func openSettings() throws -> SettingsPage {
app.iPadOnly {
if self.sideBarPanel.exists {
self.sideBarPanel.tap()
}
}
settingsButton.tap()
return try SettingsPage()
}

Check warning on line 72 in wire-ios/WireUITests/Pages/ConversationsPage.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Remove trailing space at end of a line. (trailingSpace)

Check failure on line 72 in wire-ios/WireUITests/Pages/ConversationsPage.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
func openUserAccountPageForUser(with input: String) throws -> UserProfilePage {
app.iPadOnly {
if self.sideBarPanel.exists {
self.sideBarPanel.tap()
}
}
let predicate = NSPredicate(format: "value BEGINSWITH %@", input)
let button = app.buttons.containing(predicate).firstMatch
if button.waitForExistence(timeout: 2), button.isHittable {
Expand All @@ -71,11 +85,21 @@
}

func tapPlusButtonToCreateGroup() throws -> NewConversationPage {
plusButtonToCreateGroup.tap()
app.iPadOnly {
if self.sidePanel.exists {
self.sidePanel.tap()
}
}
plusButtonToCreateGroupOrSearch.tap()
return try NewConversationPage()
}

func openPendingRequest() throws -> ConnectionRequestsPage {
app.iPadOnly {
if self.sidePanel.exists {
self.sidePanel.tap()
}
}
XCTAssertTrue(conversationCell.waitForExistence(timeout: 5), "Conversation cell did not appear")

let maxDuration: TimeInterval = 10
Expand All @@ -91,6 +115,11 @@
}

func openConversation() throws -> ActiveConversationPage {
app.iPadOnly {
if self.sidePanel.exists {
self.sidePanel.tap()
}
}
XCTAssertTrue(conversationCell.waitForExistence(timeout: 5), "Conversation cell did not appear")

let maxDuration: TimeInterval = 10
Expand All @@ -117,6 +146,11 @@
}

func getNameLabel() -> String? {
conversationCell.label
app.iPadOnly {
if self.sidePanel.exists {
self.sidePanel.tap()
}
}
return conversationCell.label
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import WireLocators
import XCTest

class OnMyiPhonePage: PageModel {
class OnMyDevicePage: PageModel {

override var pageMainElement: XCUIElement {
onMyiPhonePageLabel
onMyDevicePageLabel
}

var onMyiPhonePageLabel: XCUIElement {
app.staticTexts[Locators.OnMyiPhonePage.onMyiPhoneLabel.rawValue]
var onMyDevicePageLabel: XCUIElement {
let expected = UIDevice.current.userInterfaceIdiom == .pad ? "On My iPad" : "On My iPhone"
return app.staticTexts[expected]
}

var saveButton: XCUIElement {
Expand All @@ -44,7 +45,7 @@ class OnMyiPhonePage: PageModel {
}
}

func tapSaveButtonOnMyiPhonePage() throws -> BackupOrRestorePage {
func tapSaveButton() throws -> BackupOrRestorePage {
saveButton.tap()
return try BackupOrRestorePage()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class SaveBackupFileBottomSheetPage: PageModel {
return element.exists ? element.label : nil
}

func tapSaveToFilesOnBottomSheet() throws -> OnMyiPhonePage {
func tapSaveToFilesOnBottomSheet() throws -> OnMyDevicePage {
saveToFilesOption.tap()
return try OnMyiPhonePage()
return try OnMyDevicePage()
}

}
24 changes: 22 additions & 2 deletions wire-ios/WireUITests/Pages/SettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class SettingsPage: PageModel {
app.buttons[Locators.ConversationsPage.bottomBarRecentListButton.rawValue]
}

var sideBarPanel: XCUIElement {
app.buttons["ToggleSidebar"]
}

var allConversations: XCUIElement {
app.buttons["All"]
}

func openAccountSettings() throws -> AccountSettingsPage {
accountSettingsMenu.tap()
return try AccountSettingsPage()
Expand All @@ -47,8 +55,20 @@ class SettingsPage: PageModel {
return try OptionsOnSettingsPage()
}

func switchToConversationsTab() throws -> ConversationsPage {
conversationsTab.tap()
func switchToAllConversations() throws -> ConversationsPage {
if conversationsTab.exists {
conversationsTab.tap()
} else {
app.iPadOnly { [self] in
if sideBarPanel.exists {
sideBarPanel.tap()
}

if allConversations.exists {
allConversations.tap()
}
}
}
return try ConversationsPage()
}
}
2 changes: 1 addition & 1 deletion wire-ios/WireUITests/PersonalUserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class PersonalUsersTests: WireUITestCase {

var accountSettingsPage = try activeConversationPage.goBackToConversationPage()
.longPressForMoreOptionOnConversation()
.blockUser()
.blockUser() // iPad crashes https://wearezeta.atlassian.net/browse/WPB-21169
.openSettings()
.openAccountSettings()

Expand Down
7 changes: 7 additions & 0 deletions wire-ios/WireUITests/XCUIApplication+Additions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ extension XCUIApplication {
.enterPassword(password)
.acceptFirstTimeAlert()
}

@discardableResult
func iPadOnly(_ block: (() -> Void)? = nil) -> Bool {
guard UIDevice.current.userInterfaceIdiom == .pad else { return false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, checking userInterfaceIdiom is not future proof, since we might allow the iPad app to be resized.
Then the iPad layout can collapse to the iPhone layout and if I'm not mistaken it will still be userInterfaceIdiom == .pad. Actually I will doublecheck this.

block?()
return true
}
}
Loading