mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-02-19 14:22:10 +00:00
Fix UI tests for screenshots (#1168)
Outdated after reworking the UI. Some fixes were also needed because: - [WireGuardModule requires a configuration](https://github.com/passepartoutvpn/passepartout/pull/1164) - [OpenVPNModule is interactive when no credentials are set](https://github.com/passepartoutvpn/passepartout/pull/1104) - Mock profile had a wrong category ("" → "default")
This commit is contained in:
parent
e4333965bd
commit
afee4037e2
@ -27,6 +27,7 @@ import CommonLibrary
|
||||
import Foundation
|
||||
import PassepartoutKit
|
||||
import TipKit
|
||||
import UIAccessibility
|
||||
@_exported import UILibrary
|
||||
|
||||
public final class AppUIMain: UILibraryConfiguring {
|
||||
@ -40,6 +41,9 @@ public final class AppUIMain: UILibraryConfiguring {
|
||||
|
||||
// for debugging
|
||||
// Tips.showAllTipsForTesting()
|
||||
if AppCommandLine.contains(.uiTesting) {
|
||||
Tips.hideAllTipsForTesting()
|
||||
}
|
||||
|
||||
try? Tips.configure([
|
||||
.displayFrequency(.immediate)
|
||||
|
@ -50,7 +50,6 @@ struct InstalledProfileView: View, Routable {
|
||||
debugChanges()
|
||||
return HStack(alignment: .center) {
|
||||
cardView
|
||||
.uiAccessibility(.App.installedProfile)
|
||||
Spacer()
|
||||
toggleButton
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ struct ProfileCardView: View {
|
||||
.font(.headline)
|
||||
.themeMultiLine(true)
|
||||
}
|
||||
.uiAccessibility(.App.profileEdit)
|
||||
|
||||
tunnelView
|
||||
.font(.subheadline)
|
||||
|
||||
|
@ -73,9 +73,6 @@ private extension ProfileRowView {
|
||||
)
|
||||
.contentShape(.rect)
|
||||
.foregroundStyle(.primary)
|
||||
|
||||
// FIXME: ###, UI tests
|
||||
.uiAccessibility(.App.profileMenu)
|
||||
}
|
||||
|
||||
var attributesView: some View {
|
||||
@ -94,7 +91,6 @@ private extension ProfileRowView {
|
||||
flow: flow?.connectionFlow
|
||||
)
|
||||
.labelsHidden()
|
||||
// FIXME: ###, UI tests
|
||||
.uiAccessibility(.App.profileToggle)
|
||||
}
|
||||
}
|
||||
|
@ -39,5 +39,6 @@ struct ProfilesHeaderView: View {
|
||||
Text(Strings.Views.Verification.message)
|
||||
}
|
||||
}
|
||||
.uiAccessibility(.App.profilesHeader)
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ extension OpenVPNModule.Builder: ModuleShortcutsProviding {
|
||||
NavigationLink(value: OpenVPNView.Subroute.providerServer) {
|
||||
ProviderServerRow(selectedEntity: providerSelection.entity)
|
||||
}
|
||||
.uiAccessibility(.Profile.providerServerLink)
|
||||
}
|
||||
if providerSelection != nil || configurationBuilder?.authUserPass == true {
|
||||
NavigationLink(value: OpenVPNView.Subroute.credentials) {
|
||||
|
@ -86,7 +86,7 @@ private extension ActiveProfileView {
|
||||
.font(.title)
|
||||
.fontWeight(theme.relevantWeight)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.uiAccessibility(.App.installedProfile)
|
||||
.uiAccessibility(.App.profilesHeader)
|
||||
}
|
||||
|
||||
var statusView: some View {
|
||||
|
@ -36,6 +36,8 @@ public struct AccessibilityInfo: Equatable, Sendable {
|
||||
case menuItem
|
||||
|
||||
case text
|
||||
|
||||
case toggle
|
||||
}
|
||||
|
||||
public let id: String
|
||||
|
@ -37,10 +37,10 @@ extension AccessibilityInfo {
|
||||
public static let profile = AccessibilityInfo("app.profileList.profile", .button)
|
||||
}
|
||||
|
||||
public static let installedProfile = AccessibilityInfo("app.installedProfile", .text)
|
||||
public static let profilesHeader = AccessibilityInfo("app.profilesHeader", .text)
|
||||
|
||||
public static let profileToggle = AccessibilityInfo("app.profileToggle", .button)
|
||||
public static let profileToggle = AccessibilityInfo("app.profileToggle", .toggle)
|
||||
|
||||
public static let profileMenu = AccessibilityInfo("app.profileMenu", .menu)
|
||||
public static let profileEdit = AccessibilityInfo("app.profileEdit", .button)
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ extension AccessibilityInfo {
|
||||
|
||||
public static let moduleLink = AccessibilityInfo("profile.moduleLink", .link)
|
||||
|
||||
public static let providerServerLink = AccessibilityInfo("profile.providerServerLink", .link)
|
||||
|
||||
public static let cancel = AccessibilityInfo("profile.cancel", .button)
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,9 @@
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<AutocreatedTestPlanReference>
|
||||
</AutocreatedTestPlanReference>
|
||||
<TestPlanReference
|
||||
reference = "container:Passepartout/UITests/TVScreenshots.xctestplan">
|
||||
</TestPlanReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
@ -25,7 +26,8 @@
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<TestPlans>
|
||||
<TestPlanReference
|
||||
reference = "container:Passepartout/UITests/TVScreenshots.xctestplan">
|
||||
reference = "container:Passepartout/UITests/TVScreenshots.xctestplan"
|
||||
default = "YES">
|
||||
</TestPlanReference>
|
||||
<TestPlanReference
|
||||
reference = "container:Passepartout/UITests/MainScreenshots.xctestplan">
|
||||
|
@ -56,6 +56,7 @@ extension ProfileManager {
|
||||
ovpnBuilder.isInteractive = true
|
||||
#endif
|
||||
ovpnBuilder.providerEntity = mockHideMeEntity
|
||||
ovpnBuilder.credentials = OpenVPN.Credentials.Builder(username: "foo", password: "bar").build()
|
||||
moduleBuilder = ovpnBuilder
|
||||
} else if var onDemandBuilder = moduleBuilder as? OnDemandModule.Builder {
|
||||
#if !os(tvOS)
|
||||
@ -93,6 +94,11 @@ extension ProfileManager {
|
||||
}
|
||||
}
|
||||
|
||||
if var wgBuilder = moduleBuilder as? WireGuardModule.Builder {
|
||||
wgBuilder.configurationBuilder = WireGuard.Configuration.Builder(privateKey: "")
|
||||
moduleBuilder = wgBuilder
|
||||
}
|
||||
|
||||
let module = try moduleBuilder.tryBuild()
|
||||
builder.modules.append(module)
|
||||
}
|
||||
@ -163,7 +169,7 @@ private extension ProfileManager {
|
||||
serverId: "be-v4",
|
||||
supportedConfigurationIdentifiers: ["OpenVPN"],
|
||||
supportedPresetIds: nil,
|
||||
categoryName: "",
|
||||
categoryName: "default",
|
||||
countryCode: "BE",
|
||||
otherCountryCodes: nil,
|
||||
area: nil
|
||||
|
@ -48,6 +48,8 @@ private extension XCUIElement {
|
||||
return buttons
|
||||
case .text:
|
||||
return staticTexts
|
||||
case .toggle:
|
||||
return switches
|
||||
}
|
||||
#else
|
||||
switch elementType {
|
||||
@ -59,6 +61,8 @@ private extension XCUIElement {
|
||||
return menuItems
|
||||
case .text:
|
||||
return staticTexts
|
||||
case .toggle:
|
||||
return checkBoxes
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -47,33 +47,23 @@ final class MainFlowTests: XCTestCase {
|
||||
func testEditProfile() {
|
||||
AppScreen(app: app)
|
||||
.waitForProfiles()
|
||||
.openProfileMenu(at: 2)
|
||||
.editProfile()
|
||||
.editProfile(at: 2)
|
||||
}
|
||||
|
||||
func testEditProfileModule() {
|
||||
AppScreen(app: app)
|
||||
.waitForProfiles()
|
||||
.openProfileMenu(at: 2)
|
||||
.editProfile()
|
||||
.editProfile(at: 2)
|
||||
.enterModule(at: 1)
|
||||
.leaveModule()
|
||||
}
|
||||
|
||||
func testConnectToProviderServer() {
|
||||
AppScreen(app: app)
|
||||
.waitForProfiles()
|
||||
.openProfileMenu(at: 2)
|
||||
.connectToProfile()
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
func testDiscloseProviderCountry() {
|
||||
AppScreen(app: app)
|
||||
.waitForProfiles()
|
||||
.openProfileMenu(at: 2)
|
||||
.connectToProfile()
|
||||
.discloseCountry(at: 2)
|
||||
.editProfile(at: 2)
|
||||
.editProviderServer()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -48,11 +48,10 @@ final class MainScreenshotTests: XCTestCase, XCUIApplicationProviding {
|
||||
func testTakeScreenshots() async throws {
|
||||
let root = AppScreen(app: app)
|
||||
.waitForProfiles()
|
||||
.enableProfile(at: 0)
|
||||
.enableProfile(at: 1)
|
||||
|
||||
let profile = root
|
||||
.openProfileMenu(at: 2)
|
||||
.editProfile()
|
||||
.editProfile(at: 2)
|
||||
|
||||
await pause()
|
||||
try snapshot("03", "ProfileEditor", target: .sheet)
|
||||
@ -78,8 +77,8 @@ final class MainScreenshotTests: XCTestCase, XCUIApplicationProviding {
|
||||
try snapshot("01", "Connected")
|
||||
|
||||
app
|
||||
.openProfileMenu(at: 2)
|
||||
.connectToProfile()
|
||||
.editProfile(at: 2)
|
||||
.editProviderServer()
|
||||
#if os(iOS)
|
||||
.discloseCountry(at: 2)
|
||||
#endif
|
||||
|
@ -33,7 +33,7 @@ struct AppScreen {
|
||||
|
||||
@discardableResult
|
||||
func waitForProfiles() -> Self {
|
||||
app.get(.App.installedProfile)
|
||||
app.get(.App.profilesHeader)
|
||||
return self
|
||||
}
|
||||
|
||||
@ -45,9 +45,9 @@ struct AppScreen {
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func openProfileMenu(at index: Int) -> ProfileMenuScreen {
|
||||
let profileMenu = app.get(.App.profileMenu, at: index)
|
||||
func editProfile(at index: Int) -> ProfileEditorScreen {
|
||||
let profileMenu = app.get(.App.profileEdit, at: index)
|
||||
profileMenu.tap()
|
||||
return ProfileMenuScreen(app: app)
|
||||
return ProfileEditorScreen(app: app)
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ struct ProfileEditorScreen {
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func editProviderServer() -> ProviderServersScreen {
|
||||
let providerServerLink = app.get(.Profile.providerServerLink)
|
||||
providerServerLink.tap()
|
||||
return ProviderServersScreen(app: app)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func closeProfile() -> AppScreen {
|
||||
let cancelButton = app.get(.Profile.cancel)
|
||||
|
@ -35,7 +35,7 @@ struct AppScreen {
|
||||
|
||||
@discardableResult
|
||||
func waitForProfiles() -> Self {
|
||||
app.get(.App.installedProfile)
|
||||
app.get(.App.profilesHeader)
|
||||
return self
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user