Skip to content

Bug 2024075 Test Version Refactor: Moved subtest columns to test version strategy and test version files#1017

Open
kala-moz wants to merge 1 commit intomozilla:mainfrom
kala-moz:refactor_subtests_testversions
Open

Bug 2024075 Test Version Refactor: Moved subtest columns to test version strategy and test version files#1017
kala-moz wants to merge 1 commit intomozilla:mainfrom
kala-moz:refactor_subtests_testversions

Conversation

@kala-moz
Copy link
Contributor

@kala-moz kala-moz commented Mar 19, 2026

For bug: https://bugzilla.mozilla.org/show_bug.cgi?id=2024075

This PR continues the test version refactor work by removing the conditional rendering of the subtests' columns based on test versions and replacing it with the strategy test version call. The interface has been updated with the renderSubtestsColumns method. For example:

//src/common/testVersions/index.ts

export interface TestVersionStrategy {
  getColumns(isSubtestTable: boolean): TableConfig;
  getAvgValues(result: CombinedResultsItemType): {
    baseAvg: number | null;
    newAvg: number | null;
  };
  renderColumns(result: CombinedResultsItemType): ReactNode;
  renderSubtestColumns(
    result: CombinedResultsItemType,
    expanded: boolean,
  ): ReactNode;
}

The columns and properties specific to the test versions have been moved to their respective test version files. For example:

//src/common/testVersions/mannWhitney.tsx

...

  renderSubtestColumns(result: CombinedResultsItemType, expanded: boolean) {
    const {
      test,
      cliffs_delta,
      mann_whitney_test,
      cles,
      direction_of_change,
      base_measurement_unit: baseUnit,
      new_measurement_unit: newUnit,
      base_app: baseApp,
      new_app: newApp,
    } = result as MannWhitneyResultsItem;
    const mann_whitney_interpretation = mann_whitney_test?.interpretation
      ? capitalize(mann_whitney_test.interpretation)
      : '-';
    const clesVal = ((cles?.cles ?? 0) * 100).toFixed(2);
    const baseAvgValue =
      (result as MannWhitneyResultsItem).base_standard_stats?.mean ?? 0;
    const newAvgValue =
      (result as MannWhitneyResultsItem).new_standard_stats?.mean ?? 0;
    return (
      <>
        <div title={test} className='subtests subtests-mannwhitney' role='cell'>
          {test}
        </div>
        <div className='mann-witney-browser-name cell' role='cell'>
          {formatNumber(baseAvgValue)} {baseUnit}
          {getBrowserDisplay(baseApp, newApp, expanded) && (
            <span className={FontSize.xSmall}>({baseApp})</span>
          )}
        </div>
        <div className='comparison-sign cell' role='cell'>
          {determineSign(baseAvgValue, newAvgValue)}
        </div>
        <div className='mann-witney-browser-name cell' role='cell'>
          {formatNumber(newAvgValue)} {newUnit}
          {getBrowserDisplay(baseApp, newApp, expanded) && (
            <span className={FontSize.xSmall}>({newApp})</span>
          )}
        </div>
        etc...

Now, SubtestRevsisionRow is cleaner with a simple strategy test version call.

//src/components/CompareResults/SubtestsResults/SubtestsRevisionRow

...

 const strategy = getStrategy(testVersion ?? MANN_WHITNEY_U);

return (
    <>
      <Box
        className={`revisionRow ${revisionRow} ${typography}`}
        sx={{ gridTemplateColumns, backgroundColor: 'revisionRow.background' }}
        role='row'
      >
        {strategy.renderSubtestColumns(result, expanded)}
... etc 

Lastly added duplicated code in RevisionRow and SubtestsRevisionRow to revisionRowHelpers and updated test for the subtests to reflect Mann-Whitney-U as the default.

Updated tests to make mann-whitney-u the default. Added duplicated code to revisionRowHelpers.
@netlify
Copy link

netlify bot commented Mar 19, 2026

Deploy Preview for mozilla-perfcompare ready!

Name Link
🔨 Latest commit 17366f8
🔍 Latest deploy log https://app.netlify.com/projects/mozilla-perfcompare/deploys/69bc384fda12da000769275d
😎 Deploy Preview https://deploy-preview-1017--mozilla-perfcompare.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kala-moz kala-moz marked this pull request as draft March 19, 2026 17:55
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.44%. Comparing base (cdca3ee) to head (17366f8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1017      +/-   ##
==========================================
- Coverage   96.46%   96.44%   -0.02%     
==========================================
  Files         109      109              
  Lines        3051     3034      -17     
  Branches      691      683       -8     
==========================================
- Hits         2943     2926      -17     
  Misses        107      107              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 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.

@kala-moz kala-moz changed the title Bug 2024075: Moved subtest columns to test version strategy and test version files Bug 2024075 Test Version Refactor: Moved subtest columns to test version strategy and test version files Mar 19, 2026
@kala-moz kala-moz marked this pull request as ready for review March 19, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant