mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
test check test WIP
This commit is contained in:
parent
d2e6280059
commit
a4be3f7adf
@ -57,11 +57,9 @@ describe('User', () => {
|
|||||||
describe('as admin', () => {
|
describe('as admin', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
const admin = await Factory.build(
|
const admin = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
},
|
},
|
||||||
@ -128,15 +126,13 @@ describe('UpdateUser', () => {
|
|||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
user = await Factory.build(
|
user = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
termsAndConditionsAgreedVersion: null,
|
termsAndConditionsAgreedVersion: null,
|
||||||
termsAndConditionsAgreedAt: null,
|
termsAndConditionsAgreedAt: null,
|
||||||
allowEmbedIframes: false,
|
allowEmbedIframes: false,
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -145,11 +141,9 @@ describe('UpdateUser', () => {
|
|||||||
describe('as another user', () => {
|
describe('as another user', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
const someoneElse = await Factory.build(
|
const someoneElse = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
name: 'James Doe',
|
name: 'James Doe',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'someone-else@example.org',
|
email: 'someone-else@example.org',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -244,36 +238,8 @@ describe('UpdateUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('DeleteUser', () => {
|
|
||||||
const deleteUserMutation = gql`
|
describe('Delete a User as another user', () => {
|
||||||
mutation($id: ID!, $resource: [Deletable]) {
|
|
||||||
DeleteUser(id: $id, resource: $resource) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
about
|
|
||||||
deleted
|
|
||||||
contributions {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
deleted
|
|
||||||
comments {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
comments {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
describe('as another user', () => {
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
@ -285,12 +251,10 @@ describe('DeleteUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
const anotherUser = await Factory.build(
|
anotherUser = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
role: 'user',
|
role: 'user',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
},
|
},
|
||||||
@ -305,7 +269,7 @@ describe('DeleteUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('as moderator', () => {
|
describe('Delete a User as moderator', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
@ -317,12 +281,10 @@ describe('DeleteUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
const moderator = await Factory.build(
|
moderator = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'moderator@example.org',
|
email: 'moderator@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
},
|
},
|
||||||
@ -337,7 +299,7 @@ describe('DeleteUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('as admin', () => {
|
describe('Delete a User as admin', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
@ -350,12 +312,10 @@ describe('DeleteUser', () => {
|
|||||||
|
|
||||||
describe('authenticated as Admin', () => {
|
describe('authenticated as Admin', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
const admin = await Factory.build(
|
admin = await Factory.build(
|
||||||
'user',
|
'user', {
|
||||||
{
|
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
},
|
},
|
||||||
@ -376,33 +336,27 @@ describe('DeleteUser', () => {
|
|||||||
icon: 'university',
|
icon: 'university',
|
||||||
})
|
})
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
'post',
|
'post', {
|
||||||
{
|
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'Post by user u343',
|
content: 'Post by user u343',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
author: user,
|
author: user,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment', {
|
||||||
{
|
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'Comment by user u343',
|
content: 'Comment by user u343',
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
author: user,
|
author: user,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment', {
|
||||||
{
|
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: "A comment by someone else on user u343's post",
|
content: "A comment by someone else on user u343's post",
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
postId: 'p139',
|
postId: 'p139',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -416,37 +370,31 @@ describe('DeleteUser', () => {
|
|||||||
name: 'UNAVAILABLE',
|
name: 'UNAVAILABLE',
|
||||||
about: 'UNAVAILABLE',
|
about: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
contributions: [
|
contributions: [{
|
||||||
{
|
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'Post by user u343',
|
content: 'Post by user u343',
|
||||||
contentExcerpt: 'Post by user u343',
|
contentExcerpt: 'Post by user u343',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
comments: [
|
comments: [{
|
||||||
{
|
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: "A comment by someone else on user u343's post",
|
content: "A comment by someone else on user u343's post",
|
||||||
contentExcerpt: "A comment by someone else on user u343's post",
|
contentExcerpt: "A comment by someone else on user u343's post",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
},
|
}, ],
|
||||||
],
|
}, ],
|
||||||
},
|
comments: [{
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'Comment by user u343',
|
content: 'Comment by user u343',
|
||||||
contentExcerpt: 'Comment by user u343',
|
contentExcerpt: 'Comment by user u343',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
},
|
}, ],
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(mutate({ mutation: deleteUserMutation, variables })).resolves.toMatchObject(
|
||||||
mutate({ mutation: deleteUserMutation, variables }),
|
expectedResponse,
|
||||||
).resolves.toMatchObject(expectedResponse)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deletion of all post requested', () => {
|
describe('deletion of all post requested', () => {
|
||||||
@ -454,7 +402,6 @@ describe('DeleteUser', () => {
|
|||||||
variables = {...variables, resource: ['Post'] }
|
variables = {...variables, resource: ['Post'] }
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("marks user's posts as deleted", () => {
|
|
||||||
it('on request', async() => {
|
it('on request', async() => {
|
||||||
const expectedResponse = {
|
const expectedResponse = {
|
||||||
data: {
|
data: {
|
||||||
@ -463,30 +410,24 @@ describe('DeleteUser', () => {
|
|||||||
name: 'UNAVAILABLE',
|
name: 'UNAVAILABLE',
|
||||||
about: 'UNAVAILABLE',
|
about: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
contributions: [
|
contributions: [{
|
||||||
{
|
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
comments: [
|
comments: [{
|
||||||
{
|
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
},
|
}, ],
|
||||||
],
|
}, ],
|
||||||
},
|
comments: [{
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'Comment by user u343',
|
content: 'Comment by user u343',
|
||||||
contentExcerpt: 'Comment by user u343',
|
contentExcerpt: 'Comment by user u343',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
},
|
}, ],
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -502,7 +443,6 @@ describe('DeleteUser', () => {
|
|||||||
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe('deletion of all comments requested', () => {
|
describe('deletion of all comments requested', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -517,30 +457,24 @@ describe('DeleteUser', () => {
|
|||||||
name: 'UNAVAILABLE',
|
name: 'UNAVAILABLE',
|
||||||
about: 'UNAVAILABLE',
|
about: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
contributions: [
|
contributions: [{
|
||||||
{
|
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'Post by user u343',
|
content: 'Post by user u343',
|
||||||
contentExcerpt: 'Post by user u343',
|
contentExcerpt: 'Post by user u343',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
comments: [
|
comments: [{
|
||||||
{
|
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: "A comment by someone else on user u343's post",
|
content: "A comment by someone else on user u343's post",
|
||||||
contentExcerpt: "A comment by someone else on user u343's post",
|
contentExcerpt: "A comment by someone else on user u343's post",
|
||||||
deleted: false,
|
deleted: false,
|
||||||
},
|
}, ],
|
||||||
],
|
}, ],
|
||||||
},
|
comments: [{
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
},
|
}, ],
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -553,7 +487,7 @@ describe('DeleteUser', () => {
|
|||||||
|
|
||||||
describe('deletion of all posts and comments requested', () => {
|
describe('deletion of all posts and comments requested', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = { ...variables, resource: ['Post', 'Comment'] }
|
variables = {...variables, resource: ['Comment', 'Post'] }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('marks posts and comments as deleted', async() => {
|
it('marks posts and comments as deleted', async() => {
|
||||||
@ -564,30 +498,24 @@ describe('DeleteUser', () => {
|
|||||||
name: 'UNAVAILABLE',
|
name: 'UNAVAILABLE',
|
||||||
about: 'UNAVAILABLE',
|
about: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
contributions: [
|
contributions: [{
|
||||||
{
|
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
comments: [
|
comments: [{
|
||||||
{
|
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
},
|
}, ],
|
||||||
],
|
}, ],
|
||||||
},
|
comments: [{
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'UNAVAILABLE',
|
content: 'UNAVAILABLE',
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
contentExcerpt: 'UNAVAILABLE',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
},
|
}, ],
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -603,6 +531,7 @@ describe('DeleteUser', () => {
|
|||||||
it('will be removed completely', async() => {
|
it('will be removed completely', async() => {
|
||||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(2)
|
await expect(neode.all('EmailAddress')).resolves.toHaveLength(2)
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
await mutate({ mutation: deleteUserMutation, variables })
|
||||||
|
|
||||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(1)
|
await expect(neode.all('EmailAddress')).resolves.toHaveLength(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -622,299 +551,3 @@ describe('DeleteUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('user deletes his own account', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
variables = { id: 'u343', resource: [] }
|
|
||||||
|
|
||||||
user = await Factory.build('user', {
|
|
||||||
name: 'My name should be deleted',
|
|
||||||
about: 'along with my about',
|
|
||||||
id: 'u343',
|
|
||||||
})
|
|
||||||
await Factory.build(
|
|
||||||
'user',
|
|
||||||
{
|
|
||||||
id: 'not-my-account',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
email: 'friends-account@example.org',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('authenticated', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
authenticatedUser = await user.toJson()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("attempting to delete another user's account", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
variables = { ...variables, id: 'not-my-account' }
|
|
||||||
})
|
|
||||||
|
|
||||||
it('throws an authorization error', async () => {
|
|
||||||
const { errors } = await mutate({ mutation: deleteUserMutation, variables })
|
|
||||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('attempting to delete my own account', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
variables = { ...variables, id: 'u343' }
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('given posts and comments', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await Factory.build('category', {
|
|
||||||
id: 'cat9',
|
|
||||||
name: 'Democracy & Politics',
|
|
||||||
icon: 'university',
|
|
||||||
})
|
|
||||||
await Factory.build(
|
|
||||||
'post',
|
|
||||||
{
|
|
||||||
id: 'p139',
|
|
||||||
content: 'Post by user u343',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: user,
|
|
||||||
categoryIds,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await Factory.build(
|
|
||||||
'comment',
|
|
||||||
{
|
|
||||||
id: 'c155',
|
|
||||||
content: 'Comment by user u343',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: user,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await Factory.build(
|
|
||||||
'comment',
|
|
||||||
{
|
|
||||||
id: 'c156',
|
|
||||||
content: "A comment by someone else on user u343's post",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
postId: 'p139',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("deletes my account, but doesn't delete posts or comments by default", async () => {
|
|
||||||
const expectedResponse = {
|
|
||||||
data: {
|
|
||||||
DeleteUser: {
|
|
||||||
id: 'u343',
|
|
||||||
name: 'UNAVAILABLE',
|
|
||||||
about: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
contributions: [
|
|
||||||
{
|
|
||||||
id: 'p139',
|
|
||||||
content: 'Post by user u343',
|
|
||||||
contentExcerpt: 'Post by user u343',
|
|
||||||
deleted: false,
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c156',
|
|
||||||
content: "A comment by someone else on user u343's post",
|
|
||||||
contentExcerpt: "A comment by someone else on user u343's post",
|
|
||||||
deleted: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
|
||||||
content: 'Comment by user u343',
|
|
||||||
contentExcerpt: 'Comment by user u343',
|
|
||||||
deleted: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
errors: undefined,
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
mutate({ mutation: deleteUserMutation, variables }),
|
|
||||||
).resolves.toMatchObject(expectedResponse)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('deletion of all post requested', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
variables = { ...variables, resource: ['Post'] }
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("marks user's posts as deleted", () => {
|
|
||||||
it('posts on request', async () => {
|
|
||||||
const expectedResponse = {
|
|
||||||
data: {
|
|
||||||
DeleteUser: {
|
|
||||||
id: 'u343',
|
|
||||||
name: 'UNAVAILABLE',
|
|
||||||
about: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
contributions: [
|
|
||||||
{
|
|
||||||
id: 'p139',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c156',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
|
||||||
content: 'Comment by user u343',
|
|
||||||
contentExcerpt: 'Comment by user u343',
|
|
||||||
deleted: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
errors: undefined,
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
mutate({ mutation: deleteUserMutation, variables }),
|
|
||||||
).resolves.toMatchObject(expectedResponse)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('deletes user avatar and post hero images', async () => {
|
|
||||||
await expect(neode.all('Image')).resolves.toHaveLength(22)
|
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
|
||||||
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('deletion of all comments requested', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
variables = { ...variables, resource: ['Comment'] }
|
|
||||||
})
|
|
||||||
|
|
||||||
it('marks comments as deleted', async () => {
|
|
||||||
const expectedResponse = {
|
|
||||||
data: {
|
|
||||||
DeleteUser: {
|
|
||||||
id: 'u343',
|
|
||||||
name: 'UNAVAILABLE',
|
|
||||||
about: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
contributions: [
|
|
||||||
{
|
|
||||||
id: 'p139',
|
|
||||||
content: 'Post by user u343',
|
|
||||||
contentExcerpt: 'Post by user u343',
|
|
||||||
deleted: false,
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c156',
|
|
||||||
content: "A comment by someone else on user u343's post",
|
|
||||||
contentExcerpt: "A comment by someone else on user u343's post",
|
|
||||||
deleted: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
errors: undefined,
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
mutate({ mutation: deleteUserMutation, variables }),
|
|
||||||
).resolves.toMatchObject(expectedResponse)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('deletion of all post and comments requested', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
variables = { ...variables, resource: ['Post', 'Comment'] }
|
|
||||||
})
|
|
||||||
|
|
||||||
it('marks posts and comments as deleted', async () => {
|
|
||||||
const expectedResponse = {
|
|
||||||
data: {
|
|
||||||
DeleteUser: {
|
|
||||||
id: 'u343',
|
|
||||||
name: 'UNAVAILABLE',
|
|
||||||
about: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
contributions: [
|
|
||||||
{
|
|
||||||
id: 'p139',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c156',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
comments: [
|
|
||||||
{
|
|
||||||
id: 'c155',
|
|
||||||
content: 'UNAVAILABLE',
|
|
||||||
contentExcerpt: 'UNAVAILABLE',
|
|
||||||
deleted: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
errors: undefined,
|
|
||||||
}
|
|
||||||
await expect(
|
|
||||||
mutate({ mutation: deleteUserMutation, variables }),
|
|
||||||
).resolves.toMatchObject(expectedResponse)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('connected `EmailAddress` nodes', () => {
|
|
||||||
it('will be removed completely', async () => {
|
|
||||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(2)
|
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
|
||||||
await expect(neode.all('EmailAddress')).resolves.toHaveLength(1)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('connected `SocialMedia` nodes', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
const socialMedia = await Factory.build('socialMedia')
|
|
||||||
await socialMedia.relateTo(user, 'ownedBy')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('will be removed completely', async () => {
|
|
||||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(1)
|
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
|
||||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(0)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user