Migrated Overview test from enzyme to react testing library

This commit is contained in:
Alejandro Celaya
2022-05-02 19:19:47 +02:00
parent 0de8eb1568
commit 8918b1ac96
3 changed files with 49 additions and 63 deletions

View File

@@ -13,7 +13,6 @@ import { ShlinkShortUrlsListParams } from '../api/types';
import { supportsNonOrphanVisits } from '../utils/helpers/features';
import { getServerId, SelectedServer } from './data';
import { HighlightCard } from './helpers/HighlightCard';
import { ForServerVersionProps } from './helpers/ForServerVersion';
interface OverviewConnectProps {
shortUrlsList: ShortUrlsListState;
@@ -28,7 +27,6 @@ interface OverviewConnectProps {
export const Overview = (
ShortUrlsTable: FC<ShortUrlsTableProps>,
CreateShortUrl: FC<CreateShortUrlProps>,
ForServerVersion: FC<ForServerVersionProps>,
) => boundToMercureHub(({
shortUrlsList,
listShortUrls,
@@ -61,12 +59,7 @@ export const Overview = (
</div>
<div className="col-lg-6 col-xl-3 mb-3">
<HighlightCard title="Orphan visits" link={`/server/${serverId}/orphan-visits`}>
<ForServerVersion minVersion="2.6.0">
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount ?? 0)}
</ForServerVersion>
<ForServerVersion maxVersion="2.5.*">
<small className="text-muted"><i>Shlink 2.6 is needed</i></small>
</ForServerVersion>
{loadingVisits ? 'Loading...' : prettify(orphanVisitsCount ?? 0)}
</HighlightCard>
</div>
<div className="col-lg-6 col-xl-3 mb-3">

View File

@@ -61,7 +61,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator) => {
bottle.serviceFactory('ServerError', ServerError, 'DeleteServerButton');
bottle.decorator('ServerError', connect(['servers', 'selectedServer']));
bottle.serviceFactory('Overview', Overview, 'ShortUrlsTable', 'CreateShortUrl', 'ForServerVersion');
bottle.serviceFactory('Overview', Overview, 'ShortUrlsTable', 'CreateShortUrl');
bottle.decorator('Overview', connect(
['shortUrlsList', 'tagsList', 'selectedServer', 'mercureInfo', 'visitsOverview'],
['listShortUrls', 'listTags', 'createNewVisits', 'loadMercureInfo', 'loadVisitsOverview'],