Move shlink-web-component tests to their own folder

This commit is contained in:
Alejandro Celaya 2023-08-02 09:01:44 +02:00
parent c48facc863
commit c794ff8b58
124 changed files with 455 additions and 371 deletions

View file

@ -0,0 +1,14 @@
import type { FC, ReactElement } from 'react';
import { useToggle } from '../../src/utils/helpers/hooks';
interface RenderModalArgs {
isOpen: boolean;
toggle: () => void;
}
export const TestModalWrapper: FC<{ renderModal: (args: RenderModalArgs) => ReactElement }> = (
{ renderModal },
) => {
const [isOpen, toggle] = useToggle(true);
return renderModal({ isOpen, toggle });
};

View file

@ -0,0 +1,20 @@
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ReactElement } from 'react';
export const setUpCanvas = (element: ReactElement) => {
const result = render(element);
const { container } = result;
const getEvents = () => {
const context = container.querySelector('canvas')?.getContext('2d');
// @ts-expect-error __getEvents is set by vitest-canvas-mock
return context?.__getEvents(); // eslint-disable-line no-underscore-dangle
};
return { ...result, events: getEvents(), getEvents };
};
export const renderWithEvents = (element: ReactElement) => ({
user: userEvent.setup(),
...render(element),
});

View file

@ -0,0 +1,18 @@
import { fromAny, fromPartial } from '@total-typescript/shoehorn';
const createLinkMock = () => ({
setAttribute: vi.fn(),
click: vi.fn(),
style: {},
});
export const appendChild = vi.fn();
export const removeChild = vi.fn();
export const windowMock = fromPartial<Window>({
document: fromAny({
createElement: vi.fn(createLinkMock),
body: { appendChild, removeChild },
}),
});

