Implement suggestions of Matt

Co-Authored-By: mattwr18 <mattwr18@gmail.com>
This commit is contained in:
Wolfgang Huß 2020-02-05 11:05:37 +01:00
parent 346a1b0d3e
commit bef747b9a1
10 changed files with 73 additions and 142 deletions

View File

@ -746,31 +746,31 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
])
// notify first report filers
await Promise.all([
reportAgainstDagobert.relateTo(jennyRostock, 'notified', {
jennyRostock.relateTo(reportAgainstDagobert, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstHuey.relateTo(jennyRostock, 'notified', {
jennyRostock.relateTo(reportAgainstHuey, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingPostP2.relateTo(jennyRostock, 'notified', {
jennyRostock.relateTo(reportAgainstTrollingPostP2, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingPostP9.relateTo(jennyRostock, 'notified', {
jennyRostock.relateTo(reportAgainstTrollingPostP9, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingCommentC1.relateTo(huey, 'notified', {
huey.relateTo(reportAgainstTrollingCommentC1, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingCommentC2.relateTo(jennyRostock, 'notified', {
jennyRostock.relateTo(reportAgainstTrollingCommentC2, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstDewey.relateTo(dagobert, 'notified', {
dagobert.relateTo(reportAgainstDewey, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
@ -801,15 +801,15 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
])
// notify second report filers
await Promise.all([
reportAgainstDagobert.relateTo(louie, 'notified', {
louie.relateTo(reportAgainstDagobert, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingPostP2.relateTo(peterLustig, 'notified', {
peterLustig.relateTo(reportAgainstTrollingPostP2, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),
reportAgainstTrollingCommentC1.relateTo(bobDerBaumeister, 'notified', {
bobDerBaumeister.relateTo(reportAgainstTrollingCommentC1, 'notified', {
read: false,
reason: 'filed_report_on_resource',
}),

View File

@ -25,34 +25,4 @@ export default {
target: 'User',
direction: 'in',
},
notified: {
type: 'relationship',
relationship: 'NOTIFIED',
target: 'User',
direction: 'out',
properties: {
createdAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
updatedAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
read: { type: 'boolean', default: false },
reason: {
type: 'string',
valid: [
'mentioned_in_post',
'mentioned_in_comment',
'commented_on_post',
'filed_report_on_resource',
],
},
},
},
}

View File

@ -17,31 +17,6 @@ export default {
image: { type: 'string', allow: [null] },
deleted: { type: 'boolean', default: false },
disabled: { type: 'boolean', default: false },
notified: {
type: 'relationship',
relationship: 'NOTIFIED',
target: 'User',
direction: 'out',
properties: {
createdAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
updatedAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
read: { type: 'boolean', default: false },
reason: {
type: 'string',
valid: ['mentioned_in_post', 'mentioned_in_comment', 'commented_on_post'],
},
},
},
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
updatedAt: {
type: 'string',

View File

@ -49,34 +49,4 @@ export default {
closed: { type: 'boolean', default: false },
},
},
notified: {
type: 'relationship',
relationship: 'NOTIFIED',
target: 'User',
direction: 'out',
properties: {
createdAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
updatedAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
read: { type: 'boolean', default: false },
reason: {
type: 'string',
valid: [
'mentioned_in_post',
'mentioned_in_comment',
'commented_on_post',
'filed_report_on_resource',
],
},
},
},
}

View File

@ -90,11 +90,35 @@ export default {
createdAt: { type: 'string', isoDate: true, default: () => new Date().toISOString() },
},
},
notifications: {
notified: {
type: 'relationship',
relationship: 'NOTIFIED',
target: 'User',
target: ['Post', 'Comment'],
direction: 'in',
properties: {
createdAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
updatedAt: {
type: 'string',
isoDate: true,
required: true,
default: () => new Date().toISOString(),
},
read: { type: 'boolean', default: false },
reason: {
type: 'string',
valid: [
'mentioned_in_post',
'mentioned_in_comment',
'commented_on_post',
'filed_report_on_resource',
],
},
},
},
termsAndConditionsAgreedVersion: {
type: 'string',

View File

@ -28,7 +28,7 @@ beforeAll(() => {
beforeEach(async () => {
authenticatedUser = null
variables = { orderBy: 'createdAt_asc' }
variables = { orderBy: 'updatedAt_desc' }
})
afterEach(async () => {
@ -94,37 +94,37 @@ describe('given some notifications', () => {
}),
])
await Promise.all([
post1.relateTo(neighbor, 'notified', {
neighbor.relateTo(post1, 'notified', {
createdAt: '2019-08-29T17:33:48.651Z',
updatedAt: '2019-08-29T17:33:48.651Z',
read: false,
reason: 'mentioned_in_post',
}),
post2.relateTo(user, 'notified', {
user.relateTo(post2, 'notified', {
createdAt: '2019-08-30T17:33:48.651Z',
updatedAt: '2019-08-30T17:33:48.651Z',
read: true,
reason: 'mentioned_in_post',
}),
post3.relateTo(user, 'notified', {
user.relateTo(post3, 'notified', {
createdAt: '2019-08-31T17:33:48.651Z',
updatedAt: '2019-08-31T17:33:48.651Z',
read: false,
reason: 'mentioned_in_post',
}),
comment1.relateTo(user, 'notified', {
user.relateTo(comment1, 'notified', {
createdAt: '2019-08-30T15:33:48.651Z',
updatedAt: '2019-08-30T15:33:48.651Z',
read: true,
reason: 'mentioned_in_comment',
}),
comment2.relateTo(user, 'notified', {
user.relateTo(comment2, 'notified', {
createdAt: '2019-08-30T19:33:48.651Z',
updatedAt: '2019-08-30T19:33:48.651Z',
read: false,
reason: 'mentioned_in_comment',
}),
comment3.relateTo(neighbor, 'notified', {
neighbor.relateTo(comment3, 'notified', {
createdAt: '2019-09-01T17:33:48.651Z',
updatedAt: '2019-09-01T17:33:48.651Z',
read: false,
@ -165,19 +165,19 @@ describe('given some notifications', () => {
reportOnComment.relateTo(comment4, 'belongsTo'),
])
await Promise.all([
reportOnUser.relateTo(user, 'notified', {
user.relateTo(reportOnUser, 'notified', {
createdAt: '2020-01-15T16:33:48.651Z',
updatedAt: '2020-01-15T16:33:48.651Z',
read: false,
reason: 'filed_report_on_resource',
}),
reportOnPost.relateTo(user, 'notified', {
user.relateTo(reportOnPost, 'notified', {
createdAt: '2020-01-16T10:33:48.651Z',
updatedAt: '2020-01-16T10:33:48.651Z',
read: true,
reason: 'filed_report_on_resource',
}),
reportOnComment.relateTo(user, 'notified', {
user.relateTo(reportOnComment, 'notified', {
createdAt: '2020-01-14T12:33:48.651Z',
updatedAt: '2020-01-14T12:33:48.651Z',
read: false,
@ -245,7 +245,7 @@ describe('given some notifications', () => {
it('returns all notifications of current user', async () => {
const expected = {
data: {
notifications: expect.arrayContaining([
notifications: [
{
createdAt: '2020-01-16T10:33:48.651Z',
updatedAt: '2020-01-16T10:33:48.651Z',
@ -348,7 +348,7 @@ describe('given some notifications', () => {
content: 'You have seen this comment mentioning already',
},
}),
]),
],
},
errors: undefined,
}
@ -363,27 +363,7 @@ describe('given some notifications', () => {
it('returns only unread notifications of current user', async () => {
const expected = {
data: {
notifications: expect.arrayContaining([
{
createdAt: '2019-08-30T19:33:48.651Z',
updatedAt: '2019-08-30T19:33:48.651Z',
read: false,
reason: 'mentioned_in_comment',
from: {
__typename: 'Comment',
content: 'You have been mentioned in a comment',
},
},
{
createdAt: '2019-08-31T17:33:48.651Z',
updatedAt: '2019-08-31T17:33:48.651Z',
read: false,
reason: 'mentioned_in_post',
from: {
__typename: 'Post',
content: 'You have been mentioned in a post',
},
},
notifications: [
{
createdAt: '2020-01-15T16:33:48.651Z',
updatedAt: '2020-01-15T16:33:48.651Z',
@ -427,7 +407,27 @@ describe('given some notifications', () => {
],
},
},
]),
{
createdAt: '2019-08-31T17:33:48.651Z',
updatedAt: '2019-08-31T17:33:48.651Z',
read: false,
reason: 'mentioned_in_post',
from: {
__typename: 'Post',
content: 'You have been mentioned in a post',
},
},
{
createdAt: '2019-08-30T19:33:48.651Z',
updatedAt: '2019-08-30T19:33:48.651Z',
read: false,
reason: 'mentioned_in_comment',
from: {
__typename: 'Comment',
content: 'You have been mentioned in a comment',
},
},
],
},
errors: undefined,
}

View File

@ -186,9 +186,5 @@ export default {
},
FILED: {
...undefinedToNullResolver(['reasonDescription']),
// Wolle reasonDescription: async (parent, _params, _context, _resolveInfo) => {
// if (typeof parent.reasonDescription !== 'undefined') return parent.reasonDescription
// return null
// },
},
}

View File

@ -383,7 +383,7 @@ When("I log in with the following credentials:", table => {
When("open the notification menu and click on the first item", () => {
cy.get(".notifications-menu").invoke('show').click(); // "invoke('show')" because of the delay for show the menu
cy.get('[data-testid="notification-link"]')
cy.get('.notification .notifications-card')
.first()
.click({
force: true

View File

@ -27,8 +27,6 @@
</client-only>
<ds-space margin-bottom="x-small" />
<nuxt-link
data-testid="notification-link"
class="notification-link-for-test"
:to="notificationData.linkTo"
@click.native="$emit('read')"
>

View File

@ -73,12 +73,10 @@ describe('NotificationList.vue', () => {
describe('click on a notification', () => {
beforeEach(() => {
// Wolle wrapper.find('.notification-link-for-test').trigger('click')
wrapper.getByTestId('notification-link').trigger('click')
expect(wrapper.attributes('id')).toBe('foo')
wrapper.find('.notification .notifications-card').trigger('click')
})
it.only("emits 'markAsRead' with the id of the notification source", () => {
it("emits 'markAsRead' with the id of the notification source", () => {
expect(wrapper.emitted('markAsRead')[0]).toEqual(['post-1'])
})
})