Add option for custom test host in Damus Purple developer settings

This commit adds a developer setting that allows the use of a custom
host for testing. This was added to allow testing on real devices
without the need for pushing changes into staging.

========
Testing
========

Test 1: Production not affected
-------------------------------

PASS

Device: iPhone 13 Mini
iOS: 17.3
Damus: This version
Steps:
1. Run app on a device logged into a real Damus Purple account
2. Scroll down the home feed. Make sure that other Purple members still show up with a star next to their profile. PASS
3. Go to the Damus Purple screen. Ensure that account info shows up and is correct. PASS
4. Ensure auto-translations appear. PASS

Test 2: Check custom test URL
-----------------------------

PASS

(Continued from test 1)
1. Run local damus-api and damus-website on the same computer
2. Change developer purple env setting to local test
3. Set the host url to the local IP address of the test server
4. Go through LN purchase flow. Ensure it works correctly. PASS

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Daniel D’Aquino
2024-02-08 01:25:36 +00:00
committed by William Casarin
parent aeafdccb02
commit da82663634
2 changed files with 95 additions and 15 deletions

View File

@@ -28,12 +28,41 @@ struct DeveloperSettingsView: View {
Toggle(NSLocalizedString("Enable experimental Purple API support", comment: "Developer mode setting to enable experimental Purple API support."), isOn: $settings.enable_experimental_purple_api)
.toggleStyle(.switch)
Picker(NSLocalizedString("Damus Purple environment", comment: "Prompt selection of the Damus purple environment (Developer feature to switch between real/production mode to test modes)."), selection: $settings.purple_enviroment) {
Picker(NSLocalizedString("Damus Purple environment", comment: "Prompt selection of the Damus purple environment (Developer feature to switch between real/production mode to test modes)."),
selection: Binding(
get: { () -> DamusPurpleEnvironment in
switch settings.purple_enviroment {
case .local_test(_):
return .local_test(host: nil) // Avoid errors related to a value which is not a valid picker option
default:
return settings.purple_enviroment
}
},
set: { new_value in
settings.purple_enviroment = new_value
}
)
) {
ForEach(DamusPurpleEnvironment.allCases, id: \.self) { purple_environment in
Text(purple_environment.text_description())
.tag(purple_environment.rawValue)
.tag(purple_environment.to_string())
}
}
if case .local_test(_) = settings.purple_enviroment {
TextField(
NSLocalizedString("URL", comment: "Custom URL host for Damus Purple testing"),
text: Binding.init(
get: {
return settings.purple_enviroment.custom_host() ?? ""
}, set: { new_host_value in
settings.purple_enviroment = .local_test(host: new_host_value)
}
)
)
.disableAutocorrection(true)
.autocapitalization(UITextAutocapitalizationType.none)
}
Toggle(NSLocalizedString("Enable experimental Purple In-app purchase support", comment: "Developer mode setting to enable experimental Purple In-app purchase support."), isOn: $settings.enable_experimental_purple_iap_support)
.toggleStyle(.switch)