mirror of https://github.com/oxen-io/session-ios
Fixed a silly message variant bug, unit test env var tweaks
• Added an env variable to enable the debug disappearing message durations • Moved the 'processUnitTestEnvVariablesIfNeeded' function into a separate file and added some docs (so we can just look at that file to see what is supported) • Fixed an issue where the deleted message artifact variant had incorrectly gotten it's value changed (too late to change it back so need a migration)pull/1061/head
parent
25f3e836ef
commit
828b25254a
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
//
|
||||||
|
// stringlint:disable
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
import SessionUtilitiesKit
|
||||||
|
|
||||||
|
// MARK: - Automated Test Convenience
|
||||||
|
|
||||||
|
extension DeveloperSettingsViewModel {
|
||||||
|
/// Processes and sets feature flags based on environment variables when running in the iOS simulator to allow extenrally
|
||||||
|
/// triggered automated tests to start in a specific state or with specific features enabled
|
||||||
|
///
|
||||||
|
/// In order to use these with Appium (a UI testing framework used internally) these settings can be added to the device
|
||||||
|
/// configuration as below, where the name of the value should match exactly to the `EnvironmentVariable` value
|
||||||
|
/// below and the value should match one of the options documented below
|
||||||
|
/// ```
|
||||||
|
/// const iOSCapabilities: AppiumXCUITestCapabilities = {
|
||||||
|
/// 'appium:processArguments': {
|
||||||
|
/// env: {
|
||||||
|
/// 'serviceNetwork': "testnet",
|
||||||
|
/// 'debugDisappearingMessageDurations': true
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
static func processUnitTestEnvVariablesIfNeeded(using dependencies: Dependencies) {
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
enum EnvironmentVariable: String {
|
||||||
|
/// Disables animations for the app (where possible)
|
||||||
|
///
|
||||||
|
/// **Value:** `true`/`false` (default: `true`)
|
||||||
|
case animationsEnabled
|
||||||
|
|
||||||
|
/// Controls whether the "keys" for strings should be displayed instead of their localized values
|
||||||
|
///
|
||||||
|
/// **Value:** `true`/`false` (default: `false`)
|
||||||
|
case showStringKeys
|
||||||
|
|
||||||
|
/// Controls whether the app communicates with mainnet or testnet by default
|
||||||
|
///
|
||||||
|
/// **Value:** `"mainnet"`/`"testnet"` (default: `"mainnet"`)
|
||||||
|
case serviceNetwork
|
||||||
|
|
||||||
|
/// Controls whether the app should trigger it's "Force Offline" behaviour (the network doesn't connect and all requests
|
||||||
|
/// fail after a 1 second delay with a serviceUnavailable error)
|
||||||
|
///
|
||||||
|
/// **Value:** `true`/`false` (default: `false`)
|
||||||
|
case forceOffline
|
||||||
|
|
||||||
|
/// Controls whether the app should offer the debug durations for disappearing messages (eg. `10s`, `30s`, etc.)
|
||||||
|
///
|
||||||
|
/// **Value:** `true`/`false` (default: `false`)
|
||||||
|
case debugDisappearingMessageDurations
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessInfo.processInfo.environment.forEach { key, value in
|
||||||
|
guard let variable: EnvironmentVariable = EnvironmentVariable(rawValue: key) else { return }
|
||||||
|
|
||||||
|
switch variable {
|
||||||
|
case .animationsEnabled:
|
||||||
|
dependencies.set(feature: .animationsEnabled, to: (value == "true"))
|
||||||
|
|
||||||
|
guard value == "false" else { return }
|
||||||
|
|
||||||
|
UIView.setAnimationsEnabled(false)
|
||||||
|
|
||||||
|
case .showStringKeys:
|
||||||
|
dependencies.set(feature: .showStringKeys, to: (value == "true"))
|
||||||
|
|
||||||
|
case .serviceNetwork:
|
||||||
|
let network: ServiceNetwork
|
||||||
|
|
||||||
|
switch value {
|
||||||
|
case "testnet": network = .testnet
|
||||||
|
default: network = .mainnet
|
||||||
|
}
|
||||||
|
|
||||||
|
DeveloperSettingsViewModel.updateServiceNetwork(to: network, using: dependencies)
|
||||||
|
|
||||||
|
case .forceOffline:
|
||||||
|
dependencies.set(feature: .forceOffline, to: (value == "true"))
|
||||||
|
|
||||||
|
case .debugDisappearingMessageDurations:
|
||||||
|
dependencies.set(feature: .debugDisappearingMessageDurations, to: (value == "true"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import GRDB
|
||||||
|
import SessionUtilitiesKit
|
||||||
|
|
||||||
|
/// There was a bug with internal releases of the Groups Rebuild feature where we incorrectly assigned an `Interaction.Variant`
|
||||||
|
/// value of `3` to deleted message artifacts when it should have been `2`, this migration updates any interactions with a value of `2`
|
||||||
|
/// to be `3`
|
||||||
|
enum _024_FixBustedInteractionVariant: Migration {
|
||||||
|
static let target: TargetMigrations.Identifier = .messagingKit
|
||||||
|
static let identifier: String = "FixBustedInteractionVariant"
|
||||||
|
static let minExpectedRunDuration: TimeInterval = 0.1
|
||||||
|
static var createdTables: [(FetchableRecord & TableRecord).Type] = []
|
||||||
|
|
||||||
|
static func migrate(_ db: Database, using dependencies: Dependencies) throws {
|
||||||
|
try db.execute(sql: """
|
||||||
|
UPDATE interaction
|
||||||
|
SET variant = \(Interaction.Variant.standardIncomingDeleted.rawValue)
|
||||||
|
WHERE variant = \(Interaction.Variant._legacyStandardIncomingDeleted.rawValue)
|
||||||
|
""")
|
||||||
|
|
||||||
|
Storage.update(progress: 1, for: self, in: target, using: dependencies)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue