mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
* basics to notify a user when a followed user posted * do not notify following user on posts in groups * followig user wrote post notification * notify regular group members when a new post is posted in the group * mute and unmute groups * clean database at end * locale for post in group notification * post in group notification triggers correctly * email settings for post in group * Add mute/unumute group to menu (WIP) * Add mute group functionality (WIP) * Add locales; use mute/unmute mutations, cleanup tests * Overhaul group content menu test * Rename isMuted to isMutedByMe and add it to group query * Add German and English locales * Add spanish translations * Add missing translation keys (with null values) * Remove console statement * Add snapshot * Replace mount by render * Mock Math.random(), add tests for mute/unmute * Use container instead of baseElement for snapshots * fix group slug tests * undo wrong variable naming * rename parameter to groupId of mute/unmute group mutation * rename parameter to groupId of mute/unmute group mutation * only non pending members have access to the comtext menu --------- Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de> Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de>
84 lines
2.1 KiB
JavaScript
84 lines
2.1 KiB
JavaScript
import GroupContentMenu from './GroupContentMenu.vue'
|
|
import { render, screen, fireEvent } from '@testing-library/vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
const stubs = {
|
|
'router-link': {
|
|
template: '<span><slot /></span>',
|
|
},
|
|
'v-popover': true,
|
|
}
|
|
|
|
// Mock Math.random, used in Dropdown
|
|
Object.assign(Math, {
|
|
random: () => 0,
|
|
})
|
|
|
|
describe('GroupContentMenu', () => {
|
|
let mocks
|
|
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$t: jest.fn((s) => s),
|
|
}
|
|
})
|
|
|
|
const Wrapper = (propsData) => {
|
|
return render(GroupContentMenu, { propsData, mocks, localVue, stubs })
|
|
}
|
|
|
|
it('renders as groupTeaser', () => {
|
|
const wrapper = Wrapper({ usage: 'groupTeaser', group: { id: 'groupid' } })
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
it('renders as groupProfile, not muted', () => {
|
|
const wrapper = Wrapper({
|
|
usage: 'groupProfile',
|
|
group: { isMutedByMe: false, id: 'groupid' },
|
|
})
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
it('renders as groupProfile, muted', () => {
|
|
const wrapper = Wrapper({
|
|
usage: 'groupProfile',
|
|
group: { isMutedByMe: true, id: 'groupid' },
|
|
})
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
it('renders as groupProfile when I am the owner', () => {
|
|
const wrapper = Wrapper({
|
|
usage: 'groupProfile',
|
|
group: { myRole: 'owner', id: 'groupid' },
|
|
})
|
|
expect(wrapper.container).toMatchSnapshot()
|
|
})
|
|
|
|
describe('mute button', () => {
|
|
it('emits mute', async () => {
|
|
const wrapper = Wrapper({
|
|
usage: 'groupProfile',
|
|
group: { isMutedByMe: false, id: 'groupid' },
|
|
})
|
|
const muteButton = screen.getByText('group.contentMenu.muteGroup')
|
|
await fireEvent.click(muteButton)
|
|
expect(wrapper.emitted().mute).toBeTruthy()
|
|
})
|
|
})
|
|
|
|
describe('unmute button', () => {
|
|
it('emits unmute', async () => {
|
|
const wrapper = Wrapper({
|
|
usage: 'groupProfile',
|
|
group: { isMutedByMe: true, id: 'groupid' },
|
|
})
|
|
const muteButton = screen.getByText('group.contentMenu.unmuteGroup')
|
|
await fireEvent.click(muteButton)
|
|
expect(wrapper.emitted().unmute).toBeTruthy()
|
|
})
|
|
})
|
|
})
|