mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
* calculate distance between current user and queried user * fix query for unset location * use database to calculate distance * rename distance to distance to me, 100% calculation done in DB * distanceToMe tests * lint fixes * remove comments * Show user teaser popover with badges, Desktop * Refactor UserTeaser and add mobile popover support * Avoid click propagation (WIP) * Prevent event propagation * Adjust alignment and font sizes * More spacing for statistics * Add distance, simplify user link * Refactor location info into own component * Add tests for UserTeaserPopup * Refactor and test LocationInfo * Query distanceToMe, rename distance to distanceToMe * Update test * Improve tests for UserTeaser, WIP * Fix tests * DistanceToMe on User instead of Location * Revert "DistanceToMe on User instead of Location" This reverts commit 96c9db00a44cd120e47bfe9534d3e066a194744c. * Fix notifications * Refactor UserTeaser and fix location info * Fix group member crash * Show 0 distance * Fit in popover on small screens * Allow access to profile on desktop * Revert backend changes * Load user teaser popover data only when needed * Fix type mismatch * Refactor for clarity and accessibility * Litte refactorings and improvements * Fix popover test * Adapt and fix tests * Fix tests and bugs * Add placeholder * cypress: adapt user teaser locator to changes * Remove delays and scrolling * Disable popovers in notification list and fix layout * Remove flickering * Make overlay catch all pointer events on touch devices * Re-add attribute for E2E test * Fix test, return to mouseover * fix snapshot --------- Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de> Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com> Co-authored-by: mahula <lenzmath@posteo.de>
100 lines
2.5 KiB
JavaScript
100 lines
2.5 KiB
JavaScript
import { render } from '@testing-library/vue'
|
|
import { RouterLinkStub } from '@vue/test-utils'
|
|
import UserTeaserPopover from './UserTeaserPopover.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
const user = {
|
|
id: 'id',
|
|
name: 'Tilda Swinton',
|
|
slug: 'tilda-swinton',
|
|
badgeVerification: {
|
|
id: 'bv1',
|
|
icon: '/icons/verified',
|
|
description: 'Verified',
|
|
isDefault: false,
|
|
},
|
|
badgeTrophiesSelected: [
|
|
{
|
|
id: 'trophy1',
|
|
icon: '/icons/trophy1',
|
|
description: 'Trophy 1',
|
|
isDefault: false,
|
|
},
|
|
{
|
|
id: 'trophy2',
|
|
icon: '/icons/trophy2',
|
|
description: 'Trophy 2',
|
|
isDefault: false,
|
|
},
|
|
{
|
|
id: 'empty',
|
|
icon: '/icons/empty',
|
|
description: 'Empty',
|
|
isDefault: true,
|
|
},
|
|
],
|
|
}
|
|
|
|
const userLink = {
|
|
name: 'profile-id-slug',
|
|
params: { slug: 'slug', id: 'id' },
|
|
}
|
|
|
|
describe('UserTeaserPopover', () => {
|
|
const Wrapper = ({ badgesEnabled = true, withUserLink = true, onTouchScreen = false }) => {
|
|
const mockIsTouchDevice = onTouchScreen
|
|
jest.mock('../utils/isTouchDevice', () => ({
|
|
isTouchDevice: jest.fn(() => mockIsTouchDevice),
|
|
}))
|
|
return render(UserTeaserPopover, {
|
|
localVue,
|
|
propsData: {
|
|
userId: 'id',
|
|
userLink: withUserLink ? userLink : null,
|
|
},
|
|
data: () => ({
|
|
User: [user],
|
|
}),
|
|
stubs: {
|
|
NuxtLink: RouterLinkStub,
|
|
},
|
|
mocks: {
|
|
$t: jest.fn((t) => t),
|
|
$env: {
|
|
BADGES_ENABLED: badgesEnabled,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
describe('given a touch device', () => {
|
|
it('shows button when userLink is provided', () => {
|
|
const wrapper = Wrapper({ withUserLink: true, onTouchScreen: true })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
it('does not show button when userLink is not provided', () => {
|
|
const wrapper = Wrapper({ withUserLink: false, onTouchScreen: true })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
})
|
|
|
|
describe('given a non-touch device', () => {
|
|
it('does not show button when userLink is provided', () => {
|
|
const wrapper = Wrapper({ withUserLink: true, onTouchScreen: false })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
})
|
|
|
|
it('shows badges when enabled', () => {
|
|
const wrapper = Wrapper({ badgesEnabled: true })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
it('does not show badges when disabled', () => {
|
|
const wrapper = Wrapper({ badgesEnabled: false })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
})
|