Skip to content

Commit

Permalink
Replace limitTags test with regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Oct 14, 2024
1 parent 0582456 commit cc68375
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
35 changes: 1 addition & 34 deletions packages/mui-material/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,39 +414,6 @@ describe('<Autocomplete />', () => {
expect(getAllByRole('button', { hidden: false })).to.have.lengthOf(5);
}
});

// Test for https://github.com/mui/material-ui/issues/42432
it('when the input box needs to expand downward, the listbox should remain open.', () => {
const options = [
'The Lord of the Rings: The Return of the King',
'The Good, the Bad and the Ugly',
'The Shawshank Redemption',
'Star Wars: Episode V - The Empire Strikes Back',
];
const defaultValue = [
'The Lord of the Rings: The Return of the King',
'The Good, the Bad and the Ugly',
'The Shawshank Redemption',
];

render(
<Autocomplete
multiple
limitTags={2}
options={options}
defaultValue={defaultValue}
renderInput={(params) => <TextField {...params} />}
sx={{ width: 500 }}
/>,
);

const textbox = screen.getByRole('combobox');

fireEvent.mouseDown(textbox);

const listbox = screen.getByRole('listbox');
expect(listbox).toBeVisible();
});
});

describe('prop: filterSelectedOptions', () => {
Expand Down Expand Up @@ -896,7 +863,7 @@ describe('<Autocomplete />', () => {
/>,
);

expect(queryByRole('listbox')).to.equal(null);
expect(queryByRole('listbox')).to.equal(null);

const popupIndicator = getByTestId('popup-indicator');
await user.click(popupIndicator);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import TextField from '@mui/material/TextField';
import Autocomplete from '@mui/material/Autocomplete';

export default function StandardAutocomplete() {
return (
<div style={{ height: 220 }}>
<Autocomplete
multiple
limitTags={2}
options={['One', 'Two', 'Three']}
defaultValue={['One', 'Two', 'Three']}
renderInput={(params) => <TextField {...params} />}
sx={{ width: 300 }}
/>
</div>
);
}
14 changes: 14 additions & 0 deletions test/regressions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ async function main() {
await takeScreenshot({ testcase, route: '/regression-Rating/PreciseFocusVisibleRating3' });
});
});

describe('Autocomplete', () => {
it('should not close immediately when textbox expands', async () => {
const testcase = await renderFixture(
'/regression-Autocomplete/TextboxExpandsOnListboxOpen',
);
await page.getByRole('combobox').click();
await page.waitForTimeout(10);
await takeScreenshot({
testcase,
route: '/regression-Autocomplete/TextboxExpandsOnListboxOpen2',
});
});
});
});

run();
Expand Down

0 comments on commit cc68375

Please sign in to comment.