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
14 changes: 14 additions & 0 deletions .changeset/sour-pants-drive.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не уверен что в название пропа стоит зашивать Search
мб безопасней будет просто описать clear: always, onHover или типо того?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

статус прыгает, остальное ок)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@alfalab/core-components': minor
'@alfalab/core-components-input': minor
---

##### Input

Раобота пропа `clear` разделена на 2 механики:
- `false` или `never` — не отображается
- `true` или `always` — отображается всегда
- `auto` — отображается только при взаимодействии c input (hover, focus)
- Исправлен размер контейнера иконки статусов (success, error)

Булевы значения будут удалены в core-components@51
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 133 additions & 2 deletions packages/input/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Input', () => {
expect(ref.current.classList.contains('wrapperClassName'));
});

it('should set `data-test-id` atribute to input', () => {
it('should set `data-test-id` attribute to input', () => {
const dti = 'input-dti';
const { getByTestId } = render(
<Input
Expand Down Expand Up @@ -75,10 +75,21 @@ describe('Input', () => {
);

expect(getByTestIdHint(testIds.hint)).toBeInTheDocument();
expect(getByTestId(testIds.successIcon)).toBeInTheDocument();
expect(getByTestId(testIds.clearIcon)).toBeInTheDocument();
});

it('should set success `data-test-id` attribute to input', () => {
const dti = 'input-dti';

const { getByTestId } = render(
<Input dataTestId={dti} value='value' clear='auto' success={true} />,
);

const testIds = getInputTestIds(dti);

expect(getByTestId(testIds.successIcon)).toBeInTheDocument();
});

it('should set `aria-label` atribute to input', () => {
const label = 'label';
const { getByLabelText } = render(<Input block={true} label={label} />);
Expand Down Expand Up @@ -425,4 +436,124 @@ describe('Input', () => {

expect(unmount).not.toThrow();
});

describe('clearButton tests', () => {
const dti = 'input-dti';

describe('auto', () => {
it('should not render if status icon and empty input', () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='' clear='auto' success={true} />,
);

const testIds = getInputTestIds(dti);

expect(queryByTestId(testIds.clearIcon)).not.toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).toBeInTheDocument();
});

it('should not render if status icon', () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='auto' success={true} />,
);

const testIds = getInputTestIds(dti);

expect(queryByTestId(testIds.clearIcon)).not.toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).toBeInTheDocument();
});

it('should render if status icon and focus input', async () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='auto' success={true} />,
);

const testIds = getInputTestIds(dti);

const inputElement = queryByTestId(testIds.input);

if (inputElement) {
await userEvent.click(inputElement);
}

expect(queryByTestId(testIds.clearIcon)).toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).not.toBeInTheDocument();
});

it('should render if status icons and hover input', async () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='auto' success={true} />,
);

const testIds = getInputTestIds(dti);

const inputElement = queryByTestId(testIds.input);

if (inputElement) {
await userEvent.hover(inputElement);
}

expect(queryByTestId(testIds.clearIcon)).toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).not.toBeInTheDocument();
});
});

describe('always', () => {
it('should render if status icon', () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='always' success={true} />,
);

const testIds = getInputTestIds(dti);

expect(queryByTestId(testIds.clearIcon)).toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).not.toBeInTheDocument();
});

it('should render if status icon and focus input', async () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='always' success={true} />,
);

const testIds = getInputTestIds(dti);

const inputElement = queryByTestId(testIds.input);

if (inputElement) {
await userEvent.click(inputElement);
}

expect(queryByTestId(testIds.clearIcon)).toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).not.toBeInTheDocument();
});

it('should render if status icon and hover input', async () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='value' clear='always' success={true} />,
);

const testIds = getInputTestIds(dti);

const inputElement = queryByTestId(testIds.input);

if (inputElement) {
await userEvent.hover(inputElement);
}

expect(queryByTestId(testIds.clearIcon)).toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).not.toBeInTheDocument();
});

it('should not render if status and empty input', async () => {
const { queryByTestId } = render(
<Input dataTestId={dti} value='' clear='always' success={true} />,
);

const testIds = getInputTestIds(dti);

expect(queryByTestId(testIds.clearIcon)).not.toBeInTheDocument();
expect(queryByTestId(testIds.successIcon)).toBeInTheDocument();
});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading