From 64a879f72d0701c8561781e08d4cb6e8424a2b70 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Mon, 25 Aug 2025 17:50:00 +0200 Subject: [PATCH] Add autofill filter test for names with punctuation (#1142) --- .../contentScript/__tests__/Filter.test.ts | 14 ++++++++++++++ .../app/nativevaultmanager/AutofillTest.kt | 14 ++++++++++++++ .../ios/VaultUITests/CredentialFilterTests.swift | 10 ++++++++++ 3 files changed, 38 insertions(+) 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', 'user@bank.com'), createTestCredential('AliExpress', 'https://aliexpress.com', 'user@aliexpress.com'), + createTestCredential('Reddit', '', 'user@reddit.com'), ]; } 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", "user@bank.com"), createTestCredential("AliExpress", "https://aliexpress.com", "user@aliexpress.com"), + createTestCredential("Reddit", "", "user@reddit.com"), ) } 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: "user@bank.com"), createTestCredential(serviceName: "AliExpress", serviceUrl: "https://aliexpress.com", username: "user@aliexpress.com"), + createTestCredential(serviceName: "Reddit", serviceUrl: "", username: "user@reddit.com"), ] }