Skip to content
Draft
320 changes: 160 additions & 160 deletions src/__tests__/CompareResults/ResultsTable.test.tsx

Large diffs are not rendered by default.

71 changes: 0 additions & 71 deletions src/__tests__/CompareResults/RevisionRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import fetchMock from '@fetch-mock/jest';
import userEvent from '@testing-library/user-event';

import { compareView } from '../../common/constants';
import { isDistributionNormal } from '../../common/testVersions/mannWhitney';
import { loader } from '../../components/CompareResults/loader';
import RevisionRow from '../../components/CompareResults/RevisionRow';
import { useSubtestRegressionCount } from '../../hooks/useSubtestRegressionCount';
Expand Down Expand Up @@ -524,76 +523,6 @@ describe('Expanded row', () => {

expect(writeTextMock).toHaveBeenCalledWith(baseRuns);
});

describe('median diff column normality gating', () => {
const normalRuns = [5.1, 5.2, 4.9, 5.0, 5.05];
const tooFewRuns = [5.0];

function makeResult(
baseRuns: number[],
newRuns: number[],
): MannWhitneyResultsItem {
const { testCompareMannWhitneyData } = getTestData();
return {
...testCompareMannWhitneyData[0],
base_runs: baseRuns,
new_runs: newRuns,
};
}

it('shows dash when neither distribution is normal', async () => {
const result = makeResult(tooFewRuns, tooFewRuns);
expect(isDistributionNormal(result)).toBe(false);
renderWithRoute(
<RevisionRow
result={result}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).toHaveTextContent('-');
});

it('shows value with warning icon when only one distribution is normal', async () => {
const result = makeResult(normalRuns, tooFewRuns);
expect(isDistributionNormal(result)).toBe(true);
renderWithRoute(
<RevisionRow
result={result}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).not.toHaveTextContent('-');
expect(roles[4].querySelector('svg[role="img"]')).toBeTruthy();
});

it('shows value without warning icon when both distributions are normal', async () => {
const result = makeResult(normalRuns, normalRuns);
expect(isDistributionNormal(result)).toBe(true);
renderWithRoute(
<RevisionRow
result={result}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).not.toHaveTextContent('-');
expect(roles[4].querySelector('svg[role="img"]')).toBeFalsy();
});
});
});

describe('expandAll prop', () => {
Expand Down
102 changes: 51 additions & 51 deletions src/__tests__/CompareResults/SubtestsResultsView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function summarizeVisibleRows(testVersion?: TestVersion) {
}
const rowClasses =
testVersion === 'mann-whitney-u'
? ['.median-diff', '.delta', '.significance', '.effects']
? ['.mode-delta', '.delta', '.significance', '.effects']
: ['.delta', '.confidence'];
const rowString = rowClasses
.map((selector) => row.querySelector(selector)?.textContent.trim())
Expand Down Expand Up @@ -527,11 +527,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
await setupForSorting();
// Initial view (alphabetical ordered, even if "sort by subtests" isn't specified
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'browser.html: 0.963 %, -0.04, -, 15.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
]);

// Sort by Delta
Expand All @@ -542,11 +542,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
// Sort descending
await user.click(deltaButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'regression.html: 1.135 %, 0.12, , 25.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
]);

// It should have the "descending" SVG.
Expand All @@ -557,11 +557,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
// Sort ascending
await user.click(deltaButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
]);
// It should have the "ascending" SVG.
expect(deltaButton).toMatchSnapshot();
Expand All @@ -574,11 +574,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
});
await user.click(significanceButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'browser.html: 0.963 %, -0.04, -, 15.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
]);
// It should have the "no sort" SVG.
expect(deltaButton).toMatchSnapshot();
Expand All @@ -590,11 +590,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
// Sort by Significance ascending
await user.click(significanceButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'improvement.html: 0.963 %, -0.05, , 50.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
]);
expectParameterToHaveValue('sort', 'significance|asc');

Expand All @@ -604,11 +604,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
});
await user.click(effectButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'browser.html: 0.963 %, -0.04, -, 15.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
]);

