Skip to content

feat: add Competency Tree on the Competency Management page - #3218

Open
AShatsila wants to merge 6 commits into
openedx:masterfrom
AShatsila:ashatsila/680-feat-competency-tree
Open

feat: add Competency Tree on the Competency Management page#3218
AShatsila wants to merge 6 commits into
openedx:masterfrom
AShatsila:ashatsila/680-feat-competency-tree

Conversation

@AShatsila

@AShatsila AShatsila commented Aug 28, 2026

Copy link
Copy Markdown

Description

Adds a new read-only Competency Management page at /taxonomy/:taxonomyId/competencies. It shows a competency taxonomy's tags as a nested expand/collapse tree (taxonomy name → groups → sub-competencies), with each row's Competency ID (external_id) displayed next to it. The page is fully read-only: no editing of names or IDs, no add/edit/delete affordances anywhere, and no backend/API/data-layer changes.

This is a new page, so it doesn't change behavior for any existing role. It's intended for Platform Administrators who need to browse a taxonomy's competencies by their stable Competency ID before applying competency criteria elsewhere.

image

Supporting information

Testing instructions

  1. Enable the ENABLE_TAGGING_TAXONOMY_PAGES feature flag.
  2. Have (or create) a competency taxonomy with a nested tag tree at least 2 levels deep, where at least one tag has no external_id set.
  3. As a Platform Administrator (staff) user, navigate to /taxonomy/:taxonomyId/competencies for that taxonomy.
  4. Confirm the tree renders with the taxonomy's own name as the top row, groups below it, and sub-competencies nested under their group.
  5. Use Expand All / Collapse All and individual row toggles; confirm indentation stays correct at every level.
  6. Confirm each tag with an external_id shows it as a badge, and the tag without one shows no badge (not the literal text "undefined" or "null").
  7. Confirm there is no add/edit/delete/rename control anywhere on the page.
  8. Resize to a narrow viewport and confirm the tree and Competency IDs stay readable and correctly associated.
  9. Open the existing /taxonomy/:taxonomyId page (tag editing) and confirm it's unaffected — same table, same columns, same zebra striping as before.

Other information

  • No backend, API, or data-layer changes.
  • Entry point is URL-only for this ticket — no link was added from the taxonomy detail page or its menu, per the agreed scope.
  • The API doesn't distinguish "competency" taxonomies from other taxonomies, so this page will render whatever taxonomy id is in the URL, including system-defined ones whose tags may not be fully enumerable. Known limitation, to revisit once/if the backend exposes a competency-enabled flag.
  • Architecture note: this page does not reuse the existing table-based tag tree-table shell (src/taxonomy/tree-table/) that the editable taxonomy detail page uses. That shell is built around an HTML <table>/TanStack Table, which can't express per-row gaps or nested "card" grouping without hacky workarounds (<tr> can't take margin, and a box-shadow-based border approach bled across row boundaries). Since this page needs neither the shared shell's editing machinery nor its tabular semantics, it renders its own lightweight <ul>/<li> tree instead, reusing only the taxonomy-tag-to-tree data shaping (TagTree) from the existing tag-list feature.
  • Paragon note: the Competency ID badge's exact color (#006DAA) doesn't correspond to any existing Paragon semantic color variant in this app's theme (variant="info" resolves to teal) - it's retinted via a page-scoped CSS custom-property override on top of the real Badge component. Flagging per the standing internal reminder to surface anything not natively available in Paragon.
  • Accessibility: the disclosure chevron's clickable area is kept at the WCAG 2.2 AA minimum of 24×24px even though its visible icon is smaller (16px, per the Figma spec), via an invisible expanded hit area. The Competency ID badge also carries its own aria-label since there's no table header for screen readers to associate it with.

Best Practices Checklist

  • Any new files are using TypeScript (.ts, .tsx).

  • Avoid propTypes and defaultProps in any new or modified code.

  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)

  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.

  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.

  • All new i18n messages in messages.ts files have a description for translators to use.

  • Avoid using ../ in import paths. To import from parent folders, use @src.

  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

SaXaPhonist and others added 2 commits August 28, 2026 16:14
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 28, 2026
@openedx-webhooks

openedx-webhooks commented Aug 28, 2026

Copy link
Copy Markdown

Thanks for the pull request, @AShatsila!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Aug 28, 2026
@AShatsila
AShatsila marked this pull request as ready for review August 28, 2026 15:13
@AShatsila AShatsila changed the title Feat add Competency Tree on the Competency Management page feat: add Competency Tree on the Competency Management page Aug 28, 2026

@mgwozdz-unicon mgwozdz-unicon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude and I worked together on this code review and came up with the following items:

1. CompetencyExpandIcon.tsx duplicates an existing component.

