Skip to content
7 changes: 7 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ def internal_server_error(error):
"""Render a friendly 500 page for unexpected server errors."""
return render_template("500.html"), 500

fix/skills-input-validation

@app.route('/health')
def health_check():
return {'status': 'ok'}, 200
=======
@app.errorhandler(405)
def method_not_allowed(error):
"""Render a friendly 405 page when the wrong HTTP method is used."""
return render_template("405.html"), 405
main


if __name__ == "__main__":
Expand Down
Binary file added main_test.py
Binary file not shown.
18 changes: 14 additions & 4 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,32 @@ if (clearFiltersBtn) {
}
});

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) {
Expand Down Expand Up @@ -955,3 +964,4 @@ if (scrollTopBtn) {
window.addEventListener('scroll', handleScroll);
scrollTopBtn.addEventListener('click', scrollToTop);
}
}
13 changes: 12 additions & 1 deletion tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__), ".."))

Expand Down Expand Up @@ -297,7 +296,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)
# ============================================================
Expand Down
Loading