Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add autofill filter test for names with punctuation (#1142)

Leendert de Borst64a879f72d07
diff --git a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts
index 42557d1d2..8d614a7b6 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts
+++ b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts
@@ -279,6 +279,19 @@ describe('Filter - Credential URL Matching', () => {
expect(matches).toHaveLength(0);
});
+ // [#19] - Ensure separators and punctuation are stripped for matching
+ it('should match service names when separated by commas and other punctuation', () => {
+ const matches = filterCredentials(
+ testCredentials,
+ 'https://nomatch.com',
+ 'Reddit, social media platform'
+ );
+
+ // Should match "Reddit" even though it's followed by a comma and description
+ expect(matches).toHaveLength(1);
+ expect(matches[0].ServiceName).toBe('Reddit');
+ });
+
/**
* Creates the shared test credential dataset used across all platforms.
* Note: when making changes to this list, make sure to update the corresponding list for iOS and Android tests as well.
@@ -297,6 +310,7 @@ describe('Filter - Credential URL Matching', () => {
createTestCredential('Title Only newyorktimes', '', ''),
createTestCredential('Bank Account', 'https://secure-bank.com', '[email protected]'),
createTestCredential('AliExpress', 'https://aliexpress.com', '[email protected]'),
+ createTestCredential('Reddit', '', '[email protected]'),
];
}
diff --git a/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt b/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt
index 7430828f5..5d9dd9df9 100644
--- a/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt
+++ b/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt
@@ -282,6 +282,19 @@ class AutofillTest {
assertTrue(matches.isEmpty())
}
+ // [#19] - Ensure separators and punctuation are stripped for matching
+ @Test
+ fun testSeparatorsAndPunctuationStripped() {
+ val matches = CredentialMatcher.filterCredentialsByAppInfo(
+ testCredentials,
+ "Reddit, social media platform",
+ )
+
+ // Should match "Reddit" even though it's followed by a comma and description
+ assertEquals(1, matches.size)
+ assertEquals("Reddit", matches[0].service.name)
+ }
+
/**
* Creates the shared test credential dataset used across all platforms.
* This ensures consistent testing across Browser Extension, iOS, and Android.
@@ -300,6 +313,7 @@ class AutofillTest {
createTestCredential("Title Only newyorktimes", "", ""),
createTestCredential("Bank Account", "https://secure-bank.com", "[email protected]"),
createTestCredential("AliExpress", "https://aliexpress.com", "[email protected]"),
+ createTestCredential("Reddit", "", "[email protected]"),
)
}
diff --git a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift
index e01289f0d..7c65d2186 100644
--- a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift
+++ b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift
@@ -180,6 +180,15 @@ final class CredentialFilterTests: XCTestCase {
XCTAssertTrue(matches.isEmpty)
}
+ // [#19] - Ensure separators and punctuation are stripped for matching
+ func testSeparatorsAndPunctuationStripped() {
+ let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "Reddit, social media platform")
+
+ // Should match "Coolblue" even though it's followed by a comma and description
+ XCTAssertEqual(matches.count, 1)
+ XCTAssertEqual(matches.first?.service.name, "Reddit")
+ }
+
// MARK: - Shared Test Data
/**
@@ -200,6 +209,7 @@ final class CredentialFilterTests: XCTestCase {
createTestCredential(serviceName: "Title Only newyorktimes", serviceUrl: "", username: ""),
createTestCredential(serviceName: "Bank Account", serviceUrl: "https://secure-bank.com", username: "[email protected]"),
createTestCredential(serviceName: "AliExpress", serviceUrl: "https://aliexpress.com", username: "[email protected]"),
+ createTestCredential(serviceName: "Reddit", serviceUrl: "", username: "[email protected]"),
]
}