src/taxonomy/tag-list/OptionalExpandLink.tsx already renders the same disclosure button (invisible placeholder when a row can't expand, aria-expanded toggle when it can). It takes a TanStack Row, which doesn't fit this page's plain <ul>/<li> tree, but CompetencyExpandIcon's own canExpand/isExpanded/onToggle interface is the more reusable shape. Suggest hoisting it into a shared location (it isn't competency-specific) and making OptionalExpandLink a thin wrapper around it, so there's one component instead of two near-identical ones.

2. Test coverage doesn't reach the platform's documented depth limit.

The backend enforces TAXONOMY_MAX_DEPTH = 5 (0-indexed, openedx_tagging/models/base.py), so a taxonomy can legally nest 6 levels deep, and the frontend has a matching constant in src/taxonomy/taxonomy-detail/constants.ts. The deepest fixture in either the existing tree-table tests or CompetencyTree.test.tsx is depth 2. That matters here because CompetencyTree/CompetencyTreeItem recurse through nested <ul> elements with CSS-driven indentation rather than TanStack's built-in depth handling, and that path is untested at real depth (the synthetic taxonomy-root row adds one more level on top, so the real max case is 7 nested <ul>s, not 6). Could you add a test with a 6-level tag chain confirming every label is reachable via Expand All?

3. CompetencyTree.test.tsx:179 is testing an impossible failure.

The test renders as a plain list, not a table, with no CRUD affordances anywhere in the tree asserts the absence of six buttons copied from the other page's action menu (src/taxonomy/tag-list/Actions.tsx). Since CompetencyTreeItem never renders anything from that file, none of those assertions can fail from a change within this feature folder, and they couple this suite to another file's button labels. Suggest dropping those six and keeping the queryByRole('table')/columnheader checks just above them, since those verify what this PR actually decided: a list, not a table.

4. #680 doesn't specify the tree's default expand state, and we think it should require the root expanded.

Checked the ticket directly: the "Accordion expand/collapse" acceptance criterion only says a node's children hide or show when toggled, it never states the initial state, and nothing else in the ticket does either. CompetencyTree.tsx calls the collapsed default "this page's deliberate initial state," matching the existing Taxonomy Detail page's tree-table, which also defaults to fully collapsed. But this page's default is more aggressive than that precedent, because the thing collapsed here is the taxonomy root itself. A first-time visitor sees exactly one row, the taxonomy's own name, and zero competencies until they click. On the existing tag-editing page, top-level tags are already visible on load; only their children start collapsed. Our recommendation is to default the root row expanded (showing top-level groups/tags immediately) while leaving deeper nodes collapsed, so the page is useful without a click on first load. @thelmick-unicon, could you update #680 to specify this as a requirement, so it's explicit rather than left to each implementation's own judgment?

- Deduplicate expand/collapse icon into a shared ExpandCollapseIconButton,
  replacing CompetencyExpandIcon and simplifying OptionalExpandLink
- Add a max-depth (6-level) tree test matching TAXONOMY_MAX_DEPTH
- Remove CRUD-absence assertions that could never fail from this feature
- Default the taxonomy root row to expanded on first load

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('renders as a plain list, not a table', async () => {

* message objects, so this component stays free of any particular i18n
* message set - each caller owns its own wording.
*/
const ExpandCollapseIconButton = ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting this in src/generic :)

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.80000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.93%. Comparing base (16e19f1) to head (17384c6).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
.../taxonomy/competency-management/CompetencyTree.tsx 96.82% 2 Missing ⚠️
src/taxonomy/competency-management/index.ts 0.00% 1 Missing ⚠️
src/taxonomy/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #3218    +/-   ##
========================================
  Coverage   95.92%   95.93%            
========================================
  Files        1397     1403     +6     
  Lines       33581    33737   +156     
  Branches     7947     7729   -218     
========================================
+ Hits        32214    32367   +153     
- Misses       1308     1327    +19     
+ Partials       59       43    -16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mgwozdz-unicon mgwozdz-unicon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing my comments! I'm approving this, pending the one cleanup item I flagged.

@arbrandes arbrandes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, thank you! Claude helped me find a few issues, though. Comments inline.

Comment thread src/taxonomy/competency-management/CompetencyTree.tsx Outdated
Comment thread src/taxonomy/competency-management/CompetencyTree.tsx Outdated
Comment thread src/taxonomy/competency-management/CompetencyTree.tsx
Comment thread src/taxonomy/competency-management/CompetencyTree.tsx
Comment thread src/taxonomy/competency-management/CompetencyTreeItem.tsx Outdated
Comment thread src/taxonomy/competency-management/CompetencyTree.scss Outdated
Comment on lines +108 to +115
// Grows the hit area to the WCAG 24px minimum, then cancels that
// growth's effect on the row's layout with matching negative margins
// so the glyph and the 25px label inset don't move. The right margin
// also covers the icon-to-label gap, replacing the `mr-1` utility
// this page's disclosure button doesn't apply (`ExpandCollapseIconButton`'s
// `!important` couldn't otherwise be overridden here).
padding: $disclosure-hit-area-inset;
margin: (-$disclosure-hit-area-inset) 0 (-$disclosure-hit-area-inset) (-$disclosure-hit-area-inset); // top right bottom left

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the comment says "The right margin also covers the icon-to-label gap", but the shorthand sets right margin to 0 - it's the 4px hit-area padding that provides that gap.

Comment thread src/taxonomy/competency-management/CompetencyTree.scss Outdated
Comment on lines +9 to +11
expandedLabel: string;
/** Label for the "collapse" action - shown while the row is expanded. */
collapsedLabel: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: these two hold the opposite of what their names suggest - expandedLabel is the label shown while collapsed - which is why both call sites and these doc comments have to explain the inversion. expandLabel/collapseLabel, naming the action rather than the state, reads correctly without the explanation.

Comment thread src/taxonomy/competency-management/CompetencyTree.scss Outdated
@bradenmacdonald

Copy link
Copy Markdown
Contributor

This can merge once you've addressed @arbrandes review and gotten a ✅ from him; no need for further review from me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

[FE] Display Competency ID on the Competency Management page

7 participants