From aecd5321ea50b95c8c06f77c0b493d5582967226 Mon Sep 17 00:00:00 2001 From: Luis Date: Tue, 14 Nov 2023 14:38:16 +0000 Subject: [PATCH] Added validation for the case the header is not a string --- caimira/apps/calculator/static/js/co2_form.js | 1 + caimira/tests/apps/calculator/test_model_generator.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/caimira/apps/calculator/static/js/co2_form.js b/caimira/apps/calculator/static/js/co2_form.js index e16cf39d..ef21f010 100644 --- a/caimira/apps/calculator/static/js/co2_form.js +++ b/caimira/apps/calculator/static/js/co2_form.js @@ -64,6 +64,7 @@ function uploadFile(endpoint) { const cellValue = worksheet[headerCoordinates[header]]?.v; if ( !cellValue || + $.type(cellValue) !== "string" || cellValue.trim().toLowerCase() !== header.toLowerCase() ) { $("#upload-error") diff --git a/caimira/tests/apps/calculator/test_model_generator.py b/caimira/tests/apps/calculator/test_model_generator.py index 099a00d2..4d1f5756 100644 --- a/caimira/tests/apps/calculator/test_model_generator.py +++ b/caimira/tests/apps/calculator/test_model_generator.py @@ -171,8 +171,8 @@ def test_ventilation_window_hepa(baseline_form: model_generator.FormData): @pytest.mark.parametrize( ["activity", "total_people", "infected_people", "error"], [ - ['office', 10, 11, "Number of infected people cannot be more or equal than number of total people."], - ['office', 10, 10, "Number of infected people cannot be more or equal than number of total people."], + ['office', 10, 11, "Number of infected people cannot be greater or equal to the number of total people"], + ['office', 10, 10, "Number of infected people cannot be greater or equal to the number of total people"], ['training', 10, 2, "Conference/Training activities are limited to 1 infected."], ] )