Update Skill Tree Picker and Catalog Functions for Clarity
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
Test Suite / pytest-backend (pull_request) Successful in 35s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 12s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m14s

- Modified comments in `SkillTreePickerPanel` and `skillCatalogTree.js` to accurately reflect the default expansion behavior, specifying that only main groups are open by default.
- Refactored `defaultExpandedKeysForSkillTree` to simplify the logic, ensuring only main groups are returned as expanded.
- Adjusted tests in `skillCatalogTree.test.js` to validate the updated behavior, confirming that only main groups are opened in the skill tree.
This commit is contained in:
Lars 2026-05-20 11:21:18 +02:00
parent b2f77ca627
commit ab612a5335
3 changed files with 7 additions and 16 deletions

View File

@ -78,7 +78,7 @@ function SkillTreeNodes({ nodes, depth, expanded, exclude, onToggle, onPickSkill
}
/**
* Ausklappbare Baumliste: Hauptgruppe Kategorie Fähigkeit (Hauptgruppe und Kategorie standard offen).
* Ausklappbare Baumliste: Hauptgruppe Kategorie Fähigkeit (nur Hauptgruppe standard offen).
*/
export default function SkillTreePickerPanel({
skills = [],

View File

@ -162,19 +162,10 @@ export function allExpandableKeys(tree) {
return keys
}
/** Standard: Hauptgruppe und Kategorie aufgeklappt (Fähigkeiten direkt darunter sichtbar). */
/** Standard: nur Hauptgruppe aufgeklappt; Kategorien und Fähigkeiten zugeklappt. */
export function defaultExpandedKeysForSkillTree(tree) {
const keys = []
const walk = (nodes) => {
for (const n of nodes) {
if (n.type === 'main' || n.type === 'category') {
keys.push(n.key)
walk(n.children || [])
}
}
}
walk(tree)
return keys
if (!Array.isArray(tree)) return []
return tree.filter((n) => n.type === 'main').map((n) => n.key)
}
/** Sentinel für Katalog-Admin: keine Hauptgruppe gewählt. */

View File

@ -49,11 +49,11 @@ describe('skillCatalogTree', () => {
expect(kataSkill.skillId).toBe(2)
})
it('defaultExpandedKeysForSkillTree opens main and category only', () => {
it('defaultExpandedKeysForSkillTree opens main groups only', () => {
const tree = buildSkillCatalogTree(sample)
const keys = defaultExpandedKeysForSkillTree(tree)
expect(keys).toContain('m-10')
expect(keys.some((k) => k.includes('c-21'))).toBe(true)
expect(keys).toEqual(['m-10'])
expect(keys.some((k) => k.includes('c-'))).toBe(false)
expect(keys.some((k) => k.startsWith('s-'))).toBe(false)
})