Skip to content

fix(heuristic): replace hardcoded 75% usability with real calculation#1859

Open
Harshit2405-2004 wants to merge 4 commits intoruxailab:developfrom
Harshit2405-2004:fix/usability-hardcoded-percentage
Open

fix(heuristic): replace hardcoded 75% usability with real calculation#1859
Harshit2405-2004 wants to merge 4 commits intoruxailab:developfrom
Harshit2405-2004:fix/usability-hardcoded-percentage

Conversation

@Harshit2405-2004
Copy link
Contributor

Description

Closes #1852

The UsabilityResults.vue dashboard card always displayed a hardcoded 75% usability score regardless of actual evaluator responses. This PR replaces the placeholder with a real calculation that reads answer data from the Vuex store and computes the true usability percentage.

What changed

src/ux/Heuristic/components/manager/UsabilityResults.vue

  • Added useStore() from Vuex to access answer data via store.getters.testAnswerDocument
  • Replaced return 75 in usabilityPercentage computed property with real logic:
    • Reads each evaluator's answers from heuristicAnswers
    • Computes maxOption from props.test.testOptions
    • Handles both {value, text} object answers and raw number answers
    • Skips N/A answers (value === -1)
    • Calculates per-evaluator percentage: (sum × 100) / ((totalQ − totalNA) × maxOption)
    • Returns the average across all evaluators

tests/unit/heuristic/UsabilityResults.spec.js (new file)

  • 6 unit tests covering all edge cases:
    1. No testAnswerDocument0%
    2. Empty heuristicAnswers0%
    3. Missing testOptions0%
    4. Valid evaluator data → correct calculated percentage
    5. Mixed evaluators (some N/A, some valid) → correct average
    6. All N/A answers → 0% (no NaN or Infinity)

Screenshot

Screenshot_11-3-2026_162243_github com

Edge cases handled

  • testAnswerDocument is null or missing heuristicAnswers
  • testOptions is null, undefined, or empty array
  • maxOption is 0 or negative
  • 0 evaluators in heuristicAnswers
  • All answers are N/A (-1) — prevents division by zero
  • Answers in mixed formats (object {value, text} vs raw number)

Validation

Gate Result
npm test ✅ 11 suites, 99 tests, 0 failures
npx eslint UsabilityResults.vue ✅ 0 errors
npm run build-prod ✅ Build succeeded

Files changed

  • src/ux/Heuristic/components/manager/UsabilityResults.vue — 45 insertions, 3 deletions
  • tests/unit/heuristic/UsabilityResults.spec.js — 136 insertions (new file)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the heuristic dashboard’s “General usability” card to display a computed usability percentage based on real evaluator answers from the Vuex testAnswerDocument, replacing the previous hardcoded 75% placeholder (closes #1852).

Changes:

  • Compute usabilityPercentage in UsabilityResults.vue by aggregating evaluator answers and averaging per-evaluator percentages.
  • Add a new unit test suite validating the computed percentage across several edge cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/ux/Heuristic/components/manager/UsabilityResults.vue Replaces hardcoded usability score with a computed score derived from Vuex answer data and test options.
tests/unit/heuristic/UsabilityResults.spec.js Adds unit tests for the new usability-percentage calculation and edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…handling

- Filter non-finite values before computing maxOption to prevent NaN
- Use Number.isFinite guard on answer values for robust extraction
- Handle null and undefined answers as N/A alongside -1 sentinel
- Add 3 new test cases for null, undefined, and mixed N/A scenarios

Resolves review comments on PR ruxailab#1859
axios uses ESM import syntax which Jest cannot parse without
transforming. Add transformIgnorePatterns to exclude axios from the
default node_modules ignore list so babel-jest can convert it to CJS.

Fixes CI test failure on Node 24 LTS.
Copilot AI review requested due to automatic review settings March 11, 2026 15:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Dashboard usability percentage is hardcoded to 75% instead of real calculation

2 participants