mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #6520 from Ocelot-Social-Community/refactor-seed
refactor(backend): fix seed to not use promise all where easily refactored
This commit is contained in:
commit
da0f7094a8
@ -11,7 +11,7 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
lines: 70,
|
lines: 67,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],
|
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],
|
||||||
|
|||||||
@ -38,8 +38,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
const { mutate } = createTestClient(server)
|
const { mutate } = createTestClient(server)
|
||||||
|
|
||||||
const [Hamburg, Berlin, Germany, Paris, France] = await Promise.all([
|
// locations
|
||||||
Factory.build('location', {
|
const Hamburg = await Factory.build('location', {
|
||||||
id: 'region.5127278006398860',
|
id: 'region.5127278006398860',
|
||||||
name: 'Hamburg',
|
name: 'Hamburg',
|
||||||
type: 'region',
|
type: 'region',
|
||||||
@ -54,8 +54,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
nameNL: 'Hamburg',
|
nameNL: 'Hamburg',
|
||||||
namePL: 'Hamburg',
|
namePL: 'Hamburg',
|
||||||
nameRU: 'Гамбург',
|
nameRU: 'Гамбург',
|
||||||
}),
|
})
|
||||||
Factory.build('location', {
|
const Berlin = await Factory.build('location', {
|
||||||
id: 'region.14880313158564380',
|
id: 'region.14880313158564380',
|
||||||
type: 'region',
|
type: 'region',
|
||||||
name: 'Berlin',
|
name: 'Berlin',
|
||||||
@ -70,8 +70,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
nameNL: 'Berlijn',
|
nameNL: 'Berlijn',
|
||||||
namePL: 'Berlin',
|
namePL: 'Berlin',
|
||||||
nameRU: 'Берлин',
|
nameRU: 'Берлин',
|
||||||
}),
|
})
|
||||||
Factory.build('location', {
|
const Germany = await Factory.build('location', {
|
||||||
id: 'country.10743216036480410',
|
id: 'country.10743216036480410',
|
||||||
name: 'Germany',
|
name: 'Germany',
|
||||||
type: 'country',
|
type: 'country',
|
||||||
@ -84,8 +84,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
nameIT: 'Germania',
|
nameIT: 'Germania',
|
||||||
nameEN: 'Germany',
|
nameEN: 'Germany',
|
||||||
nameRU: 'Германия',
|
nameRU: 'Германия',
|
||||||
}),
|
})
|
||||||
Factory.build('location', {
|
const Paris = await Factory.build('location', {
|
||||||
id: 'region.9397217726497330',
|
id: 'region.9397217726497330',
|
||||||
name: 'Paris',
|
name: 'Paris',
|
||||||
type: 'region',
|
type: 'region',
|
||||||
@ -100,8 +100,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
nameNL: 'Parijs',
|
nameNL: 'Parijs',
|
||||||
namePL: 'Paryż',
|
namePL: 'Paryż',
|
||||||
nameRU: 'Париж',
|
nameRU: 'Париж',
|
||||||
}),
|
})
|
||||||
Factory.build('location', {
|
const France = await Factory.build('location', {
|
||||||
id: 'country.9759535382641660',
|
id: 'country.9759535382641660',
|
||||||
name: 'France',
|
name: 'France',
|
||||||
type: 'country',
|
type: 'country',
|
||||||
@ -114,44 +114,39 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
nameIT: 'Francia',
|
nameIT: 'Francia',
|
||||||
nameEN: 'France',
|
nameEN: 'France',
|
||||||
nameRU: 'Франция',
|
nameRU: 'Франция',
|
||||||
}),
|
})
|
||||||
])
|
await Berlin.relateTo(Germany, 'isIn')
|
||||||
await Promise.all([
|
await Hamburg.relateTo(Germany, 'isIn')
|
||||||
Berlin.relateTo(Germany, 'isIn'),
|
await Paris.relateTo(France, 'isIn')
|
||||||
Hamburg.relateTo(Germany, 'isIn'),
|
|
||||||
Paris.relateTo(France, 'isIn'),
|
|
||||||
])
|
|
||||||
|
|
||||||
const [racoon, rabbit, wolf, bear, turtle, rhino] = await Promise.all([
|
// badges
|
||||||
Factory.build('badge', {
|
const racoon = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_racoon',
|
id: 'indiegogo_en_racoon',
|
||||||
icon: '/img/badges/indiegogo_en_racoon.svg',
|
icon: '/img/badges/indiegogo_en_racoon.svg',
|
||||||
}),
|
})
|
||||||
Factory.build('badge', {
|
const rabbit = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_rabbit',
|
id: 'indiegogo_en_rabbit',
|
||||||
icon: '/img/badges/indiegogo_en_rabbit.svg',
|
icon: '/img/badges/indiegogo_en_rabbit.svg',
|
||||||
}),
|
})
|
||||||
Factory.build('badge', {
|
const wolf = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_wolf',
|
id: 'indiegogo_en_wolf',
|
||||||
icon: '/img/badges/indiegogo_en_wolf.svg',
|
icon: '/img/badges/indiegogo_en_wolf.svg',
|
||||||
}),
|
})
|
||||||
Factory.build('badge', {
|
const bear = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_bear',
|
id: 'indiegogo_en_bear',
|
||||||
icon: '/img/badges/indiegogo_en_bear.svg',
|
icon: '/img/badges/indiegogo_en_bear.svg',
|
||||||
}),
|
})
|
||||||
Factory.build('badge', {
|
const turtle = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_turtle',
|
id: 'indiegogo_en_turtle',
|
||||||
icon: '/img/badges/indiegogo_en_turtle.svg',
|
icon: '/img/badges/indiegogo_en_turtle.svg',
|
||||||
}),
|
})
|
||||||
Factory.build('badge', {
|
const rhino = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_rhino',
|
id: 'indiegogo_en_rhino',
|
||||||
icon: '/img/badges/indiegogo_en_rhino.svg',
|
icon: '/img/badges/indiegogo_en_rhino.svg',
|
||||||
}),
|
})
|
||||||
])
|
|
||||||
|
|
||||||
const [peterLustig, bobDerBaumeister, jennyRostock, huey, dewey, louie, dagobert] =
|
// users
|
||||||
await Promise.all([
|
const peterLustig = await Factory.build(
|
||||||
Factory.build(
|
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
@ -162,8 +157,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
{
|
{
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const bobDerBaumeister = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
@ -175,8 +170,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
email: 'moderator@example.org',
|
email: 'moderator@example.org',
|
||||||
avatar: null,
|
avatar: null,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const jennyRostock = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u3',
|
id: 'u3',
|
||||||
@ -187,8 +182,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
{
|
{
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const huey = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u4',
|
id: 'u4',
|
||||||
@ -199,8 +194,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
{
|
{
|
||||||
email: 'huey@example.org',
|
email: 'huey@example.org',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const dewey = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u5',
|
id: 'u5',
|
||||||
@ -212,8 +207,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
email: 'dewey@example.org',
|
email: 'dewey@example.org',
|
||||||
avatar: null,
|
avatar: null,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const louie = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u6',
|
id: 'u6',
|
||||||
@ -224,8 +219,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
{
|
{
|
||||||
email: 'louie@example.org',
|
email: 'louie@example.org',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const dagobert = await Factory.build(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
id: 'u7',
|
id: 'u7',
|
||||||
@ -236,46 +231,42 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
{
|
{
|
||||||
email: 'dagobert@example.org',
|
email: 'dagobert@example.org',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
])
|
|
||||||
|
|
||||||
await Promise.all([
|
await peterLustig.relateTo(Berlin, 'isIn')
|
||||||
peterLustig.relateTo(Berlin, 'isIn'),
|
await bobDerBaumeister.relateTo(Hamburg, 'isIn')
|
||||||
bobDerBaumeister.relateTo(Hamburg, 'isIn'),
|
await jennyRostock.relateTo(Paris, 'isIn')
|
||||||
jennyRostock.relateTo(Paris, 'isIn'),
|
await huey.relateTo(Paris, 'isIn')
|
||||||
huey.relateTo(Paris, 'isIn'),
|
|
||||||
])
|
|
||||||
|
|
||||||
await Promise.all([
|
await peterLustig.relateTo(racoon, 'rewarded')
|
||||||
peterLustig.relateTo(racoon, 'rewarded'),
|
await peterLustig.relateTo(rhino, 'rewarded')
|
||||||
peterLustig.relateTo(rhino, 'rewarded'),
|
await peterLustig.relateTo(wolf, 'rewarded')
|
||||||
peterLustig.relateTo(wolf, 'rewarded'),
|
await bobDerBaumeister.relateTo(racoon, 'rewarded')
|
||||||
bobDerBaumeister.relateTo(racoon, 'rewarded'),
|
await bobDerBaumeister.relateTo(turtle, 'rewarded')
|
||||||
bobDerBaumeister.relateTo(turtle, 'rewarded'),
|
await jennyRostock.relateTo(bear, 'rewarded')
|
||||||
jennyRostock.relateTo(bear, 'rewarded'),
|
await dagobert.relateTo(rabbit, 'rewarded')
|
||||||
dagobert.relateTo(rabbit, 'rewarded'),
|
|
||||||
|
|
||||||
peterLustig.relateTo(bobDerBaumeister, 'friends'),
|
await peterLustig.relateTo(bobDerBaumeister, 'friends')
|
||||||
peterLustig.relateTo(jennyRostock, 'friends'),
|
await peterLustig.relateTo(jennyRostock, 'friends')
|
||||||
bobDerBaumeister.relateTo(jennyRostock, 'friends'),
|
await bobDerBaumeister.relateTo(jennyRostock, 'friends')
|
||||||
|
|
||||||
peterLustig.relateTo(jennyRostock, 'following'),
|
await peterLustig.relateTo(jennyRostock, 'following')
|
||||||
peterLustig.relateTo(huey, 'following'),
|
await peterLustig.relateTo(huey, 'following')
|
||||||
bobDerBaumeister.relateTo(huey, 'following'),
|
await bobDerBaumeister.relateTo(huey, 'following')
|
||||||
jennyRostock.relateTo(huey, 'following'),
|
await jennyRostock.relateTo(huey, 'following')
|
||||||
huey.relateTo(dewey, 'following'),
|
await huey.relateTo(dewey, 'following')
|
||||||
dewey.relateTo(huey, 'following'),
|
await dewey.relateTo(huey, 'following')
|
||||||
louie.relateTo(jennyRostock, 'following'),
|
await louie.relateTo(jennyRostock, 'following')
|
||||||
|
|
||||||
huey.relateTo(dagobert, 'muted'),
|
await huey.relateTo(dagobert, 'muted')
|
||||||
dewey.relateTo(dagobert, 'muted'),
|
await dewey.relateTo(dagobert, 'muted')
|
||||||
louie.relateTo(dagobert, 'muted'),
|
await louie.relateTo(dagobert, 'muted')
|
||||||
|
|
||||||
dagobert.relateTo(huey, 'blocked'),
|
await dagobert.relateTo(huey, 'blocked')
|
||||||
dagobert.relateTo(dewey, 'blocked'),
|
await dagobert.relateTo(dewey, 'blocked')
|
||||||
dagobert.relateTo(louie, 'blocked'),
|
await dagobert.relateTo(louie, 'blocked')
|
||||||
])
|
|
||||||
|
|
||||||
|
// categories
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
categories.map(({ icon, name }, index) => {
|
categories.map(({ icon, name }, index) => {
|
||||||
return Factory.build('category', {
|
return Factory.build('category', {
|
||||||
@ -287,23 +278,20 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
const [environment, nature, democracy, freedom] = await Promise.all([
|
const environment = await Factory.build('tag', {
|
||||||
Factory.build('tag', {
|
|
||||||
id: 'Environment',
|
id: 'Environment',
|
||||||
}),
|
})
|
||||||
Factory.build('tag', {
|
const nature = await Factory.build('tag', {
|
||||||
id: 'Nature',
|
id: 'Nature',
|
||||||
}),
|
})
|
||||||
Factory.build('tag', {
|
const democracy = await Factory.build('tag', {
|
||||||
id: 'Democracy',
|
id: 'Democracy',
|
||||||
}),
|
})
|
||||||
Factory.build('tag', {
|
const freedom = await Factory.build('tag', {
|
||||||
id: 'Freedom',
|
id: 'Freedom',
|
||||||
}),
|
})
|
||||||
])
|
|
||||||
|
|
||||||
// Create Groups
|
|
||||||
|
|
||||||
|
// groups
|
||||||
authenticatedUser = await peterLustig.toJson()
|
authenticatedUser = await peterLustig.toJson()
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
mutate({
|
mutate({
|
||||||
@ -668,10 +656,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 3).toISOString(),
|
eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 3).toISOString(),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Create Posts (Articles)
|
// posts (articles)
|
||||||
|
const p0 = await Factory.build(
|
||||||
const [p0, p1, p3, p4, p5, p6, p9, p10, p11, p13, p14, p15] = await Promise.all([
|
|
||||||
Factory.build(
|
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p0',
|
id: 'p0',
|
||||||
@ -686,8 +672,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
aspectRatio: 300 / 169,
|
aspectRatio: 300 / 169,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p1 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
@ -701,8 +687,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
aspectRatio: 300 / 1500,
|
aspectRatio: 300 / 1500,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p3 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p3',
|
id: 'p3',
|
||||||
@ -712,8 +698,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat3'],
|
categoryIds: ['cat3'],
|
||||||
author: huey,
|
author: huey,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p4 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p4',
|
id: 'p4',
|
||||||
@ -723,8 +709,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat4'],
|
categoryIds: ['cat4'],
|
||||||
author: dewey,
|
author: dewey,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p5 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p5',
|
id: 'p5',
|
||||||
@ -734,8 +720,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat5'],
|
categoryIds: ['cat5'],
|
||||||
author: louie,
|
author: louie,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p6 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p6',
|
id: 'p6',
|
||||||
@ -749,8 +735,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
aspectRatio: 300 / 857,
|
aspectRatio: 300 / 857,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p9 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p9',
|
id: 'p9',
|
||||||
@ -760,8 +746,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat9'],
|
categoryIds: ['cat9'],
|
||||||
author: huey,
|
author: huey,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p10 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p10',
|
id: 'p10',
|
||||||
@ -773,8 +759,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
sensitive: true,
|
sensitive: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p11 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p11',
|
id: 'p11',
|
||||||
@ -788,8 +774,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
aspectRatio: 300 / 901,
|
aspectRatio: 300 / 901,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p13 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p13',
|
id: 'p13',
|
||||||
@ -799,8 +785,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat13'],
|
categoryIds: ['cat13'],
|
||||||
author: bobDerBaumeister,
|
author: bobDerBaumeister,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p14 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p14',
|
id: 'p14',
|
||||||
@ -814,8 +800,8 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
aspectRatio: 300 / 450,
|
aspectRatio: 300 / 450,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
Factory.build(
|
const p15 = await Factory.build(
|
||||||
'post',
|
'post',
|
||||||
{
|
{
|
||||||
id: 'p15',
|
id: 'p15',
|
||||||
@ -825,9 +811,9 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
categoryIds: ['cat15'],
|
categoryIds: ['cat15'],
|
||||||
author: huey,
|
author: huey,
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
])
|
|
||||||
|
|
||||||
|
// invite code
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
'inviteCode',
|
'inviteCode',
|
||||||
{
|
{
|
||||||
@ -924,8 +910,9 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
])
|
])
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
|
|
||||||
const comments = await Promise.all([
|
const comments: any[] = []
|
||||||
Factory.build(
|
comments.push(
|
||||||
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c1',
|
id: 'c1',
|
||||||
@ -935,7 +922,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p1',
|
postId: 'p1',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c2',
|
id: 'c2',
|
||||||
@ -945,7 +932,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p1',
|
postId: 'p1',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c3',
|
id: 'c3',
|
||||||
@ -955,7 +942,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p3',
|
postId: 'p3',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c5',
|
id: 'c5',
|
||||||
@ -965,7 +952,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p3',
|
postId: 'p3',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c6',
|
id: 'c6',
|
||||||
@ -975,7 +962,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p4',
|
postId: 'p4',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c7',
|
id: 'c7',
|
||||||
@ -985,7 +972,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p2',
|
postId: 'p2',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c8',
|
id: 'c8',
|
||||||
@ -995,7 +982,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p15',
|
postId: 'p15',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c9',
|
id: 'c9',
|
||||||
@ -1005,7 +992,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p15',
|
postId: 'p15',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c10',
|
id: 'c10',
|
||||||
@ -1015,7 +1002,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p15',
|
postId: 'p15',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c11',
|
id: 'c11',
|
||||||
@ -1025,7 +1012,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p15',
|
postId: 'p15',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Factory.build(
|
await Factory.build(
|
||||||
'comment',
|
'comment',
|
||||||
{
|
{
|
||||||
id: 'c12',
|
id: 'c12',
|
||||||
@ -1035,84 +1022,81 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
postId: 'p15',
|
postId: 'p15',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
])
|
)
|
||||||
|
|
||||||
const trollingComment = comments[0]
|
const trollingComment = comments[0]
|
||||||
|
|
||||||
await Promise.all([
|
await democracy.relateTo(p3, 'post')
|
||||||
democracy.relateTo(p3, 'post'),
|
await democracy.relateTo(p11, 'post')
|
||||||
democracy.relateTo(p11, 'post'),
|
await democracy.relateTo(p15, 'post')
|
||||||
democracy.relateTo(p15, 'post'),
|
await democracy.relateTo(p7, 'post')
|
||||||
democracy.relateTo(p7, 'post'),
|
await environment.relateTo(p1, 'post')
|
||||||
environment.relateTo(p1, 'post'),
|
await environment.relateTo(p5, 'post')
|
||||||
environment.relateTo(p5, 'post'),
|
await environment.relateTo(p9, 'post')
|
||||||
environment.relateTo(p9, 'post'),
|
await environment.relateTo(p13, 'post')
|
||||||
environment.relateTo(p13, 'post'),
|
await freedom.relateTo(p0, 'post')
|
||||||
freedom.relateTo(p0, 'post'),
|
await freedom.relateTo(p4, 'post')
|
||||||
freedom.relateTo(p4, 'post'),
|
await freedom.relateTo(p8, 'post')
|
||||||
freedom.relateTo(p8, 'post'),
|
await freedom.relateTo(p12, 'post')
|
||||||
freedom.relateTo(p12, 'post'),
|
await nature.relateTo(p2, 'post')
|
||||||
nature.relateTo(p2, 'post'),
|
await nature.relateTo(p6, 'post')
|
||||||
nature.relateTo(p6, 'post'),
|
await nature.relateTo(p10, 'post')
|
||||||
nature.relateTo(p10, 'post'),
|
await nature.relateTo(p14, 'post')
|
||||||
nature.relateTo(p14, 'post'),
|
await peterLustig.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
peterLustig.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await bobDerBaumeister.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
bobDerBaumeister.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await jennyRostock.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
jennyRostock.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await huey.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
huey.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await dewey.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
dewey.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await louie.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
louie.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await dagobert.relateTo(p15, 'emoted', { emotion: 'surprised' })
|
||||||
dagobert.relateTo(p15, 'emoted', { emotion: 'surprised' }),
|
await bobDerBaumeister.relateTo(p14, 'emoted', { emotion: 'cry' })
|
||||||
bobDerBaumeister.relateTo(p14, 'emoted', { emotion: 'cry' }),
|
await jennyRostock.relateTo(p13, 'emoted', { emotion: 'angry' })
|
||||||
jennyRostock.relateTo(p13, 'emoted', { emotion: 'angry' }),
|
await huey.relateTo(p12, 'emoted', { emotion: 'funny' })
|
||||||
huey.relateTo(p12, 'emoted', { emotion: 'funny' }),
|
await dewey.relateTo(p11, 'emoted', { emotion: 'surprised' })
|
||||||
dewey.relateTo(p11, 'emoted', { emotion: 'surprised' }),
|
await louie.relateTo(p10, 'emoted', { emotion: 'cry' })
|
||||||
louie.relateTo(p10, 'emoted', { emotion: 'cry' }),
|
await dewey.relateTo(p9, 'emoted', { emotion: 'happy' })
|
||||||
dewey.relateTo(p9, 'emoted', { emotion: 'happy' }),
|
await huey.relateTo(p8, 'emoted', { emotion: 'angry' })
|
||||||
huey.relateTo(p8, 'emoted', { emotion: 'angry' }),
|
await jennyRostock.relateTo(p7, 'emoted', { emotion: 'funny' })
|
||||||
jennyRostock.relateTo(p7, 'emoted', { emotion: 'funny' }),
|
await bobDerBaumeister.relateTo(p6, 'emoted', { emotion: 'surprised' })
|
||||||
bobDerBaumeister.relateTo(p6, 'emoted', { emotion: 'surprised' }),
|
await peterLustig.relateTo(p5, 'emoted', { emotion: 'cry' })
|
||||||
peterLustig.relateTo(p5, 'emoted', { emotion: 'cry' }),
|
await bobDerBaumeister.relateTo(p4, 'emoted', { emotion: 'happy' })
|
||||||
bobDerBaumeister.relateTo(p4, 'emoted', { emotion: 'happy' }),
|
await jennyRostock.relateTo(p3, 'emoted', { emotion: 'angry' })
|
||||||
jennyRostock.relateTo(p3, 'emoted', { emotion: 'angry' }),
|
await huey.relateTo(p2, 'emoted', { emotion: 'funny' })
|
||||||
huey.relateTo(p2, 'emoted', { emotion: 'funny' }),
|
await dewey.relateTo(p1, 'emoted', { emotion: 'surprised' })
|
||||||
dewey.relateTo(p1, 'emoted', { emotion: 'surprised' }),
|
await louie.relateTo(p0, 'emoted', { emotion: 'cry' })
|
||||||
louie.relateTo(p0, 'emoted', { emotion: 'cry' }),
|
|
||||||
])
|
|
||||||
|
|
||||||
await Promise.all([
|
await peterLustig.relateTo(p1, 'shouted')
|
||||||
peterLustig.relateTo(p1, 'shouted'),
|
await peterLustig.relateTo(p6, 'shouted')
|
||||||
peterLustig.relateTo(p6, 'shouted'),
|
await bobDerBaumeister.relateTo(p0, 'shouted')
|
||||||
bobDerBaumeister.relateTo(p0, 'shouted'),
|
await bobDerBaumeister.relateTo(p6, 'shouted')
|
||||||
bobDerBaumeister.relateTo(p6, 'shouted'),
|
await jennyRostock.relateTo(p6, 'shouted')
|
||||||
jennyRostock.relateTo(p6, 'shouted'),
|
await jennyRostock.relateTo(p7, 'shouted')
|
||||||
jennyRostock.relateTo(p7, 'shouted'),
|
await huey.relateTo(p8, 'shouted')
|
||||||
huey.relateTo(p8, 'shouted'),
|
await huey.relateTo(p9, 'shouted')
|
||||||
huey.relateTo(p9, 'shouted'),
|
await dewey.relateTo(p10, 'shouted')
|
||||||
dewey.relateTo(p10, 'shouted'),
|
await peterLustig.relateTo(p2, 'shouted')
|
||||||
peterLustig.relateTo(p2, 'shouted'),
|
await peterLustig.relateTo(p6, 'shouted')
|
||||||
peterLustig.relateTo(p6, 'shouted'),
|
await bobDerBaumeister.relateTo(p0, 'shouted')
|
||||||
bobDerBaumeister.relateTo(p0, 'shouted'),
|
await bobDerBaumeister.relateTo(p6, 'shouted')
|
||||||
bobDerBaumeister.relateTo(p6, 'shouted'),
|
await jennyRostock.relateTo(p6, 'shouted')
|
||||||
jennyRostock.relateTo(p6, 'shouted'),
|
await jennyRostock.relateTo(p7, 'shouted')
|
||||||
jennyRostock.relateTo(p7, 'shouted'),
|
await huey.relateTo(p8, 'shouted')
|
||||||
huey.relateTo(p8, 'shouted'),
|
await huey.relateTo(p9, 'shouted')
|
||||||
huey.relateTo(p9, 'shouted'),
|
await louie.relateTo(p10, 'shouted')
|
||||||
louie.relateTo(p10, 'shouted'),
|
|
||||||
])
|
const reports: any[] = []
|
||||||
const reports = await Promise.all([
|
reports.push(
|
||||||
Factory.build('report'),
|
await Factory.build('report'),
|
||||||
Factory.build('report'),
|
await Factory.build('report'),
|
||||||
Factory.build('report'),
|
await Factory.build('report'),
|
||||||
Factory.build('report'),
|
await Factory.build('report'),
|
||||||
])
|
)
|
||||||
const reportAgainstDagobert = reports[0]
|
const reportAgainstDagobert = reports[0]
|
||||||
const reportAgainstTrollingPost = reports[1]
|
const reportAgainstTrollingPost = reports[1]
|
||||||
const reportAgainstTrollingComment = reports[2]
|
const reportAgainstTrollingComment = reports[2]
|
||||||
const reportAgainstDewey = reports[3]
|
const reportAgainstDewey = reports[3]
|
||||||
|
|
||||||
// report resource first time
|
// report resource first time
|
||||||
|
|
||||||
await reportAgainstDagobert.relateTo(jennyRostock, 'filed', {
|
await reportAgainstDagobert.relateTo(jennyRostock, 'filed', {
|
||||||
resourceId: 'u7',
|
resourceId: 'u7',
|
||||||
reasonCategory: 'discrimination_etc',
|
reasonCategory: 'discrimination_etc',
|
||||||
@ -1139,27 +1123,25 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
await reportAgainstDewey.relateTo(dewey, 'belongsTo')
|
await reportAgainstDewey.relateTo(dewey, 'belongsTo')
|
||||||
|
|
||||||
// report resource a second time
|
// report resource a second time
|
||||||
await Promise.all([
|
await reportAgainstDagobert.relateTo(louie, 'filed', {
|
||||||
reportAgainstDagobert.relateTo(louie, 'filed', {
|
|
||||||
resourceId: 'u7',
|
resourceId: 'u7',
|
||||||
reasonCategory: 'discrimination_etc',
|
reasonCategory: 'discrimination_etc',
|
||||||
reasonDescription: 'this user is attacking me for who I am!',
|
reasonDescription: 'this user is attacking me for who I am!',
|
||||||
}),
|
})
|
||||||
reportAgainstDagobert.relateTo(dagobert, 'belongsTo'),
|
await reportAgainstDagobert.relateTo(dagobert, 'belongsTo')
|
||||||
reportAgainstTrollingPost.relateTo(peterLustig, 'filed', {
|
await reportAgainstTrollingPost.relateTo(peterLustig, 'filed', {
|
||||||
resourceId: 'p2',
|
resourceId: 'p2',
|
||||||
reasonCategory: 'discrimination_etc',
|
reasonCategory: 'discrimination_etc',
|
||||||
reasonDescription: 'This post is bigoted',
|
reasonDescription: 'This post is bigoted',
|
||||||
}),
|
})
|
||||||
reportAgainstTrollingPost.relateTo(p2, 'belongsTo'),
|
await reportAgainstTrollingPost.relateTo(p2, 'belongsTo')
|
||||||
|
|
||||||
reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'filed', {
|
await reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'filed', {
|
||||||
resourceId: 'c1',
|
resourceId: 'c1',
|
||||||
reasonCategory: 'pornographic_content_links',
|
reasonCategory: 'pornographic_content_links',
|
||||||
reasonDescription: 'This comment is porno!!!',
|
reasonDescription: 'This comment is porno!!!',
|
||||||
}),
|
})
|
||||||
reportAgainstTrollingComment.relateTo(trollingComment, 'belongsTo'),
|
await reportAgainstTrollingComment.relateTo(trollingComment, 'belongsTo')
|
||||||
])
|
|
||||||
|
|
||||||
const disableVariables = {
|
const disableVariables = {
|
||||||
resourceId: 'undefined-resource',
|
resourceId: 'undefined-resource',
|
||||||
@ -1168,46 +1150,46 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
}
|
}
|
||||||
|
|
||||||
// review resource first time
|
// review resource first time
|
||||||
await Promise.all([
|
await reportAgainstDagobert.relateTo(bobDerBaumeister, 'reviewed', {
|
||||||
reportAgainstDagobert.relateTo(bobDerBaumeister, 'reviewed', {
|
|
||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'u7',
|
resourceId: 'u7',
|
||||||
}),
|
})
|
||||||
dagobert.update({ disabled: true, updatedAt: new Date().toISOString() }),
|
await dagobert.update({ disabled: true, updatedAt: new Date().toISOString() })
|
||||||
reportAgainstTrollingPost.relateTo(peterLustig, 'reviewed', {
|
await reportAgainstTrollingPost.relateTo(peterLustig, 'reviewed', {
|
||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'p2',
|
resourceId: 'p2',
|
||||||
}),
|
})
|
||||||
p2.update({ disabled: true, updatedAt: new Date().toISOString() }),
|
await p2.update({ disabled: true, updatedAt: new Date().toISOString() })
|
||||||
reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'reviewed', {
|
await reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'reviewed', {
|
||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'c1',
|
resourceId: 'c1',
|
||||||
}),
|
})
|
||||||
trollingComment.update({ disabled: true, updatedAt: new Date().toISOString() }),
|
await trollingComment.update({ disabled: true, updatedAt: new Date().toISOString() })
|
||||||
])
|
|
||||||
|
|
||||||
// second review of resource and close report
|
// second review of resource and close report
|
||||||
await Promise.all([
|
await reportAgainstDagobert.relateTo(peterLustig, 'reviewed', {
|
||||||
reportAgainstDagobert.relateTo(peterLustig, 'reviewed', {
|
|
||||||
resourceId: 'u7',
|
resourceId: 'u7',
|
||||||
disable: false,
|
disable: false,
|
||||||
closed: true,
|
closed: true,
|
||||||
}),
|
})
|
||||||
dagobert.update({ disabled: false, updatedAt: new Date().toISOString(), closed: true }),
|
await dagobert.update({ disabled: false, updatedAt: new Date().toISOString(), closed: true })
|
||||||
reportAgainstTrollingPost.relateTo(bobDerBaumeister, 'reviewed', {
|
await reportAgainstTrollingPost.relateTo(bobDerBaumeister, 'reviewed', {
|
||||||
resourceId: 'p2',
|
resourceId: 'p2',
|
||||||
disable: true,
|
disable: true,
|
||||||
closed: true,
|
closed: true,
|
||||||
}),
|
})
|
||||||
p2.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }),
|
await p2.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true })
|
||||||
reportAgainstTrollingComment.relateTo(peterLustig, 'reviewed', {
|
await reportAgainstTrollingComment.relateTo(peterLustig, 'reviewed', {
|
||||||
...disableVariables,
|
...disableVariables,
|
||||||
resourceId: 'c1',
|
resourceId: 'c1',
|
||||||
disable: true,
|
disable: true,
|
||||||
closed: true,
|
closed: true,
|
||||||
}),
|
})
|
||||||
trollingComment.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }),
|
await trollingComment.update({
|
||||||
])
|
disabled: true,
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
closed: true,
|
||||||
|
})
|
||||||
|
|
||||||
const additionalUsers = await Promise.all(
|
const additionalUsers = await Promise.all(
|
||||||
[...Array(30).keys()].map(() => Factory.build('user')),
|
[...Array(30).keys()].map(() => Factory.build('user')),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user