fix: prework for tests

This commit is contained in:
ogerly 2020-08-05 13:45:24 +02:00
parent 8b7b1056ac
commit 0b62d76bc1
2 changed files with 540 additions and 466 deletions

View File

@ -6,15 +6,47 @@ import { createTestClient } from 'apollo-server-testing'
const categoryIds = ['cat9']
let user
//let anotherUser
//let moderator
//let admin
let query
let mutate
let authenticatedUser
let variables
//let variables
const driver = getDriver()
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(() => {
const { server } = createServer({
context: () => {
@ -57,9 +89,11 @@ describe('User', () => {
describe('as admin', () => {
beforeEach(async () => {
const admin = await Factory.build(
'user', {
'user',
{
role: 'admin',
}, {
},
{
email: 'admin@example.org',
password: '1234',
},
@ -126,13 +160,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',
},
)
@ -141,9 +177,11 @@ describe('UpdateUser', () => {
describe('as another user', () => {
beforeEach(async () => {
const someoneElse = await Factory.build(
'user', {
'user',
{
name: 'James Doe',
}, {
},
{
email: 'someone-else@example.org',
},
)
@ -237,8 +275,7 @@ describe('UpdateUser', () => {
})
})
})
/*
describe('Delete a User as another user', () => {
beforeEach(async () => {
variables = { id: ' u343', resource: [] }
@ -252,9 +289,11 @@ describe('Delete a User as another user', () => {
beforeEach(async () => {
anotherUser = await Factory.build(
'user', {
'user',
{
role: 'user',
}, {
},
{
email: 'user@example.org',
password: '1234',
},
@ -282,9 +321,11 @@ describe('Delete a User as moderator', () => {
beforeEach(async () => {
moderator = await Factory.build(
'user', {
'user',
{
role: 'moderator',
}, {
},
{
email: 'moderator@example.org',
password: '1234',
},
@ -313,9 +354,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',
},
@ -336,27 +379,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',
},
)
@ -370,24 +419,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: 'Comment by user u343',
contentExcerpt: 'Comment by user u343',
deleted: false,
}, ],
},
],
},
},
errors: undefined,
@ -410,24 +465,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,
@ -457,24 +518,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,
@ -498,24 +565,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,
@ -551,3 +624,5 @@ describe('Delete a User as admin', () => {
})
})
})
*/

View File

@ -13,7 +13,6 @@
</ds-flex-item>
<ds-flex-item width="20%">
<ds-text size="small">
<relative-date-time :date-time="userdata.createdAt" class="relative-date-time" />
<br />
{{ $t('modals.deleteUser.created') }}
@ -162,7 +161,7 @@ export default {
<style lang="scss">
.ds-modal {
max-width: 600px !important;
max-width: 700px !important;
}
.hc-modal-success {
pointer-events: none;