Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
use super::{dedupe_emails, is_generic_email};
#[test]
fn test_is_generic_email() {
// Test original "reply" pattern
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email(
"32.mrtvirzriftueqkpj53gqqkinfzdiukcifng4s3bfvlvo4krnfpxqzdpinjxo2keonat2pi=@unsubscribe2.customer.io"
));
assert!(is_generic_email(
"reply-107199600-1441644_html-1962870046-524000040-59174@e.atlassian.com"
));
// Test additional common system email prefixes
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Test with dot and hyphen variants
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Test with service provider domains
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Test with numeric and code patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Test non-automated emails (should return false)
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]")); // Contains "reply" but not as a prefix/pattern
assert!(!is_generic_email("[email protected]")); // Contains "information" but not as a pattern
}
#[test]
fn test_is_generic_email_new_prefixes() {
// Authentication/Security patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Transactional patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// System/DevOps patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Marketing/Communication patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Business department patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_new_domains() {
// Email service providers
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// CRM/Support platforms
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Subdomains of known providers
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_expanded_keywords() {
// "notification" anywhere in the local part, not just as a prefix
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Other strong keywords anywhere in the local part
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// New automated prefixes
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_expanded_domains() {
// ESP sending/bounce domains
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Product notification domains
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_expanded_false_positives_avoided() {
// Real names that share letters with new prefixes
assert!(!is_generic_email("[email protected]")); // "sales" not at start
assert!(!is_generic_email("[email protected]")); // "report" followed by a letter
assert!(!is_generic_email("[email protected]")); // "invite" followed by a letter
assert!(!is_generic_email("[email protected]")); // "members" followed by a letter
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]")); // "community" followed by a letter
assert!(!is_generic_email("[email protected]")); // no "notification" substring
// Corporate domains that host real humans stay non-generic
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_autogenerated_patterns() {
// UUID patterns
assert!(is_generic_email(
"[email protected]"
));
assert!(is_generic_email(
"[email protected]"
));
// Long hex strings
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email(
"[email protected]"
));
// Numeric prefix patterns
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
// Very long local parts (likely autogenerated)
assert!(is_generic_email(
"this-is-a-very-long-autogenerated-email-address-that-exceeds-fifty-chars@company.com"
));
}
#[test]
fn test_is_generic_email_false_positives_avoided() {
// Words containing prefixes but not matching the pattern
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
// Regular names with numbers
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
// Normal business emails
assert!(!is_generic_email("[email protected]"));
assert!(!is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_case_insensitivity() {
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
assert!(is_generic_email("[email protected]"));
}
#[test]
fn test_is_generic_email_invalid_input() {
// Invalid emails without @ should return false, not panic
assert!(!is_generic_email("invalid-email-no-at-sign"));
assert!(!is_generic_email(""));
assert!(!is_generic_email("just-text"));
}
#[test]
fn test_dedupe_emails() {
let emails = vec![
// Basic duplicates
"[email protected]".to_string(),
"[email protected]".to_string(),
// Plus aliases that should normalize to the same email
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
// Different emails that should remain separate
"[email protected]".to_string(),
"[email protected]".to_string(),
// Plus aliases for different base emails
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
// Edge cases
"[email protected]".to_string(), // Empty plus part
"[email protected]".to_string(), // Multiple plus signs
"[email protected]".to_string(), // Plus in the tag part
"[email protected]".to_string(),
// Plus sign after @ (shouldn't be processed)
"user@example+tag.com".to_string(),
"user@example+tag.com".to_string(),
// Complex cases
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
];
let mut result = dedupe_emails(emails);
result.sort();
let expected = vec![
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
"user@example+tag.com".to_string(), // Plus after @ should remain
"[email protected]".to_string(),
];
assert_eq!(result, expected);
assert_eq!(result.len(), 6);
}
#[test]
fn test_dedupe_emails_empty() {
let emails: Vec<String> = vec![];
let result = dedupe_emails(emails);
assert_eq!(result, Vec::<String>::new());
}
#[test]
fn test_dedupe_emails_no_duplicates() {
let emails = vec![
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
];
let mut result = dedupe_emails(emails);
result.sort();
let expected = vec![
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
];
assert_eq!(result, expected);
}
#[test]
fn test_dedupe_emails_all_same_base() {
let emails = vec![
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
"[email protected]".to_string(),
];
let result = dedupe_emails(emails);
assert_eq!(result.len(), 1);
assert_eq!(result[0], "[email protected]");
}