Skip to content

Commit d780cd3

Browse files
committed
Add gui test to test framework
1 parent 023a51d commit d780cd3

File tree

1 file changed

+67
-7
lines changed
  • test/test-manager/src/tests

1 file changed

+67
-7
lines changed

test/test-manager/src/tests/ui.rs

+67-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use super::{config::TEST_CONFIG, helpers, Error, TestContext};
1+
use super::{
2+
config::TEST_CONFIG,
3+
helpers::{self, ensure_logged_in},
4+
Error, TestContext,
5+
};
26
use mullvad_management_interface::MullvadProxyClient;
37
use mullvad_relay_selector::query::builder::RelayQueryBuilder;
48
use std::{
@@ -125,7 +129,7 @@ pub async fn test_ui_login(_: TestContext, rpc: ServiceClient) -> Result<(), Err
125129
Ok(())
126130
}
127131

128-
#[test_function(priority = 1000, must_succeed = true)]
132+
#[test_function(priority = 1000)]
129133
async fn test_custom_access_methods_gui(
130134
_: TestContext,
131135
rpc: ServiceClient,
@@ -196,13 +200,69 @@ async fn test_custom_access_methods_gui(
196200

197201
assert!(ui_result.success());
198202

199-
// Reset the `api-override` feature.
200-
tokio::time::timeout(
201-
std::time::Duration::from_secs(60),
202-
rpc.set_daemon_environment(helpers::get_app_env()),
203+
Ok(())
204+
}
205+
206+
#[test_function(priority = 1000)]
207+
async fn test_custom_bridge_gui(
208+
_: TestContext,
209+
rpc: ServiceClient,
210+
mut mullvad_client: MullvadProxyClient,
211+
) -> Result<(), Error> {
212+
use mullvad_relay_selector::{RelaySelector, SelectorConfig};
213+
use talpid_types::net::proxy::CustomProxy;
214+
// For this test to work, we need to supply the following env-variables:
215+
//
216+
// * SHADOWSOCKS_SERVER_IP
217+
// * SHADOWSOCKS_SERVER_PORT
218+
// * SHADOWSOCKS_SERVER_CIPHER
219+
// * SHADOWSOCKS_SERVER_PASSWORD
220+
//
221+
// See `gui/test/e2e/installed/state-dependent/custom-bridge.spec.ts`
222+
// for details. The setup should be the same as in
223+
// `test_manager::tests::access_methods::test_shadowsocks`.
224+
//
225+
// # Note
226+
// The test requires the app to already be logged in.
227+
228+
ensure_logged_in(&mut mullvad_client)
229+
.await
230+
.expect("ensure_logged_in failed");
231+
232+
let gui_test = "custom-bridge.spec";
233+
let relay_list = mullvad_client.get_relay_locations().await.unwrap();
234+
let relay_selector = RelaySelector::from_list(SelectorConfig::default(), relay_list);
235+
let custom_proxy = relay_selector
236+
.get_bridge_forced()
237+
.and_then(|proxy| match proxy {
238+
CustomProxy::Shadowsocks(s) => Some(s),
239+
_ => None
240+
})
241+
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found none in relay list.");
242+
243+
let ui_result = run_test_env(
244+
&rpc,
245+
&[gui_test],
246+
[
247+
(
248+
"SHADOWSOCKS_SERVER_IP",
249+
custom_proxy.endpoint.ip().to_string().as_ref(),
250+
),
251+
(
252+
"SHADOWSOCKS_SERVER_PORT",
253+
custom_proxy.endpoint.port().to_string().as_ref(),
254+
),
255+
("SHADOWSOCKS_SERVER_CIPHER", custom_proxy.cipher.as_ref()),
256+
(
257+
"SHADOWSOCKS_SERVER_PASSWORD",
258+
custom_proxy.password.as_ref(),
259+
),
260+
],
203261
)
204262
.await
205-
.map_err(|_| Error::DaemonNotRunning)??;
263+
.unwrap();
264+
265+
assert!(ui_result.success());
206266

207267
Ok(())
208268
}

0 commit comments

Comments
 (0)