Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable autofill for time selection field #6279

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { render, screen } from 'tests/test-utils';

import CustomTimePicker from './CustomTimePicker';

const mockProps = {
onSelect: jest.fn(),
onError: jest.fn(),
items: [],
selectedValue: '',
selectedTime: '',
open: false,
setOpen: jest.fn(),
onValidCustomDateChange: jest.fn(),
onCustomTimeStatusUpdate: jest.fn(),
newPopover: false,
customDateTimeVisible: false,
setCustomDTPickerVisible: jest.fn(),
onCustomDateHandler: jest.fn(),
handleGoLive: jest.fn(),
};

describe('CustomTimePicker Component', () => {
it('should render the time selection input with autocomplete "off"', async () => {
render(
<CustomTimePicker
onSelect={mockProps.onSelect}
onError={mockProps.onError}
items={mockProps.items}
selectedValue={mockProps.selectedValue}
selectedTime={mockProps.selectedTime}
open={mockProps.open}
setOpen={mockProps.setOpen}
onValidCustomDateChange={mockProps.onValidCustomDateChange}
onCustomTimeStatusUpdate={mockProps.onCustomTimeStatusUpdate}
newPopover={mockProps.newPopover}
customDateTimeVisible={mockProps.customDateTimeVisible}
setCustomDTPickerVisible={mockProps.setCustomDTPickerVisible}
onCustomDateHandler={mockProps.onCustomDateHandler}
handleGoLive={mockProps.handleGoLive}
/>,
);

const timeSelectionInput = screen.getByTestId('timeSelection-input');

expect(timeSelectionInput).toBeInTheDocument();

expect(timeSelectionInput).toHaveAttribute('autocomplete', 'off');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ function CustomTimePicker({
}}
>
<Input
autoComplete="off"
data-testid="timeSelection-input"
className="timeSelection-input"
type="text"
status={inputValue && inputStatus === 'error' ? 'error' : ''}
Expand Down
Loading