mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 23:07:26 +03:00
Ensured tags, servers and domains search is case insensitive
This commit is contained in:
parent
4a92d0ff11
commit
f69bda351d
6 changed files with 9 additions and 9 deletions
|
@ -65,7 +65,7 @@ export default buildReducer<DomainsList, DomainsCombinedAction>({
|
||||||
({ ...initialState, domains, filteredDomains: domains, defaultRedirects }),
|
({ ...initialState, domains, filteredDomains: domains, defaultRedirects }),
|
||||||
[FILTER_DOMAINS]: (state, { searchTerm }) => ({
|
[FILTER_DOMAINS]: (state, { searchTerm }) => ({
|
||||||
...state,
|
...state,
|
||||||
filteredDomains: state.domains.filter(({ domain }) => domain.toLowerCase().match(searchTerm)),
|
filteredDomains: state.domains.filter(({ domain }) => domain.toLowerCase().match(searchTerm.toLowerCase())),
|
||||||
}),
|
}),
|
||||||
[EDIT_DOMAIN_REDIRECTS]: (state, { domain, redirects }) => ({
|
[EDIT_DOMAIN_REDIRECTS]: (state, { domain, redirects }) => ({
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const ManageServers = (
|
||||||
const allServers = Object.values(servers);
|
const allServers = Object.values(servers);
|
||||||
const [serversList, setServersList] = useState(allServers);
|
const [serversList, setServersList] = useState(allServers);
|
||||||
const filterServers = (searchTerm: string) => setServersList(
|
const filterServers = (searchTerm: string) => setServersList(
|
||||||
allServers.filter(({ name, url }) => `${name} ${url}`.match(searchTerm)),
|
allServers.filter(({ name, url }) => `${name} ${url}`.toLowerCase().match(searchTerm.toLowerCase())),
|
||||||
);
|
);
|
||||||
const hasAutoConnect = serversList.some(({ autoConnect }) => !!autoConnect);
|
const hasAutoConnect = serversList.some(({ autoConnect }) => !!autoConnect);
|
||||||
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
const [errorImporting, setErrorImporting] = useTimeoutToggle(false, SHOW_IMPORT_MSG_TIME);
|
||||||
|
|
|
@ -96,7 +96,7 @@ export default buildReducer<TagsList, TagsCombinedAction>({
|
||||||
}),
|
}),
|
||||||
[FILTER_TAGS]: (state, { searchTerm }) => ({
|
[FILTER_TAGS]: (state, { searchTerm }) => ({
|
||||||
...state,
|
...state,
|
||||||
filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm)),
|
filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm.toLowerCase())),
|
||||||
}),
|
}),
|
||||||
[CREATE_VISITS]: (state, { createdVisits }) => ({
|
[CREATE_VISITS]: (state, { createdVisits }) => ({
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe('domainsListReducer', () => {
|
||||||
const buildShlinkApiClient = () => Mock.of<ShlinkApiClient>({ listDomains, health });
|
const buildShlinkApiClient = () => Mock.of<ShlinkApiClient>({ listDomains, health });
|
||||||
const filteredDomains = [
|
const filteredDomains = [
|
||||||
Mock.of<Domain>({ domain: 'foo', status: 'validating' }),
|
Mock.of<Domain>({ domain: 'foo', status: 'validating' }),
|
||||||
Mock.of<Domain>({ domain: 'boo', status: 'validating' }),
|
Mock.of<Domain>({ domain: 'Boo', status: 'validating' }),
|
||||||
];
|
];
|
||||||
const domains = [...filteredDomains, Mock.of<Domain>({ domain: 'bar', status: 'validating' })];
|
const domains = [...filteredDomains, Mock.of<Domain>({ domain: 'bar', status: 'validating' })];
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ describe('domainsListReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filters domains on FILTER_DOMAINS', () => {
|
it('filters domains on FILTER_DOMAINS', () => {
|
||||||
expect(reducer(Mock.of<DomainsList>({ domains }), action(FILTER_DOMAINS, { searchTerm: 'oo' }))).toEqual(
|
expect(reducer(Mock.of<DomainsList>({ domains }), action(FILTER_DOMAINS, { searchTerm: 'oO' }))).toEqual(
|
||||||
{ domains, filteredDomains },
|
{ domains, filteredDomains },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,7 @@ describe('<ManageServers />', () => {
|
||||||
await waitFor(() => expect(screen.getAllByText(/^ManageServersRow/)).toHaveLength(1));
|
await waitFor(() => expect(screen.getAllByText(/^ManageServersRow/)).toHaveLength(1));
|
||||||
expect(screen.queryByText('No servers found.')).not.toBeInTheDocument();
|
expect(screen.queryByText('No servers found.')).not.toBeInTheDocument();
|
||||||
|
|
||||||
await search('ba');
|
await search('Ba');
|
||||||
await waitFor(() => expect(screen.getAllByText(/^ManageServersRow/)).toHaveLength(2));
|
await waitFor(() => expect(screen.getAllByText(/^ManageServersRow/)).toHaveLength(2));
|
||||||
expect(screen.queryByText('No servers found.')).not.toBeInTheDocument();
|
expect(screen.queryByText('No servers found.')).not.toBeInTheDocument();
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,9 @@ describe('tagsListReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filters original list of tags by provided search term on FILTER_TAGS', () => {
|
it('filters original list of tags by provided search term on FILTER_TAGS', () => {
|
||||||
const tags = ['foo', 'bar', 'baz', 'foo2', 'fo'];
|
const tags = ['foo', 'bar', 'baz', 'Foo2', 'fo'];
|
||||||
const searchTerm = 'fo';
|
const searchTerm = 'Fo';
|
||||||
const filteredTags = ['foo', 'foo2', 'fo'];
|
const filteredTags = ['foo', 'Foo2', 'fo'];
|
||||||
|
|
||||||
expect(reducer(state({ tags }), { type: FILTER_TAGS, searchTerm } as any)).toEqual({
|
expect(reducer(state({ tags }), { type: FILTER_TAGS, searchTerm } as any)).toEqual({
|
||||||
tags,
|
tags,
|
||||||
|
|
Loading…
Reference in a new issue