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'] 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: () => {
@ -57,9 +89,11 @@ 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',
}, },
@ -126,13 +160,15 @@ 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',
}, },
) )
@ -141,9 +177,11 @@ 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',
}, },
) )
@ -237,8 +275,7 @@ 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: [] }
@ -252,9 +289,11 @@ 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',
}, },
@ -282,9 +321,11 @@ 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',
}, },
@ -313,9 +354,11 @@ 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',
}, },
@ -336,27 +379,33 @@ describe('Delete a User as admin', () => {
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',
}, },
) )
@ -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,
@ -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,
@ -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,
@ -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,
@ -551,3 +624,5 @@ describe('Delete a User as admin', () => {
}) })
}) })
}) })
*/

View File

@ -13,7 +13,6 @@
</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') }}
@ -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;