mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fix lint: tests and lint ok
This commit is contained in:
parent
9d5c192869
commit
d2a43cecd7
@ -18,7 +18,6 @@ let variables
|
||||
const driver = getDriver()
|
||||
const neode = getNeode()
|
||||
|
||||
|
||||
const deleteUserMutation = gql`
|
||||
mutation($id: ID!, $resource: [Deletable]) {
|
||||
DeleteUser(id: $id, resource: $resource) {
|
||||
@ -48,7 +47,6 @@ mutation($id: ID!, $resource: [Deletable]) {
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
beforeAll(() => {
|
||||
const { server } = createServer({
|
||||
context: () => {
|
||||
@ -61,18 +59,12 @@ beforeAll(() => {
|
||||
})
|
||||
query = createTestClient(server).query
|
||||
mutate = createTestClient(server).mutate
|
||||
console.log("z18 beforeAll")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await cleanDatabase()
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('Delete a User as another user', () => {
|
||||
beforeEach(async () => {
|
||||
variables = { id: ' u343', resource: [] }
|
||||
@ -85,10 +77,12 @@ describe('Delete a User as another user', () => {
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
const anotherUser = await Factory.build(
|
||||
'user', {
|
||||
anotherUser = await Factory.build(
|
||||
'user',
|
||||
{
|
||||
role: 'user',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'user@example.org',
|
||||
password: '1234',
|
||||
},
|
||||
@ -115,10 +109,12 @@ describe('Delete a User as moderator', () => {
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
const moderator = await Factory.build(
|
||||
'user', {
|
||||
moderator = await Factory.build(
|
||||
'user',
|
||||
{
|
||||
role: 'moderator',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'moderator@example.org',
|
||||
password: '1234',
|
||||
},
|
||||
@ -133,7 +129,6 @@ describe('Delete a User as moderator', () => {
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('User', () => {
|
||||
describe('query by email address', () => {
|
||||
beforeEach(async () => {
|
||||
@ -158,9 +153,11 @@ describe('User', () => {
|
||||
describe('as admin', () => {
|
||||
beforeEach(async () => {
|
||||
const admin = await Factory.build(
|
||||
'user', {
|
||||
'user',
|
||||
{
|
||||
role: 'admin',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'admin@example.org',
|
||||
password: '1234',
|
||||
},
|
||||
@ -193,12 +190,7 @@ describe('User', () => {
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('Delete a User as admin', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
variables = { id: ' u343', resource: [] }
|
||||
|
||||
@ -212,9 +204,11 @@ describe('Delete a User as admin', () => {
|
||||
describe('authenticated as Admin', () => {
|
||||
beforeEach(async () => {
|
||||
admin = await Factory.build(
|
||||
'user', {
|
||||
'user',
|
||||
{
|
||||
role: 'admin',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'admin@example.org',
|
||||
password: '1234',
|
||||
},
|
||||
@ -235,27 +229,33 @@ describe('Delete a User as admin', () => {
|
||||
icon: 'university',
|
||||
})
|
||||
await Factory.build(
|
||||
'post', {
|
||||
'post',
|
||||
{
|
||||
id: 'p139',
|
||||
content: 'Post by user u343',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
author: user,
|
||||
categoryIds,
|
||||
},
|
||||
)
|
||||
await Factory.build(
|
||||
'comment', {
|
||||
'comment',
|
||||
{
|
||||
id: 'c155',
|
||||
content: 'Comment by user u343',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
author: user,
|
||||
},
|
||||
)
|
||||
await Factory.build(
|
||||
'comment', {
|
||||
'comment',
|
||||
{
|
||||
id: 'c156',
|
||||
content: "A comment by someone else on user u343's post",
|
||||
}, {
|
||||
},
|
||||
{
|
||||
postId: 'p139',
|
||||
},
|
||||
)
|
||||
@ -269,40 +269,44 @@ describe('Delete a User as admin', () => {
|
||||
name: 'UNAVAILABLE',
|
||||
about: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
contributions: [{
|
||||
contributions: [
|
||||
{
|
||||
id: 'p139',
|
||||
content: 'Post by user u343',
|
||||
contentExcerpt: 'Post by user u343',
|
||||
deleted: false,
|
||||
comments: [{
|
||||
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: [{
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
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)
|
||||
await expect(mutate({ mutation: deleteUserMutation, variables })).resolves.toMatchObject(
|
||||
expectedResponse,
|
||||
)
|
||||
})
|
||||
|
||||
describe('deletion of all post requested', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
variables = { ...variables, resource: ['Post'] }
|
||||
})
|
||||
|
||||
|
||||
it('on request', async () => {
|
||||
const expectedResponse = {
|
||||
data: {
|
||||
@ -311,24 +315,30 @@ describe('Delete a User as admin', () => {
|
||||
name: 'UNAVAILABLE',
|
||||
about: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
contributions: [{
|
||||
contributions: [
|
||||
{
|
||||
id: 'p139',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
comments: [{
|
||||
comments: [
|
||||
{
|
||||
id: 'c156',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
}, ],
|
||||
}, ],
|
||||
comments: [{
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
id: 'c155',
|
||||
content: 'Comment by user u343',
|
||||
contentExcerpt: 'Comment by user u343',
|
||||
deleted: false,
|
||||
}, ],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -343,7 +353,6 @@ describe('Delete a User as admin', () => {
|
||||
await mutate({ mutation: deleteUserMutation, variables })
|
||||
await expect(neode.all('Image')).resolves.toHaveLength(20)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('deletion of all comments requested', () => {
|
||||
@ -351,7 +360,6 @@ describe('Delete a User as admin', () => {
|
||||
variables = { ...variables, resource: ['Comment'] }
|
||||
})
|
||||
|
||||
|
||||
it('marks comments as deleted', async () => {
|
||||
const expectedResponse = {
|
||||
data: {
|
||||
@ -360,24 +368,30 @@ describe('Delete a User as admin', () => {
|
||||
name: 'UNAVAILABLE',
|
||||
about: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
contributions: [{
|
||||
contributions: [
|
||||
{
|
||||
id: 'p139',
|
||||
content: 'Post by user u343',
|
||||
contentExcerpt: 'Post by user u343',
|
||||
deleted: false,
|
||||
comments: [{
|
||||
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: [{
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
id: 'c155',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
}, ],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -386,16 +400,11 @@ describe('Delete a User as admin', () => {
|
||||
mutate({ mutation: deleteUserMutation, variables }),
|
||||
).resolves.toMatchObject(expectedResponse)
|
||||
})
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
describe('deletion of all posts and comments requested', () => {
|
||||
beforeEach(() => {
|
||||
variables = {...variables,
|
||||
resource: ['Comment', 'Post']
|
||||
}
|
||||
variables = { ...variables, resource: ['Comment', 'Post'] }
|
||||
})
|
||||
|
||||
it('marks posts and comments as deleted', async () => {
|
||||
@ -406,24 +415,30 @@ describe('Delete a User as admin', () => {
|
||||
name: 'UNAVAILABLE',
|
||||
about: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
contributions: [{
|
||||
contributions: [
|
||||
{
|
||||
id: 'p139',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
comments: [{
|
||||
comments: [
|
||||
{
|
||||
id: 'c156',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
}, ],
|
||||
}, ],
|
||||
comments: [{
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
id: 'c155',
|
||||
content: 'UNAVAILABLE',
|
||||
contentExcerpt: 'UNAVAILABLE',
|
||||
deleted: true,
|
||||
}, ],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
errors: undefined,
|
||||
@ -458,15 +473,8 @@ describe('Delete a User as admin', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('UpdateUser', () => {
|
||||
let variables
|
||||
|
||||
@ -501,13 +509,15 @@ describe('UpdateUser', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await Factory.build(
|
||||
'user', {
|
||||
'user',
|
||||
{
|
||||
id: 'u47',
|
||||
name: 'John Doe',
|
||||
termsAndConditionsAgreedVersion: null,
|
||||
termsAndConditionsAgreedAt: null,
|
||||
allowEmbedIframes: false,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'user@example.org',
|
||||
},
|
||||
)
|
||||
@ -516,9 +526,11 @@ describe('UpdateUser', () => {
|
||||
describe('as another user', () => {
|
||||
beforeEach(async () => {
|
||||
const someoneElse = await Factory.build(
|
||||
'user', {
|
||||
'user',
|
||||
{
|
||||
name: 'James Doe',
|
||||
}, {
|
||||
},
|
||||
{
|
||||
email: 'someone-else@example.org',
|
||||
},
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user