mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Ensured visits amount card displays warning for old shlink versions
This commit is contained in:
parent
32957835b3
commit
b9905c8bf4
3 changed files with 21 additions and 3 deletions
|
@ -11,6 +11,7 @@ import { CreateShortUrlProps } from '../short-urls/CreateShortUrl';
|
|||
import { VisitsOverview } from '../visits/reducers/visitsOverview';
|
||||
import { isServerWithId, SelectedServer } from './data';
|
||||
import './Overview.scss';
|
||||
import { Versions } from '../utils/helpers/version';
|
||||
|
||||
interface OverviewConnectProps {
|
||||
shortUrlsList: ShortUrlsListState;
|
||||
|
@ -25,6 +26,7 @@ interface OverviewConnectProps {
|
|||
export const Overview = (
|
||||
ShortUrlsTable: FC<ShortUrlsTableProps>,
|
||||
CreateShortUrl: FC<CreateShortUrlProps>,
|
||||
ForServerVersion: FC<Versions>,
|
||||
) => boundToMercureHub(({
|
||||
shortUrlsList,
|
||||
listShortUrls,
|
||||
|
@ -51,7 +53,14 @@ export const Overview = (
|
|||
<div className="col-sm-4">
|
||||
<Card className="overview__card mb-2" body>
|
||||
<CardTitle tag="h5" className="overview__card-title">Visits</CardTitle>
|
||||
<CardText tag="h2">{loadingVisits ? 'Loading...' : prettify(visitsCount)}</CardText>
|
||||
<CardText tag="h2">
|
||||
<ForServerVersion minVersion="2.2.0">
|
||||
{loadingVisits ? 'Loading...' : prettify(visitsCount)}
|
||||
</ForServerVersion>
|
||||
<ForServerVersion maxVersion="2.1.*">
|
||||
<small className="text-muted"><i>Shlink 2.2 is needed</i></small>
|
||||
</ForServerVersion>
|
||||
</CardText>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="col-sm-4">
|
||||
|
|
|
@ -44,7 +44,7 @@ const provideServices = (bottle: Bottle, connect: ConnectDecorator, withRouter:
|
|||
bottle.serviceFactory('ServerError', ServerError, 'DeleteServerButton');
|
||||
bottle.decorator('ServerError', connect([ 'servers', 'selectedServer' ]));
|
||||
|
||||
bottle.serviceFactory('Overview', Overview, 'ShortUrlsTable', 'CreateShortUrl');
|
||||
bottle.serviceFactory('Overview', Overview, 'ShortUrlsTable', 'CreateShortUrl', 'ForServerVersion');
|
||||
bottle.decorator('Overview', connect(
|
||||
[ 'shortUrlsList', 'tagsList', 'selectedServer', 'mercureInfo', 'visitsOverview' ],
|
||||
[ 'listShortUrls', 'listTags', 'createNewVisits', 'loadMercureInfo', 'loadVisitsOverview' ],
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { FC } from 'react';
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { CardText } from 'reactstrap';
|
||||
|
@ -14,10 +15,11 @@ describe('<Overview />', () => {
|
|||
let wrapper: ShallowWrapper;
|
||||
const ShortUrlsTable = () => null;
|
||||
const CreateShortUrl = () => null;
|
||||
const ForServerVersion: FC = ({ children }) => <>{children}</>;
|
||||
const listShortUrls = jest.fn();
|
||||
const listTags = jest.fn();
|
||||
const loadVisitsOverview = jest.fn();
|
||||
const Overview = overviewCreator(ShortUrlsTable, CreateShortUrl);
|
||||
const Overview = overviewCreator(ShortUrlsTable, CreateShortUrl, ForServerVersion);
|
||||
const shortUrls = {
|
||||
pagination: { totalItems: 83710 },
|
||||
};
|
||||
|
@ -61,6 +63,13 @@ describe('<Overview />', () => {
|
|||
expect(cards.at(2).html()).toContain(prettify(3));
|
||||
});
|
||||
|
||||
test('first card displays warning for old shlink versions', () => {
|
||||
const wrapper = createWrapper();
|
||||
const firstCard = wrapper.find(CardText).first();
|
||||
|
||||
expect(firstCard.html()).toContain('Shlink 2.2 is needed');
|
||||
});
|
||||
|
||||
test('nests complex components', () => {
|
||||
const wrapper = createWrapper();
|
||||
|
||||
|
|
Loading…
Reference in a new issue