From 5352564f2641efec0413d89d29d2a2241eb0df79 Mon Sep 17 00:00:00 2001 From: Franco Leyes Date: Wed, 8 Jan 2025 08:18:41 -0300 Subject: [PATCH] [ADD] web_favicon: test case for _get_favicon handling multiple companies in cids cookie --- web_favicon/tests/test_web_favicon.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/web_favicon/tests/test_web_favicon.py b/web_favicon/tests/test_web_favicon.py index b6ea4d631..387c53bbd 100644 --- a/web_favicon/tests/test_web_favicon.py +++ b/web_favicon/tests/test_web_favicon.py @@ -72,3 +72,29 @@ class TestWebFavicon(TransactionCase): expected_favicon_url, "The favicon URL should match the expected value.", ) + + def test_04_favicon_multiple_companies(self): + """Test _get_favicon with multiple companies in cids cookie.""" + Company = self.env["res.company"] + + company_1 = Company.create( + {"name": "Company 1", "favicon": Company._get_default_favicon()} + ) + company_2 = Company.create( + {"name": "Company 2", "favicon": Company._get_default_favicon()} + ) + + with MockRequest(self.env) as mock_request: + mock_request.httprequest.cookies = { + "cids": f"{company_1.id}-{company_2.id}" + } + favicon_url = Company._get_favicon() + + self.assertTrue( + favicon_url, "Favicon URL should be generated for multiple companies." + ) + self.assertIn( + str(company_1.id), + favicon_url, + "Favicon URL should correspond to the first company in the cids cookie.", + )