mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-15 09:24:34 +00:00
# Conflicts: # backend/package.json # backend/src/db/seed.js # backend/src/middleware/notifications/notificationsMiddleware.js # backend/src/middleware/notifications/notificationsMiddleware.spec.js # backend/src/schema/resolvers/notifications.js # backend/src/schema/resolvers/notifications.spec.js # backend/yarn.lock # cypress/integration/common/steps.js # webapp/components/Notification/Notification.spec.js # webapp/components/Notification/Notification.vue # webapp/components/NotificationList/NotificationList.spec.js # webapp/components/UserTeaser/UserTeaser.vue # webapp/locales/de.json # webapp/locales/en.json # webapp/package.json # webapp/yarn.lock
270 lines
7.1 KiB
JavaScript
270 lines
7.1 KiB
JavaScript
import { config, mount, RouterLinkStub } from '@vue/test-utils'
|
|
import Notification from './Notification.vue'
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
const localVue = global.localVue
|
|
|
|
config.stubs['client-only'] = '<span><slot /></span>'
|
|
|
|
describe('Notification', () => {
|
|
let stubs
|
|
let getters
|
|
let mocks
|
|
let propsData
|
|
let wrapper
|
|
beforeEach(() => {
|
|
propsData = {}
|
|
mocks = {
|
|
$t: key => key,
|
|
}
|
|
stubs = {
|
|
NuxtLink: RouterLinkStub,
|
|
}
|
|
getters = {
|
|
'auth/user': () => {
|
|
return {}
|
|
},
|
|
'auth/isModerator': () => false,
|
|
}
|
|
})
|
|
|
|
const Wrapper = () => {
|
|
const store = new Vuex.Store({
|
|
getters,
|
|
})
|
|
return mount(Notification, {
|
|
stubs,
|
|
store,
|
|
mocks,
|
|
propsData,
|
|
localVue,
|
|
})
|
|
}
|
|
|
|
describe('given a notification about a comment on a post', () => {
|
|
beforeEach(() => {
|
|
propsData.notification = {
|
|
reason: 'commented_on_post',
|
|
from: {
|
|
__typename: 'Comment',
|
|
id: 'comment-1',
|
|
contentExcerpt:
|
|
'<a href="/profile/u123" target="_blank">@dagobert-duck</a> is the best on this comment.',
|
|
post: {
|
|
title: "It's a post title",
|
|
id: 'post-1',
|
|
slug: 'its-a-title',
|
|
contentExcerpt: 'Post content.',
|
|
},
|
|
},
|
|
}
|
|
})
|
|
|
|
it('renders reason', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('[data-test="reason-text"]').text()).toEqual(
|
|
'notifications.reason.commented_on_post',
|
|
)
|
|
})
|
|
it('renders title', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain("It's a post title")
|
|
})
|
|
it('renders the identifier "notifications.comment"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('notifications.comment')
|
|
})
|
|
it('renders the contentExcerpt', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('@dagobert-duck is the best on this comment.')
|
|
})
|
|
it('has no class "--read"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.classes()).not.toContain('--read')
|
|
})
|
|
|
|
describe('that is read', () => {
|
|
beforeEach(() => {
|
|
propsData.notification.read = true
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has class "--read"', () => {
|
|
expect(wrapper.classes()).toContain('--read')
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('given a notification about a mention in a post', () => {
|
|
beforeEach(() => {
|
|
propsData.notification = {
|
|
reason: 'mentioned_in_post',
|
|
from: {
|
|
__typename: 'Post',
|
|
title: "It's a post title",
|
|
id: 'post-1',
|
|
slug: 'its-a-title',
|
|
contentExcerpt:
|
|
'<a href="/profile/u3" target="_blank">@jenny-rostock</a> is the best on this post.',
|
|
},
|
|
}
|
|
})
|
|
|
|
it('renders reason', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('[data-test="reason-text"]').text()).toEqual(
|
|
'notifications.reason.mentioned_in_post',
|
|
)
|
|
})
|
|
it('renders title', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain("It's a post title")
|
|
})
|
|
it('renders the contentExcerpt', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('@jenny-rostock is the best on this post.')
|
|
})
|
|
it('has no class "--read"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.classes()).not.toContain('--read')
|
|
})
|
|
|
|
describe('that is read', () => {
|
|
beforeEach(() => {
|
|
propsData.notification.read = true
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has class "--read"', () => {
|
|
expect(wrapper.classes()).toContain('--read')
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('given a notification about a mention in a comment', () => {
|
|
beforeEach(() => {
|
|
propsData.notification = {
|
|
reason: 'mentioned_in_comment',
|
|
from: {
|
|
__typename: 'Comment',
|
|
id: 'comment-1',
|
|
contentExcerpt:
|
|
'<a href="/profile/u123" target="_blank">@dagobert-duck</a> is the best on this comment.',
|
|
post: {
|
|
title: "It's a post title",
|
|
id: 'post-1',
|
|
slug: 'its-a-title',
|
|
contentExcerpt: 'Post content.',
|
|
},
|
|
},
|
|
}
|
|
})
|
|
|
|
it('renders reason', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('[data-test="reason-text"]').text()).toEqual(
|
|
'notifications.reason.mentioned_in_comment',
|
|
)
|
|
})
|
|
|
|
it('renders title', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain("It's a post title")
|
|
})
|
|
|
|
it('renders the identifier "notifications.comment"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('notifications.comment')
|
|
})
|
|
|
|
it('renders the contentExcerpt', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('@dagobert-duck is the best on this comment.')
|
|
})
|
|
|
|
it('has no class "--read"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.classes()).not.toContain('--read')
|
|
})
|
|
|
|
describe('that is read', () => {
|
|
beforeEach(() => {
|
|
propsData.notification.read = true
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has class "--read"', () => {
|
|
expect(wrapper.classes()).toContain('--read')
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('given a notification about the user has filed a report', () => {
|
|
beforeEach(() => {
|
|
propsData.notification = {
|
|
reason: 'filed_report_on_resource',
|
|
from: {
|
|
__typename: 'Report',
|
|
id: 'reportOnUser',
|
|
filed: [
|
|
{
|
|
reasonCategory: 'discrimination_etc',
|
|
reasonDescription: 'This user is harassing me with bigoted remarks!',
|
|
reportedResource: {
|
|
__typename: 'User',
|
|
id: 'badWomen',
|
|
slug: 'mrs.-badwomen',
|
|
name: 'Mrs. Badwomen',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}
|
|
})
|
|
|
|
it('renders reason', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('[data-test="reason-text"]').text()).toEqual(
|
|
'notifications.reason.filed_report_on_resource.user',
|
|
)
|
|
})
|
|
|
|
it('renders title', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('Mrs. Badwomen')
|
|
})
|
|
|
|
it('renders the reported users slug', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('@mrs.-badwomen')
|
|
})
|
|
|
|
it('renders the identifier "notifications.report.category"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('notifications.report.category')
|
|
})
|
|
|
|
it('renders the identifier "notifications.report.description"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.text()).toContain('notifications.report.description')
|
|
})
|
|
|
|
it('has no class "read"', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.classes()).not.toContain('--read')
|
|
})
|
|
|
|
describe('that is read', () => {
|
|
beforeEach(() => {
|
|
propsData.notification.read = true
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('has class "--read"', () => {
|
|
expect(wrapper.classes()).toContain('--read')
|
|
})
|
|
})
|
|
})
|
|
})
|