Skip to content

Commit

Permalink
tweak tests and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Jun 20, 2024
1 parent a06ca8b commit 9dddad0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/webxdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct WebxdcManifest {
/// Optional URL of webxdc source code.
pub source_code_url: Option<String>,

/// If the webxdc is an integration.
/// Set to "maps" if the webxdc is an integration.
pub integration: Option<String>,

/// If the webxdc requests network access.
Expand Down
12 changes: 4 additions & 8 deletions src/webxdc/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ impl Message {
mod tests {
use crate::config::Config;
use crate::context::Context;
use crate::message;
use crate::message::{Message, Viewtype};
use crate::test_utils::TestContext;
use crate::{chat, message};
use anyhow::Result;
use std::time::Duration;

Expand Down Expand Up @@ -180,9 +180,7 @@ mod tests {
None,
)
.await?;
chat::send_msg(&t, self_chat.id, &mut msg).await?;
let sent = t.pop_sent_msg_opt(Duration::from_secs(1)).await;
assert!(sent.is_some());
t.send_msg(self_chat.id, &mut msg).await;
assert_integration(&t, "with some icon").await?; // still the default integration

// send a maps.xdc with manifest including the line `integration = "maps"`
Expand All @@ -194,14 +192,12 @@ mod tests {
None,
)
.await?;
chat::send_msg(&t, self_chat.id, &mut msg).await?;
let sent = t.pop_sent_msg_opt(Duration::from_secs(1)).await;
assert!(sent.is_some());
let sent = t.send_msg(self_chat.id, &mut msg).await;
assert_integration(&t, "Maps Test 2").await?;

// when maps.xdc is received on another device, the integration is not accepted
let t2 = TestContext::new_alice().await;
t2.recv_msg(&sent.unwrap()).await;
t2.recv_msg(&sent).await;
assert!(t2.init_webxdc_integration(None).await?.is_none());

// deleting maps.xdc removes the user's integration - the UI will go back to default calling set_webxdc_integration() then
Expand Down

0 comments on commit 9dddad0

Please sign in to comment.