mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 20:26:40 +00:00
Updated tags list to display visits and short URLs when remote shlink version allows it
This commit is contained in:
@@ -6,19 +6,23 @@ import TagBullet from '../../src/tags/helpers/TagBullet';
|
||||
|
||||
describe('<TagCard />', () => {
|
||||
let wrapper;
|
||||
const tagStats = {
|
||||
shortUrlsCount: 48,
|
||||
visitsCount: 23257,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
const TagCard = createTagCard(() => '', () => '', {});
|
||||
const TagCard = createTagCard(() => '', () => '', () => '', {});
|
||||
|
||||
wrapper = shallow(<TagCard tag="ssr" currentServerId="1" />);
|
||||
wrapper = shallow(<TagCard tag="ssr" selectedServer={{ id: 1, serverNotFound: false }} tagStats={tagStats} />);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
||||
it('shows a TagBullet and a link to the list filtering by the tag', () => {
|
||||
const link = wrapper.find(Link);
|
||||
const links = wrapper.find(Link);
|
||||
const bullet = wrapper.find(TagBullet);
|
||||
|
||||
expect(link.prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
||||
expect(links.at(0).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
||||
expect(bullet.prop('tag')).toEqual('ssr');
|
||||
});
|
||||
|
||||
@@ -45,4 +49,13 @@ describe('<TagCard />', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('shows expected tag stats', () => {
|
||||
const links = wrapper.find(Link);
|
||||
|
||||
expect(links.at(1).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
||||
expect(links.at(1).text()).toContain('48');
|
||||
expect(links.at(2).prop('to')).toEqual('/server/1/tags/ssr/visits');
|
||||
expect(links.at(2).text()).toContain('23,257');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('<TagsList />', () => {
|
||||
it('renders the proper amount of groups and cards based on the amount of tags', () => {
|
||||
const amountOfTags = 10;
|
||||
const amountOfGroups = 4;
|
||||
const wrapper = createWrapper({ filteredTags: rangeOf(amountOfTags, (i) => `tag_${i}`) });
|
||||
const wrapper = createWrapper({ filteredTags: rangeOf(amountOfTags, (i) => `tag_${i}`), stats: {} });
|
||||
const cards = wrapper.find(TagCard);
|
||||
const groups = wrapper.find('.col-md-6');
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('tagsListReducer', () => {
|
||||
it('dispatches loaded lists when no error occurs', async () => {
|
||||
const tags = [ 'foo', 'bar', 'baz' ];
|
||||
|
||||
listTagsMock.mockResolvedValue(tags);
|
||||
listTagsMock.mockResolvedValue({ data: tags, stats: [] });
|
||||
buildShlinkApiClient.mockReturnValue({ listTags: listTagsMock });
|
||||
|
||||
await listTags(buildShlinkApiClient, true)()(dispatch, getState);
|
||||
@@ -112,7 +112,7 @@ describe('tagsListReducer', () => {
|
||||
expect(getState).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: LIST_TAGS_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: LIST_TAGS, tags });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: LIST_TAGS, tags, stats: {} });
|
||||
});
|
||||
|
||||
const assertErrorResult = async () => {
|
||||
|
||||
@@ -141,7 +141,7 @@ describe('ShlinkApiClient', () => {
|
||||
|
||||
const result = await listTags();
|
||||
|
||||
expect(expectedTags).toEqual(result);
|
||||
expect({ data: expectedTags }).toEqual(result);
|
||||
expect(axiosSpy).toHaveBeenCalledWith(expect.objectContaining({ url: '/tags', method: 'GET' }));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user