sdk: Rewrap strings in widget tests

This commit is contained in:
Jonas Platte
2023-10-12 17:39:08 +02:00
committed by Jonas Platte
parent a6a4695dd4
commit bc0e3609d0
2 changed files with 59 additions and 20 deletions
+36 -9
View File
@@ -231,7 +231,25 @@ mod tests {
#[test]
fn new_virtual_element_call_widget_raw_url() {
const CONVERTED_URL:&str= "https://call.element.io/room#?userId=$matrix_user_id&roomId=$matrix_room_id&widgetId=$matrix_widget_id&avatarUrl=$matrix_avatar_url&displayname=$matrix_display_name&lang=$org.matrix.msc2873.client_language&theme=$org.matrix.msc2873.client_theme&clientId=$org.matrix.msc2873.client_id&deviceId=$org.matrix.msc2873.matrix_device_id&baseUrl=$org.matrix.msc4039.matrix_base_url&parentUrl=https%3A%2F%2Fcall.element.io&skipLobby=false&confineToRoom=true&appPrompt=true&hideHeader=true&preload=true";
const CONVERTED_URL: &str = "
https://call.element.io/room#\
?userId=$matrix_user_id\
&roomId=$matrix_room_id\
&widgetId=$matrix_widget_id\
&avatarUrl=$matrix_avatar_url\
&displayname=$matrix_display_name\
&lang=$org.matrix.msc2873.client_language\
&theme=$org.matrix.msc2873.client_theme\
&clientId=$org.matrix.msc2873.client_id\
&deviceId=$org.matrix.msc2873.matrix_device_id\
&baseUrl=$org.matrix.msc4039.matrix_base_url\
&parentUrl=https%3A%2F%2Fcall.element.io\
&skipLobby=false\
&confineToRoom=true\
&appPrompt=true\
&hideHeader=true\
&preload=true\
";
let mut url = get_widget_settings().raw_url().clone();
let mut gen = Url::parse(CONVERTED_URL).unwrap();
@@ -250,14 +268,23 @@ mod tests {
#[test]
fn new_virtual_element_call_widget_webview_url() {
const CONVERTED_URL: &str = "https://call.element.io/room#?\
parentUrl=https%3A%2F%2Fcall.element.io&widgetId=1/@#w23\
&userId=%40test%3Auser.org&deviceId=ABCDEFG&roomId=%21room_id%3Aroom.org\
&lang=en-US&theme=light\
&baseUrl=https%3A%2F%2Fclient-matrix.server.org%2F&hideHeader=true\
&preload=true&skipLobby=false&confineToRoom=true&\
displayname=hello&avatarUrl=some-url\
&appPrompt=true&clientId=io.my_matrix.client";
const CONVERTED_URL: &str = "
https://call.element.io/room#\
?parentUrl=https%3A%2F%2Fcall.element.io\
&widgetId=1/@#w23\
&userId=%40test%3Auser.org&deviceId=ABCDEFG\
&roomId=%21room_id%3Aroom.org\
&lang=en-US&theme=light\
&baseUrl=https%3A%2F%2Fclient-matrix.server.org%2F\
&hideHeader=true\
&preload=true\
&skipLobby=false\
&confineToRoom=true\
&displayname=hello\
&avatarUrl=some-url\
&appPrompt=true\
&clientId=io.my_matrix.client\
";
let gen = get_widget_settings()
._generate_webview_url(
@@ -88,17 +88,18 @@ mod tests {
use url::Url;
use super::{replace_properties, QueryProperties};
const EXAMPLE_URL: &str = "\
https://my.widget.org/custom/path/using/$matrix_display_name/in/it\
?widgetId=$matrix_widget_id\
&deviceId=$org.matrix.msc2873.matrix_device_id\
&avatarUrl=$matrix_avatar_url\
&displayname=$matrix_display_name\
&lang=$org.matrix.msc2873.client_language\
&theme=$org.matrix.msc2873.client_theme\
&clientId=$org.matrix.msc2873.client_id\
&baseUrl=$org.matrix.msc4039.matrix_base_url\
#andAHashWithA$org.matrix.msc2873.client_themeThemeAndTheClientId:$org.matrix.msc2873.client_id\
https://my.widget.org/custom/path/using/$matrix_display_name/in/it\
?widgetId=$matrix_widget_id\
&deviceId=$org.matrix.msc2873.matrix_device_id\
&avatarUrl=$matrix_avatar_url\
&displayname=$matrix_display_name\
&lang=$org.matrix.msc2873.client_language\
&theme=$org.matrix.msc2873.client_theme\
&clientId=$org.matrix.msc2873.client_id\
&baseUrl=$org.matrix.msc4039.matrix_base_url\
#andAHashWithA$org.matrix.msc2873.client_themeThemeAndTheClientId:$org.matrix.msc2873.client_id\
";
fn get_example_props() -> QueryProperties {
@@ -124,7 +125,18 @@ mod tests {
fn replace_all_properties() {
let mut url = get_example_url();
const CONVERTED_URL: &str = "https://my.widget.org/custom/path/using/I_AM_THEuser/in/it?widgetId=%21%40%2Fabc_widget_id&deviceId=%21%40%2Fabc_device_id&avatarUrl=%21%40%2Fabc_avatar_url&displayname=I_AM_THEuser&lang=%21%40%2Fabc_language&theme=light&clientId=12345678&baseUrl=https%3A%2F%2Fabc_base_url%2F#andAHashWithAlightThemeAndTheClientId:12345678";
const CONVERTED_URL: &str = "\
https://my.widget.org/custom/path/using/I_AM_THEuser/in/it\
?widgetId=%21%40%2Fabc_widget_id\
&deviceId=%21%40%2Fabc_device_id\
&avatarUrl=%21%40%2Fabc_avatar_url\
&displayname=I_AM_THEuser\
&lang=%21%40%2Fabc_language\
&theme=light\
&clientId=12345678\
&baseUrl=https%3A%2F%2Fabc_base_url%2F\
#andAHashWithAlightThemeAndTheClientId:12345678\
";
replace_properties(&mut url, get_example_props());
assert_eq!(url.as_str(), CONVERTED_URL);