// It should have the "descending" SVG.
Expand All @@ -619,11 +619,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
// Sort by Effect Size ascending
await user.click(effectButton);
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'improvement.html: 0.963 %, -0.05, , 50.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
]);
expectParameterToHaveValue('sort', 'effects|asc');
});
Expand All @@ -632,11 +632,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
await setupForSorting({ extraParameters: 'sort=delta|asc' });
await screen.findByText('dhtml.html');
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'regression.html: 1.135 %, 0.12, , 25.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
]);
// It should have the "ascending" SVG.
expect(screen.getByRole('button', { name: /CD/ })).toMatchSnapshot();
Expand All @@ -646,11 +646,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
await setupForSorting({ extraParameters: 'sort=delta' });
await screen.findByText('dhtml.html');
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'regression.html: 1.135 %, 0.12, , 25.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
]);
// It should have the "descending" SVG.
expect(screen.getByRole('button', { name: /CD/ })).toMatchSnapshot();
Expand All @@ -659,11 +659,11 @@ describe('SubtestsResultsView Component Tests for mann-whitney-u testVersion', (
it('initializes the sort from the URL at load time for a descending sort', async () => {
await setupForSorting({ extraParameters: 'sort=delta|desc' });
expect(summarizeVisibleRows('mann-whitney-u')).toEqual([
'regression.html: 1.135 %, 0.12, , 25.00%',
'improvement.html: 0.963 %, -0.05, , 50.00%',
'browser.html: 0.963 %, -0.04, -, 15.00%',
'dhtml.html: 1.135 %, 0.02, , 60.00%',
'tablemutation.html: 0.98 %, 0.01, -, 45.00%',
'regression.html: ~1.04 %, 0.12, , 25.00%',
'improvement.html: ~-1.44 %, -0.05, , 50.00%',
'browser.html: ~-1.43 %, -0.04, -, 15.00%',
'dhtml.html: ~1.14 %, 0.02, , 60.00%',
'tablemutation.html: ~0.98 %, 0.01, -, 45.00%',
]);
// It should have the "descending" SVG.
expect(screen.getByRole('button', { name: /CD/ })).toMatchSnapshot();
Expand Down
60 changes: 0 additions & 60 deletions src/__tests__/CompareResults/SubtestsRevisionRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import userEvent from '@testing-library/user-event';

import { loader } from '../../components/CompareResults/loader';
import SubtestsRevisionRow from '../../components/CompareResults/SubtestsResults/SubtestsRevisionRow';
import { MannWhitneyResultsItem } from '../../types/state';
import getTestData from '../utils/fixtures';
import { screen, renderWithRouter } from '../utils/test-utils';

Expand Down Expand Up @@ -235,63 +234,4 @@ describe('SubtestsRevisionRow Component', () => {
expect(status1).toHaveTextContent('Improvement');
expect(status1).toHaveClass('status-hint-improvement');
});

describe('median diff column normality gating', () => {
const normalRuns = [5.1, 5.2, 4.9, 5.0, 5.05];
const tooFewRuns = [5.0];
const mockGridTemplateColumns = '1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr';

function makeResult(
baseRuns: number[],
newRuns: number[],
): MannWhitneyResultsItem {
const { subtestsMannWhitneyResult } = getTestData();
return {
...subtestsMannWhitneyResult[0],
base_runs: baseRuns,
new_runs: newRuns,
};
}

it('shows dash when neither distribution is normal', async () => {
renderWithRoute(
<SubtestsRevisionRow
result={makeResult(tooFewRuns, tooFewRuns)}
gridTemplateColumns={mockGridTemplateColumns}
replicates={false}
testVersion='mann-whitney-u'
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).toHaveTextContent('-');
});

it('shows value with warning icon when only one distribution is normal', async () => {
renderWithRoute(
<SubtestsRevisionRow
result={makeResult(normalRuns, tooFewRuns)}
gridTemplateColumns={mockGridTemplateColumns}
replicates={false}
testVersion='mann-whitney-u'
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).not.toHaveTextContent('-');
expect(roles[4].querySelector('svg[role="img"]')).toBeTruthy();
});

it('shows value without warning icon when both distributions are normal', async () => {
renderWithRoute(
<SubtestsRevisionRow
result={makeResult(normalRuns, normalRuns)}
gridTemplateColumns={mockGridTemplateColumns}
replicates={false}
testVersion='mann-whitney-u'
/>,
);
const roles = await screen.findAllByRole('cell');
expect(roles[4]).not.toHaveTextContent('-');
expect(roles[4].querySelector('svg[role="img"]')).toBeFalsy();
});
});
});
Loading