diff --git a/app.py b/app.py index d7892bd..0ce6800 100644 --- a/app.py +++ b/app.py @@ -32,6 +32,11 @@ def internal_server_error(error): """Render a friendly 500 page for unexpected server errors.""" return render_template("500.html"), 500 + +@app.route('/health') +def health_check(): + return {'status': 'ok'}, 200 + if __name__ == "__main__": # debug=True is only for local development. diff --git a/main_test.py b/main_test.py new file mode 100644 index 0000000..80435f2 Binary files /dev/null and b/main_test.py differ diff --git a/static/script.js b/static/script.js index d4de221..18c5dc3 100644 --- a/static/script.js +++ b/static/script.js @@ -305,23 +305,32 @@ if (isIndexPage) { } }); + function addSkill(rawSkill) { //add a skill to the list if it's not empty or a duplicate function addSkill(rawSkill) { // Clean up any extra spaces and match to canonical skill name var skill = getCanonicalSkill(rawSkill); - // Nothing to add if string is empty after trimming if (!skill) return; - // Block duplicate entries (case-insensitive) + // Validate against available skills list + var isValid = availableSkills.some(function(s) { + return s.toLowerCase() === skill.toLowerCase(); + }); + + if (!isValid) { + showFieldError("skills-error", + '"' + skill + '" is not a recognized skill. Please select from the available list.'); + return; + } + if (isSkillSelected(skill)) return; selectedSkills.push(skill); renderSelectedChips(); syncSkillsHiddenInput(); updateQuickPickState(); - // Once a skill is added, remove the "please add a skill" error if it was showing clearFieldError("skills-error"); - } +} // remove a skill from the list and update the UI accordingly function removeSkill(skill) { @@ -842,3 +851,4 @@ if (scrollTopBtn) { window.addEventListener('scroll', handleScroll); scrollTopBtn.addEventListener('click', scrollToTop); } +} \ No newline at end of file diff --git a/tests/test_basic.py b/tests/test_basic.py index a66c75b..148d8f6 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -12,7 +12,6 @@ import sys import os - # Allow imports from the project root when running tests directly sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @@ -296,7 +295,19 @@ def test_scoring_weights_has_all_keys(): expected_keys = {"skill", "level", "interest", "time"} assert set(SCORING_WEIGHTS.keys()) == expected_keys +def client(): + app.config["TESTING"] = True + with app.test_client() as client: + yield client +def test_health_check(): + client = get_client() + response = client.get("/health") + assert response.status_code == 200 + data = response.get_json() + assert "status" in data + assert "version" in data + assert data["status"] == "ok" # ============================================================ # Run tests directly (no pytest required) # ============================================================