From c59adb4871afa98bdc028eaf5d57274e2d8dd731 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Fri, 3 Jul 2026 15:39:35 -0300 Subject: [PATCH] Cover every supported language in ContentLanguage detection tests Extend the homepage-language detection dataset to assert all 15 supported languages resolve from their subtag, and pin the primary-subtag matching so a malformed tag ("english") no longer resolves via a two-letter prefix. --- tests/Feature/Ai/AutofillBrandTest.php | 18 +++++++++++++++++- .../Enums/Workspace/ContentLanguageTest.php | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Ai/AutofillBrandTest.php b/tests/Feature/Ai/AutofillBrandTest.php index e4be9ded..fd5469c0 100644 --- a/tests/Feature/Ai/AutofillBrandTest.php +++ b/tests/Feature/Ai/AutofillBrandTest.php @@ -100,13 +100,29 @@ expect($result->language)->toBe($expected); })->with([ + // Every supported language, detected from its primary subtag. + ['en', 'en'], ['pt', 'pt-BR'], + ['es', 'es'], + ['fr', 'fr'], + ['de', 'de'], + ['it', 'it'], + ['nl', 'nl'], + ['pl', 'pl'], + ['el', 'el'], + ['ja', 'ja'], + ['ko', 'ko'], + ['zh', 'zh'], + ['ru', 'ru'], + ['tr', 'tr'], + ['ar', 'ar'], + // Region/script subtags still resolve to the supported language. ['pt-PT', 'pt-BR'], ['en-US', 'en'], ['es-MX', 'es'], - ['fr', 'fr'], ['ja-JP', 'ja'], ['zh-Hans', 'zh'], + // Unsupported languages stay null. ['sv', null], ]); diff --git a/tests/Unit/Enums/Workspace/ContentLanguageTest.php b/tests/Unit/Enums/Workspace/ContentLanguageTest.php index 525d66d1..58db5692 100644 --- a/tests/Unit/Enums/Workspace/ContentLanguageTest.php +++ b/tests/Unit/Enums/Workspace/ContentLanguageTest.php @@ -44,4 +44,7 @@ ['sv', null], ['e', null], ['', null], + // A malformed tag is matched on its whole primary subtag, never a + // two-letter prefix — "english" must not resolve to English via "en". + ['english', null], ]);