Skip to content

Commit 012fc52

Browse files
committed
Simplify TagsSelector test
1 parent 11c2777 commit 012fc52

3 files changed

Lines changed: 22 additions & 84 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [Unreleased]
8+
### Added
9+
* *Nothing*
10+
11+
### Changed
12+
* Replace `react-tag-autocomplete` with `TagsAutocomplete` from shlink-frontend-kit.
13+
14+
### Deprecated
15+
* *Nothing*
16+
17+
### Removed
18+
* *Nothing*
19+
20+
### Fixed
21+
* *Nothing*
22+
23+
724
## [0.14.2] - 2025-06-11
825
### Added
926
* *Nothing*

test/tags/helpers/TagsSelector.test.tsx

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,6 @@ describe('<TagsSelector />', () => {
3434
expect(screen.getByPlaceholderText('Add tags to the URL')).toBeInTheDocument();
3535
});
3636

37-
it('contains expected tags', () => {
38-
setUp();
39-
40-
expect(screen.getByText('foo')).toBeInTheDocument();
41-
expect(screen.getByText('bar')).toBeInTheDocument();
42-
});
43-
44-
it('contains expected suggestions', async () => {
45-
const { container, user } = setUp();
46-
47-
expect(container.querySelector('.react-tags__listbox')).not.toBeInTheDocument();
48-
expect(screen.queryByText('baz')).not.toBeInTheDocument();
49-
50-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), 'ba');
51-
52-
expect(container.querySelector('.react-tags__listbox')).toBeInTheDocument();
53-
expect(screen.getByText('baz')).toBeInTheDocument();
54-
});
55-
56-
it('limits the amount of suggestions', async () => {
57-
const { user } = setUp({ allTags: ['foo', 'foo1', 'foo2', 'foo3', 'foo4', 'foo5', 'foo6', 'foo7'] });
58-
59-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), 'fo');
60-
61-
// First results are in the document
62-
expect(screen.getByText('foo')).toBeInTheDocument();
63-
expect(screen.getByText('foo1')).toBeInTheDocument();
64-
expect(screen.getByText('foo2')).toBeInTheDocument();
65-
expect(screen.getByText('foo3')).toBeInTheDocument();
66-
expect(screen.getByText('foo4')).toBeInTheDocument();
67-
expect(screen.getByText('foo5')).toBeInTheDocument();
68-
// While the last ones are not
69-
expect(screen.queryByText('foo6')).not.toBeInTheDocument();
70-
expect(screen.queryByText('foo7')).not.toBeInTheDocument();
71-
});
72-
7337
it.each([
7438
['The-New-Tag', [...tags, 'the-new-tag']],
7539
['AnOTH er tag ', [...tags, 'anoth-er-tag']],
@@ -82,51 +46,4 @@ describe('<TagsSelector />', () => {
8246
await user.type(screen.getByPlaceholderText('Add tags to the URL'), '{Enter}');
8347
expect(onChange).toHaveBeenCalledWith(expectedTags);
8448
});
85-
86-
it('splits tags when several comma-separated ones are pasted', async () => {
87-
const { user } = setUp();
88-
89-
expect(onChange).not.toHaveBeenCalled();
90-
await user.click(screen.getByPlaceholderText('Add tags to the URL'));
91-
await user.paste('comma,separated,tags');
92-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), '{Enter}');
93-
expect(onChange).toHaveBeenCalledWith([...tags, 'comma', 'separated', 'tags']);
94-
});
95-
96-
it.each([
97-
['foo', 'bar'],
98-
['bar', 'foo'],
99-
])('invokes onChange when tags are deleted', async (removedLabel, expected) => {
100-
const { user } = setUp();
101-
102-
await user.click(screen.getByLabelText(`Remove ${removedLabel}`));
103-
expect(onChange).toHaveBeenCalledWith([expected]);
104-
});
105-
106-
it('displays "Add tag" option for new tags', async () => {
107-
const { user } = setUp();
108-
109-
expect(screen.queryByText(/^Add "/)).not.toBeInTheDocument();
110-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), 'new-tag');
111-
expect(screen.getByText(/^Add "/)).toBeInTheDocument();
112-
});
113-
114-
it('displays "Tag not found" for unknown tags when add is not allowed', async () => {
115-
const { user } = setUp({ allowNew: false });
116-
117-
expect(screen.queryByText('Tag not found')).not.toBeInTheDocument();
118-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), 'not-found-tag');
119-
expect(screen.getByText('Tag not found')).toBeInTheDocument();
120-
});
121-
122-
it.each([
123-
['startsWith' as TagFilteringMode, ['foo', 'foobar']],
124-
['includes' as TagFilteringMode, ['foo', 'barfoo', 'foobar']],
125-
])('filters suggestions with different algorithm based on filtering mode', async (tagFilteringMode, expectedTags) => {
126-
const { user } = setUp({ tagFilteringMode, allTags: ['foo', 'barfoo', 'foobar'] });
127-
128-
await user.type(screen.getByPlaceholderText('Add tags to the URL'), ' Foo');
129-
130-
expectedTags.forEach((tag) => expect(screen.getByText(tag)).toBeInTheDocument());
131-
});
13249
});

test/visits/visits-comparison/VisitsComparisonCollector.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ describe('<VisitsComparisonCollector />', () => {
5151
const compareButton = screen.getByText(/^Compare/);
5252

5353
expect(screen.getAllByRole('listitem')).toHaveLength(itemsAmount);
54-
expect(compareButton).toHaveAttribute('aria-disabled', isDisabled ? 'true' : 'false');
54+
if (isDisabled) {
55+
expect(compareButton).toBeDisabled();
56+
} else {
57+
expect(compareButton).not.toBeDisabled();
58+
}
5559
});
5660

5761
it('can clear selected items', async () => {

0 commit comments

Comments
 (0)