mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
fix: prework for tests
This commit is contained in:
parent
8b7b1056ac
commit
0b62d76bc1
@ -6,15 +6,47 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
|
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
let user
|
let user
|
||||||
|
//let anotherUser
|
||||||
|
//let moderator
|
||||||
|
//let admin
|
||||||
|
|
||||||
let query
|
let query
|
||||||
let mutate
|
let mutate
|
||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
let variables
|
//let variables
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
|
const deleteUserMutation = gql`
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
@ -29,17 +61,17 @@ beforeAll(() => {
|
|||||||
mutate = createTestClient(server).mutate
|
mutate = createTestClient(server).mutate
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
await cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('User', () => {
|
describe('User', () => {
|
||||||
describe('query by email address', () => {
|
describe('query by email address', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
await Factory.build('user', { name: 'Johnny' }, { email: 'any-email-address@example.org' })
|
await Factory.build('user', { name: 'Johnny' }, { email: 'any-email-address@example.org' })
|
||||||
})
|
})
|
||||||
|
|
||||||
const userQuery = gql `
|
const userQuery = gql`
|
||||||
query($email: String) {
|
query($email: String) {
|
||||||
User(email: $email) {
|
User(email: $email) {
|
||||||
name
|
name
|
||||||
@ -48,18 +80,20 @@ describe('User', () => {
|
|||||||
`
|
`
|
||||||
const variables = { email: 'any-email-address@example.org' }
|
const variables = { email: 'any-email-address@example.org' }
|
||||||
|
|
||||||
it('is forbidden', async() => {
|
it('is forbidden', async () => {
|
||||||
await expect(query({ query: userQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: userQuery, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorised!' }],
|
errors: [{ message: 'Not Authorised!' }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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',
|
||||||
},
|
},
|
||||||
@ -67,14 +101,14 @@ describe('User', () => {
|
|||||||
authenticatedUser = await admin.toJson()
|
authenticatedUser = await admin.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('is permitted', async() => {
|
it('is permitted', async () => {
|
||||||
await expect(query({ query: userQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: userQuery, variables })).resolves.toMatchObject({
|
||||||
data: { User: [{ name: 'Johnny' }] },
|
data: { User: [{ name: 'Johnny' }] },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('non-existing email address, issue #2294', async() => {
|
it('non-existing email address, issue #2294', async () => {
|
||||||
// see: https://github.com/Human-Connection/Human-Connection/issues/2294
|
// see: https://github.com/Human-Connection/Human-Connection/issues/2294
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
@ -95,14 +129,14 @@ describe('User', () => {
|
|||||||
describe('UpdateUser', () => {
|
describe('UpdateUser', () => {
|
||||||
let variables
|
let variables
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = {
|
variables = {
|
||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doughnut',
|
name: 'John Doughnut',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateUserMutation = gql `
|
const updateUserMutation = gql`
|
||||||
mutation(
|
mutation(
|
||||||
$id: ID!
|
$id: ID!
|
||||||
$name: String
|
$name: String
|
||||||
@ -124,26 +158,30 @@ 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',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
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',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -151,18 +189,18 @@ describe('UpdateUser', () => {
|
|||||||
authenticatedUser = await someoneElse.toJson()
|
authenticatedUser = await someoneElse.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('is not allowed to change other user accounts', async() => {
|
it('is not allowed to change other user accounts', async () => {
|
||||||
const { errors } = await mutate({ mutation: updateUserMutation, variables })
|
const { errors } = await mutate({ mutation: updateUserMutation, variables })
|
||||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('as the same user', () => {
|
describe('as the same user', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates the name', async() => {
|
it('updates the name', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
data: {
|
data: {
|
||||||
UpdateUser: {
|
UpdateUser: {
|
||||||
@ -178,10 +216,10 @@ describe('UpdateUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('given a new agreed version of terms and conditions', () => {
|
describe('given a new agreed version of terms and conditions', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = {...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
variables = { ...variables, termsAndConditionsAgreedVersion: '0.0.2' }
|
||||||
})
|
})
|
||||||
it('update termsAndConditionsAgreedVersion', async() => {
|
it('update termsAndConditionsAgreedVersion', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
data: {
|
data: {
|
||||||
UpdateUser: expect.objectContaining({
|
UpdateUser: expect.objectContaining({
|
||||||
@ -199,10 +237,10 @@ describe('UpdateUser', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('given any attribute other than termsAndConditionsAgreedVersion', () => {
|
describe('given any attribute other than termsAndConditionsAgreedVersion', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = {...variables, name: 'any name' }
|
variables = { ...variables, name: 'any name' }
|
||||||
})
|
})
|
||||||
it('update termsAndConditionsAgreedVersion', async() => {
|
it('update termsAndConditionsAgreedVersion', async () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
data: {
|
data: {
|
||||||
UpdateUser: expect.objectContaining({
|
UpdateUser: expect.objectContaining({
|
||||||
@ -219,7 +257,7 @@ describe('UpdateUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rejects if version of terms and conditions has wrong format', async() => {
|
it('rejects if version of terms and conditions has wrong format', async () => {
|
||||||
variables = {
|
variables = {
|
||||||
...variables,
|
...variables,
|
||||||
termsAndConditionsAgreedVersion: 'invalid version format',
|
termsAndConditionsAgreedVersion: 'invalid version format',
|
||||||
@ -228,8 +266,8 @@ describe('UpdateUser', () => {
|
|||||||
expect(errors[0]).toHaveProperty('message', 'Invalid version format!')
|
expect(errors[0]).toHaveProperty('message', 'Invalid version format!')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports updating location', async() => {
|
it('supports updating location', async () => {
|
||||||
variables = {...variables, locationName: 'Hamburg, New Jersey, United States of America' }
|
variables = { ...variables, locationName: 'Hamburg, New Jersey, United States of America' }
|
||||||
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: updateUserMutation, variables })).resolves.toMatchObject({
|
||||||
data: { UpdateUser: { locationName: 'Hamburg, New Jersey, United States of America' } },
|
data: { UpdateUser: { locationName: 'Hamburg, New Jersey, United States of America' } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -237,10 +275,9 @@ describe('UpdateUser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
/*
|
||||||
|
|
||||||
describe('Delete a User as another user', () => {
|
describe('Delete a User as another user', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
user = await Factory.build('user', {
|
user = await Factory.build('user', {
|
||||||
@ -250,11 +287,13 @@ describe('Delete a User as another user', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
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',
|
||||||
},
|
},
|
||||||
@ -263,14 +302,14 @@ describe('Delete a User as another user', () => {
|
|||||||
authenticatedUser = await anotherUser.toJson()
|
authenticatedUser = await anotherUser.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("an ordinary user has no authorization to delete another user's account", async() => {
|
it("an ordinary user has no authorization to delete another user's account", async () => {
|
||||||
const { errors } = await mutate({ mutation: deleteUserMutation, variables })
|
const { errors } = await mutate({ mutation: deleteUserMutation, variables })
|
||||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Delete a User as moderator', () => {
|
describe('Delete a User as moderator', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
user = await Factory.build('user', {
|
user = await Factory.build('user', {
|
||||||
@ -280,11 +319,13 @@ describe('Delete a User as moderator', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
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',
|
||||||
},
|
},
|
||||||
@ -293,14 +334,14 @@ describe('Delete a User as moderator', () => {
|
|||||||
authenticatedUser = await moderator.toJson()
|
authenticatedUser = await moderator.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('moderator is not allowed to delete other user accounts', async() => {
|
it('moderator is not allowed to delete other user accounts', async () => {
|
||||||
const { errors } = await mutate({ mutation: deleteUserMutation, variables })
|
const { errors } = await mutate({ mutation: deleteUserMutation, variables })
|
||||||
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
expect(errors[0]).toHaveProperty('message', 'Not Authorised!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Delete a User as admin', () => {
|
describe('Delete a User as admin', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
user = await Factory.build('user', {
|
user = await Factory.build('user', {
|
||||||
@ -311,11 +352,13 @@ describe('Delete a User as admin', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('authenticated as Admin', () => {
|
describe('authenticated as Admin', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
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',
|
||||||
},
|
},
|
||||||
@ -325,44 +368,50 @@ describe('Delete a User as admin', () => {
|
|||||||
|
|
||||||
describe('deleting a user account', () => {
|
describe('deleting a user account', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = {...variables, id: 'u343' }
|
variables = { ...variables, id: 'u343' }
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('given posts and comments', () => {
|
describe('given posts and comments', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
await Factory.build('category', {
|
await Factory.build('category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
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',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes account, but doesn't delete posts or comments by default", async() => {
|
it("deletes account, but doesn't delete posts or comments by default", async () => {
|
||||||
const expectedResponse = {
|
const expectedResponse = {
|
||||||
data: {
|
data: {
|
||||||
DeleteUser: {
|
DeleteUser: {
|
||||||
@ -370,24 +419,30 @@ describe('Delete a User as admin', () => {
|
|||||||
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,
|
||||||
@ -399,10 +454,10 @@ describe('Delete a User as admin', () => {
|
|||||||
|
|
||||||
describe('deletion of all post requested', () => {
|
describe('deletion of all post requested', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = {...variables, resource: ['Post'] }
|
variables = { ...variables, resource: ['Post'] }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('on request', async() => {
|
it('on request', async () => {
|
||||||
const expectedResponse = {
|
const expectedResponse = {
|
||||||
data: {
|
data: {
|
||||||
DeleteUser: {
|
DeleteUser: {
|
||||||
@ -410,24 +465,30 @@ describe('Delete a User as admin', () => {
|
|||||||
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,
|
||||||
@ -437,7 +498,7 @@ describe('Delete a User as admin', () => {
|
|||||||
).resolves.toMatchObject(expectedResponse)
|
).resolves.toMatchObject(expectedResponse)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deletes user avatar and post hero images', async() => {
|
it('deletes user avatar and post hero images', async () => {
|
||||||
await expect(neode.all('Image')).resolves.toHaveLength(22)
|
await expect(neode.all('Image')).resolves.toHaveLength(22)
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
await mutate({ mutation: deleteUserMutation, variables })
|
||||||
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
||||||
@ -446,10 +507,10 @@ describe('Delete a User as admin', () => {
|
|||||||
|
|
||||||
describe('deletion of all comments requested', () => {
|
describe('deletion of all comments requested', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = {...variables, resource: ['Comment'] }
|
variables = { ...variables, resource: ['Comment'] }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('marks comments as deleted', async() => {
|
it('marks comments as deleted', async () => {
|
||||||
const expectedResponse = {
|
const expectedResponse = {
|
||||||
data: {
|
data: {
|
||||||
DeleteUser: {
|
DeleteUser: {
|
||||||
@ -457,24 +518,30 @@ describe('Delete a User as admin', () => {
|
|||||||
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,
|
||||||
@ -487,10 +554,10 @@ describe('Delete a User as admin', () => {
|
|||||||
|
|
||||||
describe('deletion of all posts and comments requested', () => {
|
describe('deletion of all posts and comments requested', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = {...variables, resource: ['Comment', 'Post'] }
|
variables = { ...variables, resource: ['Comment', 'Post'] }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('marks posts and comments as deleted', async() => {
|
it('marks posts and comments as deleted', async () => {
|
||||||
const expectedResponse = {
|
const expectedResponse = {
|
||||||
data: {
|
data: {
|
||||||
DeleteUser: {
|
DeleteUser: {
|
||||||
@ -498,24 +565,30 @@ describe('Delete a User as admin', () => {
|
|||||||
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,
|
||||||
@ -528,7 +601,7 @@ describe('Delete a User as admin', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('connected `EmailAddress` nodes', () => {
|
describe('connected `EmailAddress` nodes', () => {
|
||||||
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 })
|
||||||
|
|
||||||
@ -537,12 +610,12 @@ describe('Delete a User as admin', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('connected `SocialMedia` nodes', () => {
|
describe('connected `SocialMedia` nodes', () => {
|
||||||
beforeEach(async() => {
|
beforeEach(async () => {
|
||||||
const socialMedia = await Factory.build('socialMedia')
|
const socialMedia = await Factory.build('socialMedia')
|
||||||
await socialMedia.relateTo(user, 'ownedBy')
|
await socialMedia.relateTo(user, 'ownedBy')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('will be removed completely', async() => {
|
it('will be removed completely', async () => {
|
||||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(1)
|
await expect(neode.all('SocialMedia')).resolves.toHaveLength(1)
|
||||||
await mutate({ mutation: deleteUserMutation, variables })
|
await mutate({ mutation: deleteUserMutation, variables })
|
||||||
await expect(neode.all('SocialMedia')).resolves.toHaveLength(0)
|
await expect(neode.all('SocialMedia')).resolves.toHaveLength(0)
|
||||||
@ -551,3 +624,5 @@ describe('Delete a User as admin', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
*/
|
||||||
|
|||||||
@ -13,8 +13,7 @@
|
|||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<ds-flex-item width="20%">
|
<ds-flex-item width="20%">
|
||||||
<ds-text size="small">
|
<ds-text size="small">
|
||||||
|
<relative-date-time :date-time="userdata.createdAt" class="relative-date-time" />
|
||||||
<relative-date-time :date-time="userdata.createdAt" class="relative-date-time"/>
|
|
||||||
<br />
|
<br />
|
||||||
{{ $t('modals.deleteUser.created') }}
|
{{ $t('modals.deleteUser.created') }}
|
||||||
</ds-text>
|
</ds-text>
|
||||||
@ -162,7 +161,7 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.ds-modal {
|
.ds-modal {
|
||||||
max-width: 600px !important;
|
max-width: 700px !important;
|
||||||
}
|
}
|
||||||
.hc-modal-success {
|
.hc-modal-success {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user