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 { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router';
import { AsideMenu } from '../../shlink-web-component/src/common/AsideMenu';
import { AsideMenu } from '../../src/common/AsideMenu';
describe('<AsideMenu />', () => {
const setUp = () => render(

View file

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
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 { ErrorTypeV2, ErrorTypeV3 } from '../../src/api/types/errors';
import type { ShlinkApiErrorProps } from '../../src/common/ShlinkApiError';
import { ShlinkApiError } from '../../src/common/ShlinkApiError';
describe('<ShlinkApiError />', () => {
const setUp = (props: ShlinkApiErrorProps) => render(<ShlinkApiError {...props} />);

View file

@ -1,8 +1,8 @@
import { render, screen } from '@testing-library/react';
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 { Domain } from '../../src/domains/data';
import { DomainRow } from '../../src/domains/DomainRow';
describe('<DomainRow />', () => {
const redirectsCombinations = [

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
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 { editDomainRedirects } from '../../../src/domains/reducers/domainRedirects';
describe('domainRedirectsReducer', () => {
describe('editDomainRedirects', () => {

View file

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

View file

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

View file

@ -1,7 +1,7 @@
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 { GetState } from '../../../src/container/types';
import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { GetState } from '../../../../src/container/types';
import { mercureInfoReducerCreator } from '../../../src/mercure/reducers/mercureInfo';
describe('mercureInfoReducer', () => {
const mercureInfo = {

View file

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

View file

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

View file

@ -1,11 +1,18 @@
import { screen, waitFor } from '@testing-library/react';
import type { VisitsHighlightCardProps } from '../../../shlink-web-component/src/overview/helpers/VisitsHighlightCard';
import { VisitsHighlightCard } from '../../../shlink-web-component/src/overview/helpers/VisitsHighlightCard';
import type { VisitsHighlightCardProps } from '../../../src/overview/helpers/VisitsHighlightCard';
import { VisitsHighlightCard } from '../../../src/overview/helpers/VisitsHighlightCard';
import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<VisitsHighlightCard />', () => {
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([

View file

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

View file

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

View file

@ -1,9 +1,9 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
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 { Paginator } from '../../src/short-urls/Paginator';
import { ELLIPSIS } from '../../src/utils/helpers/pagination';
describe('<Paginator />', () => {
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 { fromPartial } from '@total-typescript/shoehorn';
import { formatISO } from 'date-fns';
import type { Mode } from '../../shlink-web-component/src/short-urls/ShortUrlForm';
import { ShortUrlForm as createShortUrlForm } from '../../shlink-web-component/src/short-urls/ShortUrlForm';
import { parseDate } from '../../shlink-web-component/src/utils/dates/helpers/date';
import type { ReachableServer, SelectedServer } from '../../src/servers/data';
import type { OptionalString } from '../../src/utils/utils';
import type { ReachableServer, SelectedServer } from '../../../src/servers/data';
import type { OptionalString } from '../../../src/utils/utils';
import type { Mode } from '../../src/short-urls/ShortUrlForm';
import { ShortUrlForm as createShortUrlForm } from '../../src/short-urls/ShortUrlForm';
import { parseDate } from '../../src/utils/dates/helpers/date';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<ShortUrlForm />', () => {

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
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';
describe('<UseExistingIfFoundInfoIcon />', () => {

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { fireEvent, screen } from '@testing-library/react';
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';
describe('<QrCodeModal />', () => {

View file

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

View file

@ -1,5 +1,5 @@
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 />', () => {
it.each([

View file

@ -1,9 +1,9 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
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 { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data';
import { ShortUrlStatus } from '../../../src/short-urls/helpers/ShortUrlStatus';
describe('<ShortUrlStatus />', () => {
const setUp = (shortUrl: ShortUrl) => ({

View file

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

View file

@ -1,5 +1,5 @@
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';
describe('<ShortUrlsFilterDropdown />', () => {

View file

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

View file

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

View file

@ -1,5 +1,5 @@
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';
describe('<Tags />', () => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
import { screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
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 { colorGeneratorMock } from '../utils/services/__mocks__/ColorGenerator.mock';

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
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 { ShlinkState } from '../../../src/container/types';
import type { ShlinkApiClient } from '../../../../src/api/services/ShlinkApiClient';
import type { ShlinkState } from '../../../../src/container/types';
import { tagDeleted, tagDeleteReducerCreator } from '../../../src/tags/reducers/tagDelete';
describe('tagDeleteReducer', () => {
const deleteTagsCall = vi.fn();

View file

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

View file

@ -1,18 +1,18 @@
import { fromPartial } from '@total-typescript/shoehorn';
import type { ShortUrl } from '../../../shlink-web-component/src/short-urls/data';
import { createShortUrl as createShortUrlCreator } from '../../../shlink-web-component/src/short-urls/reducers/shortUrlCreation';
import { tagDeleted } from '../../../shlink-web-component/src/tags/reducers/tagDelete';
import { tagEdited } from '../../../shlink-web-component/src/tags/reducers/tagEdit';
import type { ShlinkState } from '../../../../src/container/types';
import type { ShortUrl } from '../../../src/short-urls/data';
import { createShortUrl as createShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlCreation';
import { tagDeleted } from '../../../src/tags/reducers/tagDelete';
import { tagEdited } from '../../../src/tags/reducers/tagEdit';
import type {
TagsList } from '../../../shlink-web-component/src/tags/reducers/tagsList';
TagsList } from '../../../src/tags/reducers/tagsList';
import {
filterTags,
listTags as listTagsCreator,
tagsListReducerCreator,
} from '../../../shlink-web-component/src/tags/reducers/tagsList';
import { createNewVisits } from '../../../shlink-web-component/src/visits/reducers/visitCreation';
import type { CreateVisit } from '../../../shlink-web-component/src/visits/types';
import type { ShlinkState } from '../../../src/container/types';
} from '../../../src/tags/reducers/tagsList';
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
import type { CreateVisit } from '../../../src/visits/types';
describe('tagsListReducer', () => {
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 { renderWithEvents } from '../__helpers__/setUpTest';
import { CopyToClipboardIcon } from '../../../src/utils/components/CopyToClipboardIcon';
import { renderWithEvents } from '../../__helpers__/setUpTest';
describe('<CopyToClipboardIcon />', () => {
const onCopy = vi.fn();

View file

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

View file

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

View file

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

View file

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

View file

@ -1,8 +1,8 @@
import { screen, waitFor } from '@testing-library/react';
import { DropdownBtn } from '../../../shlink-frontend-kit/src/navigation/DropdownBtn';
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 { DropdownBtn } from '../../../../shlink-frontend-kit/src';
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';
describe('<DateIntervalDropdownItems />', () => {

View file

@ -1,5 +1,5 @@
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';
describe('<DateRangeRow />', () => {

View file

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

View file

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

View file

@ -1,5 +1,5 @@
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', () => {
const now = new Date();

View file

@ -1,7 +1,7 @@
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 {
DateInterval } from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals';
DateInterval } from '../../../../src/utils/dates/helpers/dateIntervals';
import {
dateRangeIsEmpty,
dateToMatchingInterval,
@ -9,7 +9,7 @@ import {
rangeIsInterval,
rangeOrIntervalToString,
toDateRange,
} from '../../../shlink-web-component/src/utils/dates/helpers/dateIntervals';
} from '../../../../src/utils/dates/helpers/dateIntervals';
describe('date-types', () => {
const daysBack = (days: number) => subDays(now(), days);

View file

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

View file

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

View file

@ -1,7 +1,7 @@
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 { MAIN_COLOR } from '../../../src/utils/theme';
import type { LocalStorage } from '../../../../src/utils/services/LocalStorage';
import { MAIN_COLOR } from '../../../../src/utils/theme';
import { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
describe('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 { ReportExporter } from '../../../shlink-web-component/src/utils/services/ReportExporter';
import type { NormalizedVisit } from '../../../shlink-web-component/src/visits/types';
import type { ExportableShortUrl } from '../../../src/short-urls/data';
import { ReportExporter } from '../../../src/utils/services/ReportExporter';
import type { NormalizedVisit } from '../../../src/visits/types';
import { windowMock } from '../../__mocks__/Window.mock';
describe('ReportExporter', () => {

View file

@ -1,5 +1,5 @@
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>({
getColorForKey: vi.fn(() => 'red'),

View file

@ -1,6 +1,6 @@
import { render } from '@testing-library/react';
import type { OrderDir } from '../../../shlink-frontend-kit/src/ordering/ordering';
import { TableOrderIcon } from '../../../shlink-web-component/src/utils/table/TableOrderIcon';
import type { OrderDir } from '../../../../shlink-frontend-kit/src/ordering/ordering';
import { TableOrderIcon } from '../../../src/utils/table/TableOrderIcon';
describe('<TableOrderIcon />', () => {
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 { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub';
import { DomainVisits as createDomainVisits } from '../../shlink-web-component/src/visits/DomainVisits';
import type { DomainVisits } from '../../shlink-web-component/src/visits/reducers/domainVisits';
import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { DomainVisits as createDomainVisits } from '../../src/visits/DomainVisits';
import type { DomainVisits } from '../../src/visits/reducers/domainVisits';
import { renderWithEvents } from '../__helpers__/setUpTest';
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 { formatISO } from 'date-fns';
import { MemoryRouter } from 'react-router-dom';
import type { MercureBoundProps } from '../../shlink-web-component/src/mercure/helpers/boundToMercureHub';
import { NonOrphanVisits as createNonOrphanVisits } from '../../shlink-web-component/src/visits/NonOrphanVisits';
import type { VisitsInfo } from '../../shlink-web-component/src/visits/reducers/types';
import type { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { NonOrphanVisits as createNonOrphanVisits } from '../../src/visits/NonOrphanVisits';
import type { VisitsInfo } from '../../src/visits/reducers/types';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<NonOrphanVisits />', () => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/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 />', () => {
const setUp = (title: Function | string = '', footer?: ReactNode) => render(

View file

@ -1,5 +1,5 @@
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';
describe('<DoughnutChart />', () => {

View file

@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
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 />', () => {
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 { HorizontalBarChart } from '../../../shlink-web-component/src/visits/charts/HorizontalBarChart';
import type { HorizontalBarChartProps } from '../../../src/visits/charts/HorizontalBarChart';
import { HorizontalBarChart } from '../../../src/visits/charts/HorizontalBarChart';
import { setUpCanvas } from '../../__helpers__/setUpTest';
describe('<HorizontalBarChart />', () => {

View file

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

View file

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

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