fix formatting

make test  pass
fix clippy
This commit is contained in:
Simon Laux
2022-05-10 23:10:39 +02:00
parent 688326f21c
commit bfd97fdb05
2 changed files with 25 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ pub use deltachat::accounts::Accounts;
pub mod events;
pub mod types;
use crate::api::types::chat_list::{ChatListItemFetchResult, get_chat_list_item_by_id};
use crate::api::types::chat_list::{get_chat_list_item_by_id, ChatListItemFetchResult};
use types::account::Account;
use types::chat::FullChat;
@@ -435,7 +435,7 @@ impl CommandApi {
query: Option<String>,
) -> Result<Vec<u32>> {
let ctx = self.get_context(account_id).await?;
let contacts = Contact::get_all(&ctx, list_flags, query).await?;
let contacts = Contact::get_all(&ctx, list_flags, query.as_deref()).await?;
Ok(contacts.into_iter().map(|c| c.to_u32()).collect())
}
@@ -448,7 +448,7 @@ impl CommandApi {
query: Option<String>,
) -> Result<Vec<ContactObject>> {
let ctx = self.get_context(account_id).await?;
let contact_ids = Contact::get_all(&ctx, list_flags, query).await?;
let contact_ids = Contact::get_all(&ctx, list_flags, query.as_deref()).await?;
let mut contacts: Vec<ContactObject> = Vec::with_capacity(contact_ids.len());
for id in contact_ids {
contacts.push(

View File

@@ -38,6 +38,10 @@ describe("online tests", function () {
url: "ws://localhost:" + CMD_API_SERVER_PORT + "/ws",
});
dc.on("ALL", ({ name, contextId }) => {
if (name !== "INFO") console.log(contextId, name);
});
account = await createTempUser(process.env.DCC_NEW_TMP_EMAIL);
if (!account || !account.email || !account.password) {
console.log(
@@ -92,7 +96,11 @@ describe("online tests", function () {
null
);
const chatId = await dc.rpc.contactsCreateChatByContactId(acc1, contactId);
const eventPromise = waitForEvent(dc, "INCOMING_MSG", acc2);
const eventPromise = Promise.race([
waitForEvent(dc, "MSGS_CHANGED", acc2),
waitForEvent(dc, "INCOMING_MSG", acc2),
]);
dc.rpc.miscSendTextMessage(acc1, "Hello", chatId);
const { field1: chatIdOnAccountB } = await eventPromise;
await dc.rpc.acceptChat(acc2, chatIdOnAccountB);
@@ -111,7 +119,7 @@ describe("online tests", function () {
if (!are_configured) {
this.skip();
}
this.timeout(7000);
this.timeout(10000);
// send message from A to B
const contactId = await dc.rpc.contactsCreateContact(
@@ -120,9 +128,15 @@ describe("online tests", function () {
null
);
const chatId = await dc.rpc.contactsCreateChatByContactId(acc1, contactId);
const eventPromise = Promise.race([
waitForEvent(dc, "MSGS_CHANGED", acc2),
waitForEvent(dc, "INCOMING_MSG", acc2),
]);
dc.rpc.miscSendTextMessage(acc1, "Hello2", chatId);
// wait for message from A
const event = await waitForEvent(dc, "INCOMING_MSG", acc2);
console.log("wait for message from A");
const event = await eventPromise;
const { field1: chatIdOnAccountB } = event;
await dc.rpc.acceptChat(acc2, chatIdOnAccountB);
@@ -137,9 +151,13 @@ describe("online tests", function () {
);
expect(message.text).equal("Hello2");
// Send message back from B to A
const eventPromise2 = Promise.race([
waitForEvent(dc, "MSGS_CHANGED", acc1),
waitForEvent(dc, "INCOMING_MSG", acc1),
]);
dc.rpc.miscSendTextMessage(acc2, "super secret message", chatId);
// Check if answer arives at A and if it is encrypted
await waitForEvent(dc, "INCOMING_MSG", acc1);
await eventPromise2;
const messageId = (
await dc.rpc.messageListGetMessageIds(acc1, chatId, 0)