Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/__tests__/CompareResults/ResultsView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,28 @@ describe('Results View', () => {
expect(screen.queryByText('Results')).not.toBeInTheDocument();
expect(screen.getByText(titleName)).toBeInTheDocument();
});

it('toggles all rows when the Expand all checkbox is clicked', async () => {
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
renderWithRoute(<ResultsView title={Strings.metaData.pageTitle.results} />);

await screen.findByRole('table');

const expandAllCheckbox = screen.getByRole('checkbox', {
name: /Expand all/i,
});
expect(expandAllCheckbox).not.toBeChecked();
expect(screen.queryAllByTestId(/ExpandLessIcon/)).toHaveLength(0);

await user.click(expandAllCheckbox);
expect(expandAllCheckbox).toBeChecked();
const expandLessIcons = await screen.findAllByTestId(/ExpandLessIcon/);
expect(expandLessIcons.length).toBeGreaterThan(0);

await user.click(expandAllCheckbox);
expect(expandAllCheckbox).not.toBeChecked();
await waitFor(() => {
expect(screen.queryAllByTestId(/ExpandLessIcon/)).toHaveLength(0);
});
});
});
80 changes: 80 additions & 0 deletions src/__tests__/CompareResults/RevisionRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('<RevisionRow>', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);
const shortNameNode = await screen.findByText(shortName);
Expand Down Expand Up @@ -123,6 +124,7 @@ describe('Subtest count pills', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -151,6 +153,7 @@ describe('Subtest count pills', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand All @@ -172,6 +175,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -199,6 +203,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand All @@ -220,6 +225,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);

Expand All @@ -236,6 +242,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);
const expandRow = await screen.findByTestId(/ExpandMoreIcon/);
Expand All @@ -256,6 +263,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -284,6 +292,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand All @@ -305,6 +314,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand All @@ -323,6 +333,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -350,6 +361,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);

Expand All @@ -369,6 +381,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -397,6 +410,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);

Expand Down Expand Up @@ -435,6 +449,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
Expand All @@ -451,6 +466,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
Expand All @@ -468,6 +484,7 @@ describe('Expanded row', () => {
gridTemplateColumns='none'
replicates={false}
testVersion='mann-whitney-u'
expandAll={false}
/>,
);
const roles = await screen.findAllByRole('cell');
Expand All @@ -476,3 +493,66 @@ describe('Expanded row', () => {
});
});
});

describe('expandAll prop', () => {
it('starts expanded when expandAll is true', async () => {
const {
testCompareData: [rowData],
} = getTestData();

renderWithRoute(
<RevisionRow
result={rowData}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={true}
/>,
);

expect(await screen.findByTestId(/ExpandLessIcon/)).toBeInTheDocument();
});

it('starts collapsed when expandAll is false', async () => {
const {
testCompareData: [rowData],
} = getTestData();

renderWithRoute(
<RevisionRow
result={rowData}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={false}
/>,
);

expect(await screen.findByTestId(/ExpandMoreIcon/)).toBeInTheDocument();
});

it('lets the user individually collapse a row that was force-expanded', async () => {
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
const {
testCompareData: [rowData],
} = getTestData();

renderWithRoute(
<RevisionRow
result={rowData}
view={compareView}
gridTemplateColumns='none'
replicates={false}
testVersion='student-t'
expandAll={true}
/>,
);

const collapseButton = await screen.findByTestId(/ExpandLessIcon/);
await user.click(collapseButton);

expect(await screen.findByTestId(/ExpandMoreIcon/)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`Results View The table should match snapshot and other elements should
class="MuiGrid-root MuiGrid-container MuiGrid-direction-xs-row MuiGrid-spacing-xs-2 f1wpas00 css-13620ud-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-direction-xs-row MuiGrid-grid-md-4 MuiGrid-grid-xs-12 css-1mujxwq-MuiGrid-root"
class="MuiGrid-root MuiGrid-direction-xs-row MuiGrid-grid-md-3 MuiGrid-grid-xs-12 css-11ufmbb-MuiGrid-root"
>
<form
aria-label="Search by title, platform, revision or options"
Expand Down Expand Up @@ -309,6 +309,41 @@ exports[`Results View The table should match snapshot and other elements should
</button>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-direction-xs-row MuiGrid-grid-xs-auto css-zh2j38-MuiGrid-root"
>
<label
aria-label="Expand all rows"
class="MuiFormControlLabel-root MuiFormControlLabel-labelPlacementEnd css-1bsjtco-MuiFormControlLabel-root"
data-mui-internal-clone-element="true"
>
<span
class="MuiButtonBase-root MuiCheckbox-root MuiCheckbox-colorPrimary MuiCheckbox-sizeSmall PrivateSwitchBase-root MuiCheckbox-root MuiCheckbox-colorPrimary MuiCheckbox-sizeSmall MuiCheckbox-root MuiCheckbox-colorPrimary MuiCheckbox-sizeSmall css-1nff2up-MuiButtonBase-root-MuiSwitchBase-root-MuiCheckbox-root"
>
<input
class="PrivateSwitchBase-input css-12xagqm-MuiSwitchBase-root"
data-indeterminate="false"
type="checkbox"
/>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall css-54rgmy-MuiSvgIcon-root"
data-testid="CheckBoxOutlineBlankIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
/>
</svg>
</span>
<span
class="MuiTypography-root MuiTypography-body1 MuiFormControlLabel-label css-1vajmro-MuiTypography-root"
>
Expand all
</span>
</label>
</div>
</div>
<div
class="fdtnfac f1l733lh"
Expand Down Expand Up @@ -876,7 +911,7 @@ exports[`Results View The table should match snapshot and other elements should
data-testid="expand-revision-button"
>
<button
aria-controls="_r_11_"
aria-controls="_r_12_"
aria-expanded="false"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorPrimary MuiIconButton-sizeSmall css-1pgb59k-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
Expand Down Expand Up @@ -1075,7 +1110,7 @@ exports[`Results View The table should match snapshot and other elements should
data-testid="expand-revision-button"
>
<button
aria-controls="_r_18_"
aria-controls="_r_19_"
aria-expanded="false"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorPrimary MuiIconButton-sizeSmall css-1pgb59k-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
Expand Down Expand Up @@ -1274,7 +1309,7 @@ exports[`Results View The table should match snapshot and other elements should
data-testid="expand-revision-button"
>
<button
aria-controls="_r_1f_"
aria-controls="_r_1g_"
aria-expanded="false"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorPrimary MuiIconButton-sizeSmall css-1pgb59k-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
Expand Down Expand Up @@ -1473,7 +1508,7 @@ exports[`Results View The table should match snapshot and other elements should
data-testid="expand-revision-button"
>
<button
aria-controls="_r_1m_"
aria-controls="_r_1n_"
aria-expanded="false"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorPrimary MuiIconButton-sizeSmall css-1pgb59k-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
Expand Down
Loading