View file

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router'; import { MemoryRouter } from 'react-router';
import { AsideMenu } from '../../shlink-web-component/src/common/AsideMenu'; import { AsideMenu } from '../../src/common/AsideMenu';
describe('<AsideMenu />', () => { describe('<AsideMenu />', () => {
const setUp = () => render( const setUp = () => render(

View file

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShlinkApiErrorProps } from '../../shlink-web-component/src/common/ShlinkApiError';
import { ShlinkApiError } from '../../shlink-web-component/src/common/ShlinkApiError';
import type { InvalidArgumentError, ProblemDetailsError } from '../../src/api/types/errors'; import type { InvalidArgumentError, ProblemDetailsError } from '../../src/api/types/errors';
import { ErrorTypeV2, ErrorTypeV3 } from '../../src/api/types/errors'; import { ErrorTypeV2, ErrorTypeV3 } from '../../src/api/types/errors';
import type { ShlinkApiErrorProps } from '../../src/common/ShlinkApiError';
import { ShlinkApiError } from '../../src/common/ShlinkApiError';
describe('<ShlinkApiError />', () => { describe('<ShlinkApiError />', () => {
const setUp = (props: ShlinkApiErrorProps) => render(<ShlinkApiError {...props} />); const setUp = (props: ShlinkApiErrorProps) => render(<ShlinkApiError {...props} />);

View file

@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { Domain } from '../../shlink-web-component/src/domains/data';
import { DomainRow } from '../../shlink-web-component/src/domains/DomainRow';
import type { ShlinkDomainRedirects } from '../../src/api/types'; import type { ShlinkDomainRedirects } from '../../src/api/types';
import type { Domain } from '../../src/domains/data';
import { DomainRow } from '../../src/domains/DomainRow';
describe('<DomainRow />', () => { describe('<DomainRow />', () => {
const redirectsCombinations = [ const redirectsCombinations = [

View file

@ -1,7 +1,7 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { DomainSelector } from '../../shlink-web-component/src/domains/DomainSelector'; import { DomainSelector } from '../../src/domains/DomainSelector';
import type { DomainsList } from '../../shlink-web-component/src/domains/reducers/domainsList'; import type { DomainsList } from '../../src/domains/reducers/domainsList';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<DomainSelector />', () => { describe('<DomainSelector />', () => {

View file

@ -1,9 +1,8 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { ManageDomains } from '../../shlink-web-component/src/domains/ManageDomains'; import type { ProblemDetailsError, ShlinkDomain } from '../../src/api-contract';
import type { DomainsList } from '../../shlink-web-component/src/domains/reducers/domainsList'; import { ManageDomains } from '../../src/domains/ManageDomains';
import type { ShlinkDomain } from '../../src/api/types'; import type { DomainsList } from '../../src/domains/reducers/domainsList';
import type { ProblemDetailsError } from '../../src/api/types/errors';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ManageDomains />', () => { describe('<ManageDomains />', () => {
@ -16,7 +15,6 @@ describe('<ManageDomains />', () => {
editDomainRedirects={vi.fn()} editDomainRedirects={vi.fn()}
checkDomainHealth={vi.fn()} checkDomainHealth={vi.fn()}
domainsList={domainsList} domainsList={domainsList}
selectedServer={fromPartial({})}
/>, />,
); );

View file

@ -1,10 +1,10 @@
import { screen, waitForElementToBeRemoved } from '@testing-library/react'; import { screen, waitForElementToBeRemoved } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { Domain } from '../../../shlink-web-component/src/domains/data'; import type { SelectedServer } from '../../../../src/servers/data';
import { DomainDropdown } from '../../../shlink-web-component/src/domains/helpers/DomainDropdown'; import type { SemVer } from '../../../../src/utils/helpers/version';
import type { SelectedServer } from '../../../src/servers/data'; import type { Domain } from '../../../src/domains/data';
import type { SemVer } from '../../../src/utils/helpers/version'; import { DomainDropdown } from '../../../src/domains/helpers/DomainDropdown';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DomainDropdown />', () => { describe('<DomainDropdown />', () => {

View file

@ -1,7 +1,7 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { DomainStatus } from '../../../shlink-web-component/src/domains/data'; import type { DomainStatus } from '../../../src/domains/data';
import { DomainStatusIcon } from '../../../shlink-web-component/src/domains/helpers/DomainStatusIcon'; import { DomainStatusIcon } from '../../../src/domains/helpers/DomainStatusIcon';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DomainStatusIcon />', () => { describe('<DomainStatusIcon />', () => {

View file

@ -1,7 +1,7 @@
import { fireEvent, screen, waitFor } from '@testing-library/react'; import { fireEvent, screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { EditDomainRedirectsModal } from '../../../shlink-web-component/src/domains/helpers/EditDomainRedirectsModal'; import type { ShlinkDomain } from '../../../src/api-contract';
import type { ShlinkDomain } from '../../../src/api/types'; import { EditDomainRedirectsModal } from '../../../src/domains/helpers/EditDomainRedirectsModal';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<EditDomainRedirectsModal />', () => { describe('<EditDomainRedirectsModal />', () => {

View file

@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { editDomainRedirects } from '../../../shlink-web-component/src/domains/reducers/domainRedirects'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
import type { ShlinkDomainRedirects } from '../../../src/api/types'; import type { ShlinkDomainRedirects } from '../../../src/api/types';
import { editDomainRedirects } from '../../../src/domains/reducers/domainRedirects';
describe('domainRedirectsReducer', () => { describe('domainRedirectsReducer', () => {
describe('editDomainRedirects', () => { describe('editDomainRedirects', () => {

View file

@ -1,16 +1,16 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { Domain } from '../../../shlink-web-component/src/domains/data'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { EditDomainRedirects } from '../../../shlink-web-component/src/domains/reducers/domainRedirects'; import type { ShlinkState } from '../../../../src/container/types';
import { editDomainRedirects } from '../../../shlink-web-component/src/domains/reducers/domainRedirects'; import type { ShlinkDomainRedirects } from '../../../src/api/types';
import { parseApiError } from '../../../src/api/utils';
import type { Domain } from '../../../src/domains/data';
import type { EditDomainRedirects } from '../../../src/domains/reducers/domainRedirects';
import { editDomainRedirects } from '../../../src/domains/reducers/domainRedirects';
import { import {
domainsListReducerCreator, domainsListReducerCreator,
replaceRedirectsOnDomain, replaceRedirectsOnDomain,
replaceStatusOnDomain, replaceStatusOnDomain,
} from '../../../shlink-web-component/src/domains/reducers/domainsList'; } from '../../../src/domains/reducers/domainsList';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
import type { ShlinkDomainRedirects } from '../../../src/api/types';
import { parseApiError } from '../../../src/api/utils';
import type { ShlinkState } from '../../../src/container/types';
describe('domainsListReducer', () => { describe('domainsListReducer', () => {
const dispatch = vi.fn(); const dispatch = vi.fn();

View file

@ -1,8 +1,8 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { EventSourcePolyfill } from 'event-source-polyfill'; import { EventSourcePolyfill } from 'event-source-polyfill';
import { identity } from 'ramda'; import { identity } from 'ramda';
import { bindToMercureTopic } from '../../../shlink-web-component/src/mercure/helpers'; import { bindToMercureTopic } from '../../../src/mercure/helpers';
import type { MercureInfo } from '../../../shlink-web-component/src/mercure/reducers/mercureInfo'; import type { MercureInfo } from '../../../src/mercure/reducers/mercureInfo';
vi.mock('event-source-polyfill'); vi.mock('event-source-polyfill');

View file

@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { mercureInfoReducerCreator } from '../../../shlink-web-component/src/mercure/reducers/mercureInfo'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient'; import type { GetState } from '../../../../src/container/types';
import type { GetState } from '../../../src/container/types'; import { mercureInfoReducerCreator } from '../../../src/mercure/reducers/mercureInfo';
describe('mercureInfoReducer', () => { describe('mercureInfoReducer', () => {
const mercureInfo = { const mercureInfo = {

View file

@ -1,9 +1,9 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { MercureInfo } from '../../shlink-web-component/src/mercure/reducers/mercureInfo'; import type { MercureInfo } from '../../src/mercure/reducers/mercureInfo';
import { Overview as overviewCreator } from '../../shlink-web-component/src/overview/Overview'; import { Overview as overviewCreator } from '../../src/overview/Overview';
import { prettify } from '../../shlink-web-component/src/utils/helpers/numbers'; import { prettify } from '../../src/utils/helpers/numbers';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<Overview />', () => { describe('<Overview />', () => {

View file

@ -1,8 +1,8 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { HighlightCardProps } from '../../../shlink-web-component/src/overview/helpers/HighlightCard'; import type { HighlightCardProps } from '../../../src/overview/helpers/HighlightCard';
import { HighlightCard } from '../../../shlink-web-component/src/overview/helpers/HighlightCard'; import { HighlightCard } from '../../../src/overview/helpers/HighlightCard';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<HighlightCard />', () => { describe('<HighlightCard />', () => {

View file

@ -1,11 +1,18 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import type { VisitsHighlightCardProps } from '../../../shlink-web-component/src/overview/helpers/VisitsHighlightCard'; import type { VisitsHighlightCardProps } from '../../../src/overview/helpers/VisitsHighlightCard';
import { VisitsHighlightCard } from '../../../shlink-web-component/src/overview/helpers/VisitsHighlightCard'; import { VisitsHighlightCard } from '../../../src/overview/helpers/VisitsHighlightCard';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<VisitsHighlightCard />', () => { describe('<VisitsHighlightCard />', () => {
const setUp = (props: Partial<VisitsHighlightCardProps> = {}) => renderWithEvents( const setUp = (props: Partial<VisitsHighlightCardProps> = {}) => renderWithEvents(
<VisitsHighlightCard loading={false} visitsSummary={{ total: 0 }} excludeBots={false} title="" {...props} />, <VisitsHighlightCard
loading={false}
visitsSummary={{ total: 0 }}
excludeBots={false}
title=""
link=""
{...props}
/>,
); );
it.each([ it.each([

View file

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { CreateShortUrl as createShortUrlsCreator } from '../../shlink-web-component/src/short-urls/CreateShortUrl'; import { CreateShortUrl as createShortUrlsCreator } from '../../src/short-urls/CreateShortUrl';
import type { ShortUrlCreation } from '../../shlink-web-component/src/short-urls/reducers/shortUrlCreation'; import type { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation';
describe('<CreateShortUrl />', () => { describe('<CreateShortUrl />', () => {
const ShortUrlForm = () => <span>ShortUrlForm</span>; const ShortUrlForm = () => <span>ShortUrlForm</span>;

View file

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { EditShortUrl as createEditShortUrl } from '../../shlink-web-component/src/short-urls/EditShortUrl'; import { EditShortUrl as createEditShortUrl } from '../../src/short-urls/EditShortUrl';
import type { ShortUrlDetail } from '../../shlink-web-component/src/short-urls/reducers/shortUrlDetail'; import type { ShortUrlDetail } from '../../src/short-urls/reducers/shortUrlDetail';
import type { ShortUrlEdition } from '../../shlink-web-component/src/short-urls/reducers/shortUrlEdition'; import type { ShortUrlEdition } from '../../src/short-urls/reducers/shortUrlEdition';
describe('<EditShortUrl />', () => { describe('<EditShortUrl />', () => {
const shortUrlCreation = { validateUrls: true }; const shortUrlCreation = { validateUrls: true };

View file

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { Paginator } from '../../shlink-web-component/src/short-urls/Paginator';
import { ELLIPSIS } from '../../shlink-web-component/src/utils/helpers/pagination';
import type { ShlinkPaginator } from '../../src/api/types'; import type { ShlinkPaginator } from '../../src/api/types';
import { Paginator } from '../../src/short-urls/Paginator';
import { ELLIPSIS } from '../../src/utils/helpers/pagination';
describe('<Paginator />', () => { describe('<Paginator />', () => {
const buildPaginator = (pagesCount?: number) => fromPartial<ShlinkPaginator>({ pagesCount, currentPage: 1 }); const buildPaginator = (pagesCount?: number) => fromPartial<ShlinkPaginator>({ pagesCount, currentPage: 1 });

View file

@ -2,11 +2,11 @@ import { screen } from '@testing-library/react';
import type { UserEvent } from '@testing-library/user-event/setup/setup'; import type { UserEvent } from '@testing-library/user-event/setup/setup';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import type { Mode } from '../../shlink-web-component/src/short-urls/ShortUrlForm'; import type { ReachableServer, SelectedServer } from '../../../src/servers/data';
import { ShortUrlForm as createShortUrlForm } from '../../shlink-web-component/src/short-urls/ShortUrlForm'; import type { OptionalString } from '../../../src/utils/utils';
import { parseDate } from '../../shlink-web-component/src/utils/dates/helpers/date'; import type { Mode } from '../../src/short-urls/ShortUrlForm';
import type { ReachableServer, SelectedServer } from '../../src/servers/data'; import { ShortUrlForm as createShortUrlForm } from '../../src/short-urls/ShortUrlForm';
import type { OptionalString } from '../../src/utils/utils'; import { parseDate } from '../../src/utils/dates/helpers/date';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ShortUrlForm />', () => { describe('<ShortUrlForm />', () => {

View file

@ -2,10 +2,10 @@ import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { endOfDay, formatISO, startOfDay } from 'date-fns'; import { endOfDay, formatISO, startOfDay } from 'date-fns';
import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom'; import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom';
import { ShortUrlsFilteringBar as filteringBarCreator } from '../../shlink-web-component/src/short-urls/ShortUrlsFilteringBar'; import type { ReachableServer, SelectedServer } from '../../../src/servers/data';
import { formatDate } from '../../shlink-web-component/src/utils/dates/helpers/date'; import { ShortUrlsFilteringBar as filteringBarCreator } from '../../src/short-urls/ShortUrlsFilteringBar';
import type { DateRange } from '../../shlink-web-component/src/utils/dates/helpers/dateIntervals'; import { formatIsoDate } from '../../src/utils/dates/helpers/date';
import type { ReachableServer, SelectedServer } from '../../src/servers/data'; import type { DateRange } from '../../src/utils/dates/helpers/dateIntervals';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
vi.mock('react-router-dom', async () => ({ vi.mock('react-router-dom', async () => ({
@ -65,8 +65,8 @@ describe('<ShortUrlsFilteringBar />', () => {
expect(await screen.findByRole('menu')).toBeInTheDocument(); expect(await screen.findByRole('menu')).toBeInTheDocument();
expect(navigate).not.toHaveBeenCalled(); expect(navigate).not.toHaveBeenCalled();
dates.startDate && await user.type(screen.getByPlaceholderText('Since...'), formatDate()(dates.startDate) ?? ''); dates.startDate && await user.type(screen.getByPlaceholderText('Since...'), formatIsoDate(dates.startDate) ?? '');
dates.endDate && await user.type(screen.getByPlaceholderText('Until...'), formatDate()(dates.endDate) ?? ''); dates.endDate && await user.type(screen.getByPlaceholderText('Until...'), formatIsoDate(dates.endDate) ?? '');
expect(navigate).toHaveBeenLastCalledWith(`/server/1/list-short-urls/1?${expectedQuery}`); expect(navigate).toHaveBeenLastCalledWith(`/server/1/list-short-urls/1?${expectedQuery}`);
}); });

View file

@ -1,13 +1,13 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter, useNavigate } from 'react-router-dom'; import { MemoryRouter, useNavigate } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { SemVer } from '../../../src/utils/helpers/version';
import type { ShortUrlsOrder } from '../../shlink-web-component/src/short-urls/data'; import type { Settings } from '../../src';
import type { ShortUrlsList as ShortUrlsListModel } from '../../shlink-web-component/src/short-urls/reducers/shortUrlsList'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { ShortUrlsList as createShortUrlsList } from '../../shlink-web-component/src/short-urls/ShortUrlsList'; import type { ShortUrlsOrder } from '../../src/short-urls/data';
import type { ShortUrlsTableType } from '../../shlink-web-component/src/short-urls/ShortUrlsTable'; import type { ShortUrlsList as ShortUrlsListModel } from '../../src/short-urls/reducers/shortUrlsList';
import type { Settings } from '../../src/settings/reducers/settings'; import { ShortUrlsList as createShortUrlsList } from '../../src/short-urls/ShortUrlsList';
import type { SemVer } from '../../src/utils/helpers/version'; import type { ShortUrlsTableType } from '../../src/short-urls/ShortUrlsTable';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
vi.mock('react-router-dom', async () => ({ vi.mock('react-router-dom', async () => ({

View file

@ -1,10 +1,10 @@
import { fireEvent, screen } from '@testing-library/react'; import { fireEvent, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrlsOrderableFields } from '../../shlink-web-component/src/short-urls/data'; import type { SelectedServer } from '../../../src/servers/data';
import { SHORT_URLS_ORDERABLE_FIELDS } from '../../shlink-web-component/src/short-urls/data'; import type { ShortUrlsOrderableFields } from '../../src/short-urls/data';
import type { ShortUrlsList } from '../../shlink-web-component/src/short-urls/reducers/shortUrlsList'; import { SHORT_URLS_ORDERABLE_FIELDS } from '../../src/short-urls/data';
import { ShortUrlsTable as shortUrlsTableCreator } from '../../shlink-web-component/src/short-urls/ShortUrlsTable'; import type { ShortUrlsList } from '../../src/short-urls/reducers/shortUrlsList';
import type { SelectedServer } from '../../src/servers/data'; import { ShortUrlsTable as shortUrlsTableCreator } from '../../src/short-urls/ShortUrlsTable';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ShortUrlsTable />', () => { describe('<ShortUrlsTable />', () => {

View file

@ -1,5 +1,5 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { UseExistingIfFoundInfoIcon } from '../../shlink-web-component/src/short-urls/UseExistingIfFoundInfoIcon'; import { UseExistingIfFoundInfoIcon } from '../../src/short-urls/UseExistingIfFoundInfoIcon';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<UseExistingIfFoundInfoIcon />', () => { describe('<UseExistingIfFoundInfoIcon />', () => {

View file

@ -1,8 +1,8 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { CreateShortUrlResult as createResult } from '../../../shlink-web-component/src/short-urls/helpers/CreateShortUrlResult'; import type { TimeoutToggle } from '../../../../src/utils/helpers/hooks';
import type { ShortUrlCreation } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlCreation'; import { CreateShortUrlResult as createResult } from '../../../src/short-urls/helpers/CreateShortUrlResult';
import type { TimeoutToggle } from '../../../src/utils/helpers/hooks'; import type { ShortUrlCreation } from '../../../src/short-urls/reducers/shortUrlCreation';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<CreateShortUrlResult />', () => { describe('<CreateShortUrlResult />', () => {

View file

@ -1,10 +1,10 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { InvalidShortUrlDeletion } from '../../../src/api-contract';
import { DeleteShortUrlModal } from '../../../shlink-web-component/src/short-urls/helpers/DeleteShortUrlModal'; import { ErrorTypeV2, ErrorTypeV3 } from '../../../src/api-contract';
import type { ShortUrlDeletion } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlDeletion'; import type { ShortUrl } from '../../../src/short-urls/data';
import type { InvalidShortUrlDeletion } from '../../../src/api/types/errors'; import { DeleteShortUrlModal } from '../../../src/short-urls/helpers/DeleteShortUrlModal';
import { ErrorTypeV2, ErrorTypeV3 } from '../../../src/api/types/errors'; import type { ShortUrlDeletion } from '../../../src/short-urls/reducers/shortUrlDeletion';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
import { TestModalWrapper } from '../../__helpers__/TestModalWrapper'; import { TestModalWrapper } from '../../__helpers__/TestModalWrapper';

View file

@ -1,10 +1,10 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { NotFoundServer, SelectedServer } from '../../../../src/servers/data';
import { ExportShortUrlsBtn as createExportShortUrlsBtn } from '../../../shlink-web-component/src/short-urls/helpers/ExportShortUrlsBtn'; import type { ShortUrl } from '../../../src/short-urls/data';
import type { ReportExporter } from '../../../shlink-web-component/src/utils/services/ReportExporter'; import { ExportShortUrlsBtn as createExportShortUrlsBtn } from '../../../src/short-urls/helpers/ExportShortUrlsBtn';
import type { NotFoundServer, SelectedServer } from '../../../src/servers/data'; import type { ReportExporter } from '../../../src/utils/services/ReportExporter';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<ExportShortUrlsBtn />', () => { describe('<ExportShortUrlsBtn />', () => {

View file

@ -1,7 +1,7 @@
import { fireEvent, screen } from '@testing-library/react'; import { fireEvent, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { QrCodeModal as createQrCodeModal } from '../../../shlink-web-component/src/short-urls/helpers/QrCodeModal'; import type { SemVer } from '../../../../src/utils/helpers/version';
import type { SemVer } from '../../../src/utils/helpers/version'; import { QrCodeModal as createQrCodeModal } from '../../../src/short-urls/helpers/QrCodeModal';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<QrCodeModal />', () => { describe('<QrCodeModal />', () => {

View file

@ -1,10 +1,10 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { NotFoundServer, ReachableServer } from '../../../../src/servers/data';
import type { LinkSuffix } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink'; import type { ShortUrl } from '../../../src/short-urls/data';
import { ShortUrlDetailLink } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink'; import type { LinkSuffix } from '../../../src/short-urls/helpers/ShortUrlDetailLink';
import type { NotFoundServer, ReachableServer } from '../../../src/servers/data'; import { ShortUrlDetailLink } from '../../../src/short-urls/helpers/ShortUrlDetailLink';
describe('<ShortUrlDetailLink />', () => { describe('<ShortUrlDetailLink />', () => {
it.each([ it.each([

View file

@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { ShortUrlFormCheckboxGroup } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlFormCheckboxGroup'; import { ShortUrlFormCheckboxGroup } from '../../../src/short-urls/helpers/ShortUrlFormCheckboxGroup';
describe('<ShortUrlFormCheckboxGroup />', () => { describe('<ShortUrlFormCheckboxGroup />', () => {
it.each([ it.each([

View file

@ -1,9 +1,9 @@
import { render, screen, waitFor } from '@testing-library/react'; import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl, ShortUrlMeta } from '../../../shlink-web-component/src/short-urls/data';
import { ShortUrlStatus } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlStatus';
import type { ShlinkVisitsSummary } from '../../../src/api/types'; import type { ShlinkVisitsSummary } from '../../../src/api/types';
import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data';
import { ShortUrlStatus } from '../../../src/short-urls/helpers/ShortUrlStatus';
describe('<ShortUrlStatus />', () => { describe('<ShortUrlStatus />', () => {
const setUp = (shortUrl: ShortUrl) => ({ const setUp = (shortUrl: ShortUrl) => ({

View file

@ -1,8 +1,8 @@
import { render, screen, waitFor } from '@testing-library/react'; import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShortUrl } from '../../../src/short-urls/data';
import { ShortUrlVisitsCount } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlVisitsCount'; import { ShortUrlVisitsCount } from '../../../src/short-urls/helpers/ShortUrlVisitsCount';
describe('<ShortUrlVisitsCount />', () => { describe('<ShortUrlVisitsCount />', () => {
const setUp = (visitsCount: number, shortUrl: ShortUrl) => ({ const setUp = (visitsCount: number, shortUrl: ShortUrl) => ({

View file

@ -1,5 +1,5 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { ShortUrlsFilterDropdown } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlsFilterDropdown'; import { ShortUrlsFilterDropdown } from '../../../src/short-urls/helpers/ShortUrlsFilterDropdown';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<ShortUrlsFilterDropdown />', () => { describe('<ShortUrlsFilterDropdown />', () => {

View file

@ -3,13 +3,13 @@ import { fromPartial } from '@total-typescript/shoehorn';
import { addDays, formatISO, subDays } from 'date-fns'; import { addDays, formatISO, subDays } from 'date-fns';
import { last } from 'ramda'; import { last } from 'ramda';
import { MemoryRouter, useLocation } from 'react-router-dom'; import { MemoryRouter, useLocation } from 'react-router-dom';
import type { ShortUrl, ShortUrlMeta } from '../../../shlink-web-component/src/short-urls/data'; import type { ReachableServer } from '../../../../src/servers/data';
import { ShortUrlsRow as createShortUrlsRow } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlsRow'; import type { TimeoutToggle } from '../../../../src/utils/helpers/hooks';
import { now, parseDate } from '../../../shlink-web-component/src/utils/dates/helpers/date'; import type { OptionalString } from '../../../../src/utils/utils';
import type { ReachableServer } from '../../../src/servers/data'; import type { Settings } from '../../../src';
import type { Settings } from '../../../src/settings/reducers/settings'; import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data';
import type { TimeoutToggle } from '../../../src/utils/helpers/hooks'; import { ShortUrlsRow as createShortUrlsRow } from '../../../src/short-urls/helpers/ShortUrlsRow';
import type { OptionalString } from '../../../src/utils/utils'; import { now, parseDate } from '../../../src/utils/dates/helpers/date';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock'; import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock';

View file

@ -1,9 +1,9 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ReachableServer } from '../../../../src/servers/data';
import { ShortUrlsRowMenu as createShortUrlsRowMenu } from '../../../shlink-web-component/src/short-urls/helpers/ShortUrlsRowMenu'; import type { ShortUrl } from '../../../src/short-urls/data';
import type { ReachableServer } from '../../../src/servers/data'; import { ShortUrlsRowMenu as createShortUrlsRowMenu } from '../../../src/short-urls/helpers/ShortUrlsRowMenu';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<ShortUrlsRowMenu />', () => { describe('<ShortUrlsRowMenu />', () => {

View file

@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { Tags } from '../../../shlink-web-component/src/short-urls/helpers/Tags'; import { Tags } from '../../../src/short-urls/helpers/Tags';
import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock'; import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock';
describe('<Tags />', () => { describe('<Tags />', () => {

View file

@ -1,6 +1,6 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShortUrl } from '../../../src/short-urls/data';
import { shortUrlDataFromShortUrl, urlDecodeShortCode, urlEncodeShortCode } from '../../../shlink-web-component/src/short-urls/helpers'; import { shortUrlDataFromShortUrl, urlDecodeShortCode, urlEncodeShortCode } from '../../../src/short-urls/helpers';
describe('helpers', () => { describe('helpers', () => {
describe('shortUrlDataFromShortUrl', () => { describe('shortUrlDataFromShortUrl', () => {

View file

@ -1,6 +1,6 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { QrErrorCorrectionDropdown } from '../../../../shlink-web-component/src/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown'; import { QrErrorCorrectionDropdown } from '../../../../src/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown';
import type { QrErrorCorrection } from '../../../../shlink-web-component/src/utils/helpers/qrCodes'; import type { QrErrorCorrection } from '../../../../src/utils/helpers/qrCodes';
import { renderWithEvents } from '../../../__helpers__/setUpTest'; import { renderWithEvents } from '../../../__helpers__/setUpTest';
describe('<QrErrorCorrectionDropdown />', () => { describe('<QrErrorCorrectionDropdown />', () => {

View file

@ -1,6 +1,6 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { QrFormatDropdown } from '../../../../shlink-web-component/src/short-urls/helpers/qr-codes/QrFormatDropdown'; import { QrFormatDropdown } from '../../../../src/short-urls/helpers/qr-codes/QrFormatDropdown';
import type { QrCodeFormat } from '../../../../shlink-web-component/src/utils/helpers/qrCodes'; import type { QrCodeFormat } from '../../../../src/utils/helpers/qrCodes';
import { renderWithEvents } from '../../../__helpers__/setUpTest'; import { renderWithEvents } from '../../../__helpers__/setUpTest';
describe('<QrFormatDropdown />', () => { describe('<QrFormatDropdown />', () => {

View file

@ -1,11 +1,11 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ShlinkState } from '../../../../src/container/types';
import type { ShortUrl } from '../../../src/short-urls/data';
import { import {
createShortUrl as createShortUrlCreator, createShortUrl as createShortUrlCreator,
shortUrlCreationReducerCreator, shortUrlCreationReducerCreator,
} from '../../../shlink-web-component/src/short-urls/reducers/shortUrlCreation'; } from '../../../src/short-urls/reducers/shortUrlCreation';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
import type { ShlinkState } from '../../../src/container/types';
describe('shortUrlCreationReducer', () => { describe('shortUrlCreationReducer', () => {
const shortUrl = fromPartial<ShortUrl>({}); const shortUrl = fromPartial<ShortUrl>({});

View file

@ -1,10 +1,10 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ProblemDetailsError } from '../../../src/api/types/errors';
import { import {
deleteShortUrl as deleteShortUrlCreator, deleteShortUrl as deleteShortUrlCreator,
shortUrlDeletionReducerCreator, shortUrlDeletionReducerCreator,
} from '../../../shlink-web-component/src/short-urls/reducers/shortUrlDeletion'; } from '../../../src/short-urls/reducers/shortUrlDeletion';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
import type { ProblemDetailsError } from '../../../src/api/types/errors';
describe('shortUrlDeletionReducer', () => { describe('shortUrlDeletionReducer', () => {
const deleteShortUrlCall = vi.fn(); const deleteShortUrlCall = vi.fn();

View file

@ -1,9 +1,9 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import { shortUrlDetailReducerCreator } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlDetail'; import type { ShlinkState } from '../../../../src/container/types';
import type { ShortUrlsList } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlsList'; import type { ShortUrl } from '../../../src/short-urls/data';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient'; import { shortUrlDetailReducerCreator } from '../../../src/short-urls/reducers/shortUrlDetail';
import type { ShlinkState } from '../../../src/container/types'; import type { ShortUrlsList } from '../../../src/short-urls/reducers/shortUrlsList';
describe('shortUrlDetailReducer', () => { describe('shortUrlDetailReducer', () => {
const getShortUrlCall = vi.fn(); const getShortUrlCall = vi.fn();

View file

@ -1,11 +1,11 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShlinkState } from '../../../../src/container/types';
import type { SelectedServer } from '../../../../src/servers/data';
import type { ShortUrl } from '../../../src/short-urls/data';
import { import {
editShortUrl as editShortUrlCreator, editShortUrl as editShortUrlCreator,
shortUrlEditionReducerCreator, shortUrlEditionReducerCreator,
} from '../../../shlink-web-component/src/short-urls/reducers/shortUrlEdition'; } from '../../../src/short-urls/reducers/shortUrlEdition';
import type { ShlinkState } from '../../../src/container/types';
import type { SelectedServer } from '../../../src/servers/data';
describe('shortUrlEditionReducer', () => { describe('shortUrlEditionReducer', () => {
const longUrl = 'https://shlink.io'; const longUrl = 'https://shlink.io';

View file

@ -1,16 +1,16 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import { createShortUrl as createShortUrlCreator } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlCreation'; import type { ShlinkShortUrlsResponse } from '../../../src/api/types';
import { shortUrlDeleted } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlDeletion'; import type { ShortUrl } from '../../../src/short-urls/data';
import { editShortUrl as editShortUrlCreator } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlEdition'; import { createShortUrl as createShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlCreation';
import { shortUrlDeleted } from '../../../src/short-urls/reducers/shortUrlDeletion';
import { editShortUrl as editShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlEdition';
import { import {
listShortUrls as listShortUrlsCreator, listShortUrls as listShortUrlsCreator,
shortUrlsListReducerCreator, shortUrlsListReducerCreator,
} from '../../../shlink-web-component/src/short-urls/reducers/shortUrlsList'; } from '../../../src/short-urls/reducers/shortUrlsList';
import { createNewVisits } from '../../../shlink-web-component/src/visits/reducers/visitCreation'; import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
import type { CreateVisit } from '../../../shlink-web-component/src/visits/types'; import type { CreateVisit } from '../../../src/visits/types';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
import type { ShlinkShortUrlsResponse } from '../../../src/api/types';
describe('shortUrlsListReducer', () => { describe('shortUrlsListReducer', () => {
const shortCode = 'abc123'; const shortCode = 'abc123';

View file

@ -1,10 +1,10 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { identity } from 'ramda'; import { identity } from 'ramda';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import type { TagsList } from '../../shlink-web-component/src/tags/reducers/tagsList'; import type { TagsList } from '../../src/tags/reducers/tagsList';
import type { TagsListProps } from '../../shlink-web-component/src/tags/TagsList'; import type { TagsListProps } from '../../src/tags/TagsList';
import { TagsList as createTagsList } from '../../shlink-web-component/src/tags/TagsList'; import { TagsList as createTagsList } from '../../src/tags/TagsList';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<TagsList />', () => { describe('<TagsList />', () => {

View file

@ -1,8 +1,8 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { TagsTable as createTagsTable } from '../../shlink-web-component/src/tags/TagsTable'; import { TagsTable as createTagsTable } from '../../src/tags/TagsTable';
import { rangeOf } from '../../src/utils/utils'; import { rangeOf } from '../../src/utils/helpers';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
vi.mock('react-router-dom', async () => ({ vi.mock('react-router-dom', async () => ({

View file

@ -1,7 +1,7 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { TagsTableRow as createTagsTableRow } from '../../shlink-web-component/src/tags/TagsTableRow'; import { TagsTableRow as createTagsTableRow } from '../../src/tags/TagsTableRow';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
import { colorGeneratorMock } from '../utils/services/__mocks__/ColorGenerator.mock'; import { colorGeneratorMock } from '../utils/services/__mocks__/ColorGenerator.mock';

View file

@ -1,6 +1,6 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { DeleteTagConfirmModal } from '../../../shlink-web-component/src/tags/helpers/DeleteTagConfirmModal'; import { DeleteTagConfirmModal } from '../../../src/tags/helpers/DeleteTagConfirmModal';
import type { TagDeletion } from '../../../shlink-web-component/src/tags/reducers/tagDelete'; import type { TagDeletion } from '../../../src/tags/reducers/tagDelete';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DeleteTagConfirmModal />', () => { describe('<DeleteTagConfirmModal />', () => {

View file

@ -1,7 +1,7 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { EditTagModal as createEditTagModal } from '../../../shlink-web-component/src/tags/helpers/EditTagModal'; import { EditTagModal as createEditTagModal } from '../../../src/tags/helpers/EditTagModal';
import type { TagEdition } from '../../../shlink-web-component/src/tags/reducers/tagEdit'; import type { TagEdition } from '../../../src/tags/reducers/tagEdit';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<EditTagModal />', () => { describe('<EditTagModal />', () => {

View file

@ -1,9 +1,9 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { Tag } from '../../../shlink-web-component/src/tags/helpers/Tag'; import { MAIN_COLOR } from '../../../../src/utils/theme';
import type { ColorGenerator } from '../../../shlink-web-component/src/utils/services/ColorGenerator'; import { Tag } from '../../../src/tags/helpers/Tag';
import { MAIN_COLOR } from '../../../src/utils/theme'; import type { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
const hexToRgb = (hex: string) => { const hexToRgb = (hex: string) => {

View file

@ -1,7 +1,7 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { TagsSelector as createTagsSelector } from '../../../shlink-web-component/src/tags/helpers/TagsSelector'; import { TagsSelector as createTagsSelector } from '../../../src/tags/helpers/TagsSelector';
import type { TagsList } from '../../../shlink-web-component/src/tags/reducers/tagsList'; import type { TagsList } from '../../../src/tags/reducers/tagsList';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock'; import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerator.mock';

View file

@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { tagDeleted, tagDeleteReducerCreator } from '../../../shlink-web-component/src/tags/reducers/tagDelete'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient'; import type { ShlinkState } from '../../../../src/container/types';
import type { ShlinkState } from '../../../src/container/types'; import { tagDeleted, tagDeleteReducerCreator } from '../../../src/tags/reducers/tagDelete';
describe('tagDeleteReducer', () => { describe('tagDeleteReducer', () => {
const deleteTagsCall = vi.fn(); const deleteTagsCall = vi.fn();

View file

@ -1,8 +1,8 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { editTag as editTagCreator, tagEdited, tagEditReducerCreator } from '../../../shlink-web-component/src/tags/reducers/tagEdit'; import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ColorGenerator } from '../../../shlink-web-component/src/utils/services/ColorGenerator'; import type { ShlinkState } from '../../../../src/container/types';
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient'; import { editTag as editTagCreator, tagEdited, tagEditReducerCreator } from '../../../src/tags/reducers/tagEdit';
import type { ShlinkState } from '../../../src/container/types'; import type { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
describe('tagEditReducer', () => { describe('tagEditReducer', () => {
const oldName = 'foo'; const oldName = 'foo';

View file

@ -1,18 +1,18 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ShlinkState } from '../../../../src/container/types';
import { createShortUrl as createShortUrlCreator } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlCreation'; import type { ShortUrl } from '../../../src/short-urls/data';
import { tagDeleted } from '../../../shlink-web-component/src/tags/reducers/tagDelete'; import { createShortUrl as createShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlCreation';
import { tagEdited } from '../../../shlink-web-component/src/tags/reducers/tagEdit'; import { tagDeleted } from '../../../src/tags/reducers/tagDelete';
import { tagEdited } from '../../../src/tags/reducers/tagEdit';
import type { import type {
TagsList } from '../../../shlink-web-component/src/tags/reducers/tagsList'; TagsList } from '../../../src/tags/reducers/tagsList';
import { import {
filterTags, filterTags,
listTags as listTagsCreator, listTags as listTagsCreator,
tagsListReducerCreator, tagsListReducerCreator,
} from '../../../shlink-web-component/src/tags/reducers/tagsList'; } from '../../../src/tags/reducers/tagsList';
import { createNewVisits } from '../../../shlink-web-component/src/visits/reducers/visitCreation'; import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
import type { CreateVisit } from '../../../shlink-web-component/src/visits/types'; import type { CreateVisit } from '../../../src/visits/types';
import type { ShlinkState } from '../../../src/container/types';
describe('tagsListReducer', () => { describe('tagsListReducer', () => {
const state = (props: Partial<TagsList>) => fromPartial<TagsList>(props); const state = (props: Partial<TagsList>) => fromPartial<TagsList>(props);

View file

@ -1,5 +1,5 @@
import { CopyToClipboardIcon } from '../../shlink-web-component/src/utils/components/CopyToClipboardIcon'; import { CopyToClipboardIcon } from '../../../src/utils/components/CopyToClipboardIcon';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<CopyToClipboardIcon />', () => { describe('<CopyToClipboardIcon />', () => {
const onCopy = vi.fn(); const onCopy = vi.fn();

View file

@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { ExportBtn } from '../../shlink-web-component/src/utils/components/ExportBtn'; import { ExportBtn } from '../../../src/utils/components/ExportBtn';
describe('<ExportBtn />', () => { describe('<ExportBtn />', () => {
const setUp = (amount?: number, loading = false) => render(<ExportBtn amount={amount} loading={loading} />); const setUp = (amount?: number, loading = false) => render(<ExportBtn amount={amount} loading={loading} />);

View file

@ -1,8 +1,8 @@
import type { IconProp } from '@fortawesome/fontawesome-svg-core'; import type { IconProp } from '@fortawesome/fontawesome-svg-core';
import { faAppleAlt, faCalendar, faTable } from '@fortawesome/free-solid-svg-icons'; import { faAppleAlt, faCalendar, faTable } from '@fortawesome/free-solid-svg-icons';
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { IconInput } from '../../shlink-web-component/src/utils/components/IconInput'; import { IconInput } from '../../../src/utils/components/IconInput';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<IconInput />', () => { describe('<IconInput />', () => {
const setUp = (icon: IconProp, placeholder?: string) => renderWithEvents( const setUp = (icon: IconProp, placeholder?: string) => renderWithEvents(

View file

@ -1,8 +1,8 @@
import type { Placement } from '@popperjs/core'; import type { Placement } from '@popperjs/core';
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import type { InfoTooltipProps } from '../../shlink-web-component/src/utils/components/InfoTooltip'; import type { InfoTooltipProps } from '../../../src/utils/components/InfoTooltip';
import { InfoTooltip } from '../../shlink-web-component/src/utils/components/InfoTooltip'; import { InfoTooltip } from '../../../src/utils/components/InfoTooltip';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<InfoTooltip />', () => { describe('<InfoTooltip />', () => {
const setUp = (props: Partial<InfoTooltipProps> = {}) => renderWithEvents( const setUp = (props: Partial<InfoTooltipProps> = {}) => renderWithEvents(

View file

@ -1,6 +1,6 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { PaginationDropdown } from '../../shlink-web-component/src/utils/components/PaginationDropdown'; import { PaginationDropdown } from '../../../src/utils/components/PaginationDropdown';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<PaginationDropdown />', () => { describe('<PaginationDropdown />', () => {
const setValue = vi.fn(); const setValue = vi.fn();

View file

@ -1,8 +1,8 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { parseISO } from 'date-fns'; import { parseISO } from 'date-fns';
import type { DateInputProps } from '../../../shlink-web-component/src/utils/dates/DateInput'; import type { DateInputProps } from '../../../src/utils/dates/DateInput';
import { DateInput } from '../../../shlink-web-component/src/utils/dates/DateInput'; import { DateInput } from '../../../src/utils/dates/DateInput';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DateInput />', () => { describe('<DateInput />', () => {

View file

@ -1,8 +1,8 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { DropdownBtn } from '../../../shlink-frontend-kit/src/navigation/DropdownBtn'; import { DropdownBtn } from '../../../../shlink-frontend-kit/src';
import type { DateInterval } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals';
import { DATE_INTERVALS, rangeOrIntervalToString } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals';
import { DateIntervalDropdownItems } from '../../../src/utils/dates/DateIntervalDropdownItems'; import { DateIntervalDropdownItems } from '../../../src/utils/dates/DateIntervalDropdownItems';
import type { DateInterval } from '../../../src/utils/dates/helpers/dateIntervals';
import { DATE_INTERVALS, rangeOrIntervalToString } from '../../../src/utils/dates/helpers/dateIntervals';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DateIntervalDropdownItems />', () => { describe('<DateIntervalDropdownItems />', () => {

View file

@ -1,5 +1,5 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { DateRangeRow } from '../../../shlink-web-component/src/utils/dates/DateRangeRow'; import { DateRangeRow } from '../../../src/utils/dates/DateRangeRow';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DateRangeRow />', () => { describe('<DateRangeRow />', () => {

View file

@ -1,8 +1,8 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { DateRangeSelectorProps } from '../../../shlink-web-component/src/utils/dates/DateRangeSelector'; import type { DateRangeSelectorProps } from '../../../src/utils/dates/DateRangeSelector';
import { DateRangeSelector } from '../../../shlink-web-component/src/utils/dates/DateRangeSelector'; import { DateRangeSelector } from '../../../src/utils/dates/DateRangeSelector';
import type { DateInterval } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals'; import type { DateInterval } from '../../../src/utils/dates/helpers/dateIntervals';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<DateRangeSelector />', () => { describe('<DateRangeSelector />', () => {

View file

@ -1,7 +1,7 @@
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import { parseDate } from '../../../shlink-web-component/src/utils/dates/helpers/date'; import { parseDate } from '../../../src/utils/dates/helpers/date';
import type { TimeProps } from '../../../shlink-web-component/src/utils/dates/Time'; import type { TimeProps } from '../../../src/utils/dates/Time';
import { Time } from '../../../shlink-web-component/src/utils/dates/Time'; import { Time } from '../../../src/utils/dates/Time';
describe('<Time />', () => { describe('<Time />', () => {
const setUp = (props: TimeProps) => render(<Time {...props} />); const setUp = (props: TimeProps) => render(<Time {...props} />);

View file

@ -1,5 +1,5 @@
import { addDays, formatISO, subDays } from 'date-fns'; import { addDays, formatISO, subDays } from 'date-fns';
import { formatDate, formatIsoDate, isBeforeOrEqual, isBetween, parseDate } from '../../../shlink-web-component/src/utils/dates/helpers/date'; import { formatDate, formatIsoDate, isBeforeOrEqual, isBetween, parseDate } from '../../../../src/utils/dates/helpers/date';
describe('date', () => { describe('date', () => {
const now = new Date(); const now = new Date();

View file

@ -1,7 +1,7 @@
import { endOfDay, format, formatISO, startOfDay, subDays } from 'date-fns'; import { endOfDay, format, formatISO, startOfDay, subDays } from 'date-fns';
import { now, parseDate } from '../../../shlink-web-component/src/utils/dates/helpers/date'; import { now, parseDate } from '../../../../src/utils/dates/helpers/date';
import type { import type {
DateInterval } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals'; DateInterval } from '../../../../src/utils/dates/helpers/dateIntervals';
import { import {
dateRangeIsEmpty, dateRangeIsEmpty,
dateToMatchingInterval, dateToMatchingInterval,
@ -9,7 +9,7 @@ import {
rangeIsInterval, rangeIsInterval,
rangeOrIntervalToString, rangeOrIntervalToString,
toDateRange, toDateRange,
} from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals'; } from '../../../../src/utils/dates/helpers/dateIntervals';
describe('date-types', () => { describe('date-types', () => {
const daysBack = (days: number) => subDays(now(), days); const daysBack = (days: number) => subDays(now(), days);

View file

@ -3,7 +3,7 @@ import {
parseBooleanToString, parseBooleanToString,
parseOptionalBooleanToString, parseOptionalBooleanToString,
rangeOf, rangeOf,
} from '../../src/utils/utils'; } from '../../../src/utils/helpers';
describe('utils', () => { describe('utils', () => {
describe('rangeOf', () => { describe('rangeOf', () => {

View file

@ -1,4 +1,4 @@
import { roundTen } from '../../../shlink-web-component/src/utils/helpers/numbers'; import { roundTen } from '../../../src/utils/helpers/numbers';
describe('numbers', () => { describe('numbers', () => {
describe('roundTen', () => { describe('roundTen', () => {

View file

@ -1,5 +1,5 @@
import type { QrCodeFormat, QrErrorCorrection } from '../../../shlink-web-component/src/utils/helpers/qrCodes'; import type { QrCodeFormat, QrErrorCorrection } from '../../../src/utils/helpers/qrCodes';
import { buildQrCodeUrl } from '../../../shlink-web-component/src/utils/helpers/qrCodes'; import { buildQrCodeUrl } from '../../../src/utils/helpers/qrCodes';
describe('qrCodes', () => { describe('qrCodes', () => {
describe('buildQrCodeUrl', () => { describe('buildQrCodeUrl', () => {

View file

@ -1,4 +1,4 @@
import { parseQuery, stringifyQuery } from '../../../shlink-web-component/src/utils/helpers/query'; import { parseQuery, stringifyQuery } from '../../../src/utils/helpers/query';
describe('query', () => { describe('query', () => {
describe('parseQuery', () => { describe('parseQuery', () => {

View file

@ -1,7 +1,7 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { ColorGenerator } from '../../../shlink-web-component/src/utils/services/ColorGenerator'; import type { LocalStorage } from '../../../../src/utils/services/LocalStorage';
import type { LocalStorage } from '../../../src/utils/services/LocalStorage'; import { MAIN_COLOR } from '../../../../src/utils/theme';
import { MAIN_COLOR } from '../../../src/utils/theme'; import { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
describe('ColorGenerator', () => { describe('ColorGenerator', () => {
let colorGenerator: ColorGenerator; let colorGenerator: ColorGenerator;

View file

@ -0,0 +1,21 @@
import { ImageDownloader } from '../../../src/utils/services/ImageDownloader';
import { windowMock } from '../../__mocks__/Window.mock';
describe('ImageDownloader', () => {
const fetch = vi.fn();
let imageDownloader: ImageDownloader;
beforeEach(() => {
(global as any).URL = { createObjectURL: () => '' };
imageDownloader = new ImageDownloader(fetch, windowMock);
});
it('calls URL with response type blob', async () => {
fetch.mockResolvedValue({ blob: () => new Blob() });
await imageDownloader.saveImage('/foo/bar.png', 'my-image.png');
expect(fetch).toHaveBeenCalledWith('/foo/bar.png');
});
});

View file

@ -0,0 +1,43 @@
import { fromPartial } from '@total-typescript/shoehorn';
import { LocalStorage } from '../../../src/utils/services/LocalStorage';
describe('LocalStorage', () => {
const getItem = vi.fn((key) => (key === 'shlink.foo' ? JSON.stringify({ foo: 'bar' }) : null));
const setItem = vi.fn();
const localStorageMock = fromPartial<Storage>({ getItem, setItem });
let storage: LocalStorage;
beforeEach(() => {
storage = new LocalStorage(localStorageMock);
});
describe('set', () => {
it('writes an stringified representation of provided value in local storage', () => {
const value = { bar: 'baz' };
storage.set('foo', value);
expect(setItem).toHaveBeenCalledTimes(1);
expect(setItem).toHaveBeenCalledWith('shlink.foo', JSON.stringify(value));
});
});
describe('get', () => {
it('fetches item from local storage', () => {
storage.get('foo');
expect(getItem).toHaveBeenCalledTimes(1);
});
it('returns parsed value when requested value is found in local storage', () => {
const value = storage.get('foo');
expect(value).toEqual({ foo: 'bar' });
});
it('returns undefined when requested value is not found in local storage', () => {
const value = storage.get('bar');
expect(value).toBeUndefined();
});
});
});

View file

@ -1,6 +1,6 @@
import type { ExportableShortUrl } from '../../../shlink-web-component/src/short-urls/data'; import type { ExportableShortUrl } from '../../../src/short-urls/data';
import { ReportExporter } from '../../../shlink-web-component/src/utils/services/ReportExporter'; import { ReportExporter } from '../../../src/utils/services/ReportExporter';
import type { NormalizedVisit } from '../../../shlink-web-component/src/visits/types'; import type { NormalizedVisit } from '../../../src/visits/types';
import { windowMock } from '../../__mocks__/Window.mock'; import { windowMock } from '../../__mocks__/Window.mock';
describe('ReportExporter', () => { describe('ReportExporter', () => {

View file

@ -1,5 +1,5 @@
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ColorGenerator } from '../../../../shlink-web-component/src/utils/services/ColorGenerator'; import type { ColorGenerator } from '../../../../src/utils/services/ColorGenerator';
export const colorGeneratorMock = fromPartial<ColorGenerator>({ export const colorGeneratorMock = fromPartial<ColorGenerator>({
getColorForKey: vi.fn(() => 'red'), getColorForKey: vi.fn(() => 'red'),

View file

@ -1,6 +1,6 @@
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import type { OrderDir } from '../../../shlink-frontend-kit/src/ordering/ordering'; import type { OrderDir } from '../../../../shlink-frontend-kit/src/ordering/ordering';
import { TableOrderIcon } from '../../../shlink-web-component/src/utils/table/TableOrderIcon'; import { TableOrderIcon } from '../../../src/utils/table/TableOrderIcon';
describe('<TableOrderIcon />', () => { describe('<TableOrderIcon />', () => {
const setUp = (field: string, currentDir?: OrderDir, className?: string) => render( const setUp = (field: string, currentDir?: OrderDir, className?: string) => render(

View file

@ -2,9 +2,9 @@ import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { DomainVisits as createDomainVisits } from '../../shlink-web-component/src/visits/DomainVisits'; import { DomainVisits as createDomainVisits } from '../../src/visits/DomainVisits';
import type { DomainVisits } from '../../shlink-web-component/src/visits/reducers/domainVisits'; import type { DomainVisits } from '../../src/visits/reducers/domainVisits';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
vi.mock('react-router-dom', async () => ({ vi.mock('react-router-dom', async () => ({

View file

@ -2,9 +2,9 @@ import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { NonOrphanVisits as createNonOrphanVisits } from '../../shlink-web-component/src/visits/NonOrphanVisits'; import { NonOrphanVisits as createNonOrphanVisits } from '../../src/visits/NonOrphanVisits';
import type { VisitsInfo } from '../../shlink-web-component/src/visits/reducers/types'; import type { VisitsInfo } from '../../src/visits/reducers/types';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<NonOrphanVisits />', () => { describe('<NonOrphanVisits />', () => {

View file

@ -2,9 +2,9 @@ import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { OrphanVisits as createOrphanVisits } from '../../shlink-web-component/src/visits/OrphanVisits'; import { OrphanVisits as createOrphanVisits } from '../../src/visits/OrphanVisits';
import type { VisitsInfo } from '../../shlink-web-component/src/visits/reducers/types'; import type { VisitsInfo } from '../../src/visits/reducers/types';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<OrphanVisits />', () => { describe('<OrphanVisits />', () => {

View file

@ -3,10 +3,10 @@ import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import { identity } from 'ramda'; import { identity } from 'ramda';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import type { ShortUrlVisits as ShortUrlVisitsState } from '../../shlink-web-component/src/visits/reducers/shortUrlVisits'; import type { ShortUrlVisits as ShortUrlVisitsState } from '../../src/visits/reducers/shortUrlVisits';
import type { ShortUrlVisitsProps } from '../../shlink-web-component/src/visits/ShortUrlVisits'; import type { ShortUrlVisitsProps } from '../../src/visits/ShortUrlVisits';
import { ShortUrlVisits as createShortUrlVisits } from '../../shlink-web-component/src/visits/ShortUrlVisits'; import { ShortUrlVisits as createShortUrlVisits } from '../../src/visits/ShortUrlVisits';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ShortUrlVisits />', () => { describe('<ShortUrlVisits />', () => {

View file

@ -1,9 +1,9 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatDistance, parseISO } from 'date-fns'; import { formatDistance, parseISO } from 'date-fns';
import type { ShortUrlDetail } from '../../shlink-web-component/src/short-urls/reducers/shortUrlDetail'; import type { ShortUrlDetail } from '../../src/short-urls/reducers/shortUrlDetail';
import type { ShortUrlVisits } from '../../shlink-web-component/src/visits/reducers/shortUrlVisits'; import type { ShortUrlVisits } from '../../src/visits/reducers/shortUrlVisits';
import { ShortUrlVisitsHeader } from '../../shlink-web-component/src/visits/ShortUrlVisitsHeader'; import { ShortUrlVisitsHeader } from '../../src/visits/ShortUrlVisitsHeader';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ShortUrlVisitsHeader />', () => { describe('<ShortUrlVisitsHeader />', () => {

View file

@ -2,10 +2,10 @@ import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns'; import { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router'; import { MemoryRouter } from 'react-router';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub'; import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import type { TagVisits as TagVisitsStats } from '../../shlink-web-component/src/visits/reducers/tagVisits'; import type { TagVisits as TagVisitsStats } from '../../src/visits/reducers/tagVisits';
import type { TagVisitsProps } from '../../shlink-web-component/src/visits/TagVisits'; import type { TagVisitsProps } from '../../src/visits/TagVisits';
import { TagVisits as createTagVisits } from '../../shlink-web-component/src/visits/TagVisits'; import { TagVisits as createTagVisits } from '../../src/visits/TagVisits';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
vi.mock('react-router-dom', async () => ({ vi.mock('react-router-dom', async () => ({

View file

@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { ColorGenerator } from '../../shlink-web-component/src/utils/services/ColorGenerator'; import type { ColorGenerator } from '../../src/utils/services/ColorGenerator';
import type { TagVisits } from '../../shlink-web-component/src/visits/reducers/tagVisits'; import type { TagVisits } from '../../src/visits/reducers/tagVisits';
import { TagVisitsHeader } from '../../shlink-web-component/src/visits/TagVisitsHeader'; import { TagVisitsHeader } from '../../src/visits/TagVisitsHeader';
describe('<TagVisitsHeader />', () => { describe('<TagVisitsHeader />', () => {
const tagVisits = fromPartial<TagVisits>({ const tagVisits = fromPartial<TagVisits>({

View file

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { Visit } from '../../shlink-web-component/src/visits/types'; import type { Visit } from '../../src/visits/types';
import { VisitsHeader } from '../../shlink-web-component/src/visits/VisitsHeader'; import { VisitsHeader } from '../../src/visits/VisitsHeader';
describe('<VisitsHeader />', () => { describe('<VisitsHeader />', () => {
const visits: Visit[] = [fromPartial({}), fromPartial({}), fromPartial({})]; const visits: Visit[] = [fromPartial({}), fromPartial({}), fromPartial({})];

View file

@ -2,10 +2,10 @@ import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { createMemoryHistory } from 'history'; import { createMemoryHistory } from 'history';
import { Router } from 'react-router-dom'; import { Router } from 'react-router-dom';
import type { VisitsInfo } from '../../shlink-web-component/src/visits/reducers/types'; import { rangeOf } from '../../src/utils/helpers';
import type { Visit } from '../../shlink-web-component/src/visits/types'; import type { VisitsInfo } from '../../src/visits/reducers/types';
import { VisitsStats } from '../../shlink-web-component/src/visits/VisitsStats'; import type { Visit } from '../../src/visits/types';
import { rangeOf } from '../../src/utils/utils'; import { VisitsStats } from '../../src/visits/VisitsStats';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<VisitsStats />', () => { describe('<VisitsStats />', () => {

View file

@ -1,9 +1,9 @@
import { screen, waitFor } from '@testing-library/react'; import { screen, waitFor } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { NormalizedVisit } from '../../shlink-web-component/src/visits/types'; import { rangeOf } from '../../src/utils/helpers';
import type { VisitsTableProps } from '../../shlink-web-component/src/visits/VisitsTable'; import type { NormalizedVisit } from '../../src/visits/types';
import { VisitsTable } from '../../shlink-web-component/src/visits/VisitsTable'; import type { VisitsTableProps } from '../../src/visits/VisitsTable';
import { rangeOf } from '../../src/utils/utils'; import { VisitsTable } from '../../src/visits/VisitsTable';
import { renderWithEvents } from '../__helpers__/setUpTest'; import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<VisitsTable />', () => { describe('<VisitsTable />', () => {

View file

@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { ChartCard } from '../../../shlink-web-component/src/visits/charts/ChartCard'; import { ChartCard } from '../../../src/visits/charts/ChartCard';
describe('<ChartCard />', () => { describe('<ChartCard />', () => {
const setUp = (title: Function | string = '', footer?: ReactNode) => render( const setUp = (title: Function | string = '', footer?: ReactNode) => render(

View file

@ -1,5 +1,5 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { DoughnutChart } from '../../../shlink-web-component/src/visits/charts/DoughnutChart'; import { DoughnutChart } from '../../../src/visits/charts/DoughnutChart';
import { setUpCanvas } from '../../__helpers__/setUpTest'; import { setUpCanvas } from '../../__helpers__/setUpTest';
describe('<DoughnutChart />', () => { describe('<DoughnutChart />', () => {

View file

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import type { Chart, ChartDataset } from 'chart.js'; import type { Chart, ChartDataset } from 'chart.js';
import { DoughnutChartLegend } from '../../../shlink-web-component/src/visits/charts/DoughnutChartLegend'; import { DoughnutChartLegend } from '../../../src/visits/charts/DoughnutChartLegend';
describe('<DoughnutChartLegend />', () => { describe('<DoughnutChartLegend />', () => {
const labels = ['foo', 'bar', 'baz', 'foo2', 'bar2']; const labels = ['foo', 'bar', 'baz', 'foo2', 'bar2'];

View file

@ -1,5 +1,5 @@
import type { HorizontalBarChartProps } from '../../../shlink-web-component/src/visits/charts/HorizontalBarChart'; import type { HorizontalBarChartProps } from '../../../src/visits/charts/HorizontalBarChart';
import { HorizontalBarChart } from '../../../shlink-web-component/src/visits/charts/HorizontalBarChart'; import { HorizontalBarChart } from '../../../src/visits/charts/HorizontalBarChart';
import { setUpCanvas } from '../../__helpers__/setUpTest'; import { setUpCanvas } from '../../__helpers__/setUpTest';
describe('<HorizontalBarChart />', () => { describe('<HorizontalBarChart />', () => {

View file

@ -2,8 +2,8 @@ import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { fromPartial } from '@total-typescript/shoehorn'; import { fromPartial } from '@total-typescript/shoehorn';
import { formatISO, subDays, subMonths, subYears } from 'date-fns'; import { formatISO, subDays, subMonths, subYears } from 'date-fns';
import { LineChartCard } from '../../../shlink-web-component/src/visits/charts/LineChartCard'; import { LineChartCard } from '../../../src/visits/charts/LineChartCard';
import type { NormalizedVisit } from '../../../shlink-web-component/src/visits/types'; import type { NormalizedVisit } from '../../../src/visits/types';
import { setUpCanvas } from '../../__helpers__/setUpTest'; import { setUpCanvas } from '../../__helpers__/setUpTest';
describe('<LineChartCard />', () => { describe('<LineChartCard />', () => {

View file

@ -1,9 +1,9 @@
import { screen } from '@testing-library/react'; import { screen } from '@testing-library/react';
import { range } from 'ramda'; import { range } from 'ramda';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { SortableBarChartCard } from '../../../shlink-web-component/src/visits/charts/SortableBarChartCard'; import { rangeOf } from '../../../src/utils/helpers';
import type { Stats } from '../../../shlink-web-component/src/visits/types'; import { SortableBarChartCard } from '../../../src/visits/charts/SortableBarChartCard';
import { rangeOf } from '../../../src/utils/utils'; import type { Stats } from '../../../src/visits/types';
import { renderWithEvents } from '../../__helpers__/setUpTest'; import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<SortableBarChartCard />', () => { describe('<SortableBarChartCard />', () => {

Some files were not shown because too many files have changed in this diff Show more