diff --git a/backend/jest.config.js b/backend/jest.config.js index 264ad13c00..d1cc7bd3f7 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -11,7 +11,7 @@ module.exports = { ], coverageThreshold: { global: { - lines: 70, + lines: 67, }, }, testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'], diff --git a/backend/src/db/seed.ts b/backend/src/db/seed.ts index 338a30fdf8..a717ff7a68 100644 --- a/backend/src/db/seed.ts +++ b/backend/src/db/seed.ts @@ -38,244 +38,235 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] }) const { mutate } = createTestClient(server) - const [Hamburg, Berlin, Germany, Paris, France] = await Promise.all([ - Factory.build('location', { - id: 'region.5127278006398860', - name: 'Hamburg', - type: 'region', - lng: 10.0, - lat: 53.55, - nameES: 'Hamburgo', - nameFR: 'Hambourg', - nameIT: 'Amburgo', - nameEN: 'Hamburg', - namePT: 'Hamburgo', - nameDE: 'Hamburg', - nameNL: 'Hamburg', - namePL: 'Hamburg', - nameRU: 'Гамбург', - }), - Factory.build('location', { - id: 'region.14880313158564380', - type: 'region', - name: 'Berlin', - lng: 13.38333, - lat: 52.51667, - nameES: 'Berlín', - nameFR: 'Berlin', - nameIT: 'Berlino', - nameEN: 'Berlin', - namePT: 'Berlim', - nameDE: 'Berlin', - nameNL: 'Berlijn', - namePL: 'Berlin', - nameRU: 'Берлин', - }), - Factory.build('location', { - id: 'country.10743216036480410', - name: 'Germany', - type: 'country', - namePT: 'Alemanha', - nameDE: 'Deutschland', - nameES: 'Alemania', - nameNL: 'Duitsland', - namePL: 'Niemcy', - nameFR: 'Allemagne', - nameIT: 'Germania', - nameEN: 'Germany', - nameRU: 'Германия', - }), - Factory.build('location', { - id: 'region.9397217726497330', - name: 'Paris', - type: 'region', - lng: 2.35183, - lat: 48.85658, - nameES: 'París', - nameFR: 'Paris', - nameIT: 'Parigi', - nameEN: 'Paris', - namePT: 'Paris', - nameDE: 'Paris', - nameNL: 'Parijs', - namePL: 'Paryż', - nameRU: 'Париж', - }), - Factory.build('location', { - id: 'country.9759535382641660', - name: 'France', - type: 'country', - namePT: 'França', - nameDE: 'Frankreich', - nameES: 'Francia', - nameNL: 'Frankrijk', - namePL: 'Francja', - nameFR: 'France', - nameIT: 'Francia', - nameEN: 'France', - nameRU: 'Франция', - }), - ]) - await Promise.all([ - Berlin.relateTo(Germany, 'isIn'), - Hamburg.relateTo(Germany, 'isIn'), - Paris.relateTo(France, 'isIn'), - ]) - - const [racoon, rabbit, wolf, bear, turtle, rhino] = await Promise.all([ - Factory.build('badge', { - id: 'indiegogo_en_racoon', - icon: '/img/badges/indiegogo_en_racoon.svg', - }), - Factory.build('badge', { - id: 'indiegogo_en_rabbit', - icon: '/img/badges/indiegogo_en_rabbit.svg', - }), - Factory.build('badge', { - id: 'indiegogo_en_wolf', - icon: '/img/badges/indiegogo_en_wolf.svg', - }), - Factory.build('badge', { - id: 'indiegogo_en_bear', - icon: '/img/badges/indiegogo_en_bear.svg', - }), - Factory.build('badge', { - id: 'indiegogo_en_turtle', - icon: '/img/badges/indiegogo_en_turtle.svg', - }), - Factory.build('badge', { - id: 'indiegogo_en_rhino', - icon: '/img/badges/indiegogo_en_rhino.svg', - }), - ]) - - const [peterLustig, bobDerBaumeister, jennyRostock, huey, dewey, louie, dagobert] = - await Promise.all([ - Factory.build( - 'user', - { - id: 'u1', - name: 'Peter Lustig', - slug: 'peter-lustig', - role: 'admin', - }, - { - email: 'admin@example.org', - }, - ), - Factory.build( - 'user', - { - id: 'u2', - name: 'Bob der Baumeister', - slug: 'bob-der-baumeister', - role: 'moderator', - }, - { - email: 'moderator@example.org', - avatar: null, - }, - ), - Factory.build( - 'user', - { - id: 'u3', - name: 'Jenny Rostock', - slug: 'jenny-rostock', - role: 'user', - }, - { - email: 'user@example.org', - }, - ), - Factory.build( - 'user', - { - id: 'u4', - name: 'Huey', - slug: 'huey', - role: 'user', - }, - { - email: 'huey@example.org', - }, - ), - Factory.build( - 'user', - { - id: 'u5', - name: 'Dewey', - slug: 'dewey', - role: 'user', - }, - { - email: 'dewey@example.org', - avatar: null, - }, - ), - Factory.build( - 'user', - { - id: 'u6', - name: 'Louie', - slug: 'louie', - role: 'user', - }, - { - email: 'louie@example.org', - }, - ), - Factory.build( - 'user', - { - id: 'u7', - name: 'Dagobert', - slug: 'dagobert', - role: 'user', - }, - { - email: 'dagobert@example.org', - }, - ), - ]) - - await Promise.all([ - peterLustig.relateTo(Berlin, 'isIn'), - bobDerBaumeister.relateTo(Hamburg, 'isIn'), - jennyRostock.relateTo(Paris, 'isIn'), - huey.relateTo(Paris, 'isIn'), - ]) + // locations + const Hamburg = await Factory.build('location', { + id: 'region.5127278006398860', + name: 'Hamburg', + type: 'region', + lng: 10.0, + lat: 53.55, + nameES: 'Hamburgo', + nameFR: 'Hambourg', + nameIT: 'Amburgo', + nameEN: 'Hamburg', + namePT: 'Hamburgo', + nameDE: 'Hamburg', + nameNL: 'Hamburg', + namePL: 'Hamburg', + nameRU: 'Гамбург', + }) + const Berlin = await Factory.build('location', { + id: 'region.14880313158564380', + type: 'region', + name: 'Berlin', + lng: 13.38333, + lat: 52.51667, + nameES: 'Berlín', + nameFR: 'Berlin', + nameIT: 'Berlino', + nameEN: 'Berlin', + namePT: 'Berlim', + nameDE: 'Berlin', + nameNL: 'Berlijn', + namePL: 'Berlin', + nameRU: 'Берлин', + }) + const Germany = await Factory.build('location', { + id: 'country.10743216036480410', + name: 'Germany', + type: 'country', + namePT: 'Alemanha', + nameDE: 'Deutschland', + nameES: 'Alemania', + nameNL: 'Duitsland', + namePL: 'Niemcy', + nameFR: 'Allemagne', + nameIT: 'Germania', + nameEN: 'Germany', + nameRU: 'Германия', + }) + const Paris = await Factory.build('location', { + id: 'region.9397217726497330', + name: 'Paris', + type: 'region', + lng: 2.35183, + lat: 48.85658, + nameES: 'París', + nameFR: 'Paris', + nameIT: 'Parigi', + nameEN: 'Paris', + namePT: 'Paris', + nameDE: 'Paris', + nameNL: 'Parijs', + namePL: 'Paryż', + nameRU: 'Париж', + }) + const France = await Factory.build('location', { + id: 'country.9759535382641660', + name: 'France', + type: 'country', + namePT: 'França', + nameDE: 'Frankreich', + nameES: 'Francia', + nameNL: 'Frankrijk', + namePL: 'Francja', + nameFR: 'France', + nameIT: 'Francia', + nameEN: 'France', + nameRU: 'Франция', + }) + await Berlin.relateTo(Germany, 'isIn') + await Hamburg.relateTo(Germany, 'isIn') + await Paris.relateTo(France, 'isIn') + + // badges + const racoon = await Factory.build('badge', { + id: 'indiegogo_en_racoon', + icon: '/img/badges/indiegogo_en_racoon.svg', + }) + const rabbit = await Factory.build('badge', { + id: 'indiegogo_en_rabbit', + icon: '/img/badges/indiegogo_en_rabbit.svg', + }) + const wolf = await Factory.build('badge', { + id: 'indiegogo_en_wolf', + icon: '/img/badges/indiegogo_en_wolf.svg', + }) + const bear = await Factory.build('badge', { + id: 'indiegogo_en_bear', + icon: '/img/badges/indiegogo_en_bear.svg', + }) + const turtle = await Factory.build('badge', { + id: 'indiegogo_en_turtle', + icon: '/img/badges/indiegogo_en_turtle.svg', + }) + const rhino = await Factory.build('badge', { + id: 'indiegogo_en_rhino', + icon: '/img/badges/indiegogo_en_rhino.svg', + }) - await Promise.all([ - peterLustig.relateTo(racoon, 'rewarded'), - peterLustig.relateTo(rhino, 'rewarded'), - peterLustig.relateTo(wolf, 'rewarded'), - bobDerBaumeister.relateTo(racoon, 'rewarded'), - bobDerBaumeister.relateTo(turtle, 'rewarded'), - jennyRostock.relateTo(bear, 'rewarded'), - dagobert.relateTo(rabbit, 'rewarded'), - - peterLustig.relateTo(bobDerBaumeister, 'friends'), - peterLustig.relateTo(jennyRostock, 'friends'), - bobDerBaumeister.relateTo(jennyRostock, 'friends'), - - peterLustig.relateTo(jennyRostock, 'following'), - peterLustig.relateTo(huey, 'following'), - bobDerBaumeister.relateTo(huey, 'following'), - jennyRostock.relateTo(huey, 'following'), - huey.relateTo(dewey, 'following'), - dewey.relateTo(huey, 'following'), - louie.relateTo(jennyRostock, 'following'), - - huey.relateTo(dagobert, 'muted'), - dewey.relateTo(dagobert, 'muted'), - louie.relateTo(dagobert, 'muted'), - - dagobert.relateTo(huey, 'blocked'), - dagobert.relateTo(dewey, 'blocked'), - dagobert.relateTo(louie, 'blocked'), - ]) + // users + const peterLustig = await Factory.build( + 'user', + { + id: 'u1', + name: 'Peter Lustig', + slug: 'peter-lustig', + role: 'admin', + }, + { + email: 'admin@example.org', + }, + ) + const bobDerBaumeister = await Factory.build( + 'user', + { + id: 'u2', + name: 'Bob der Baumeister', + slug: 'bob-der-baumeister', + role: 'moderator', + }, + { + email: 'moderator@example.org', + avatar: null, + }, + ) + const jennyRostock = await Factory.build( + 'user', + { + id: 'u3', + name: 'Jenny Rostock', + slug: 'jenny-rostock', + role: 'user', + }, + { + email: 'user@example.org', + }, + ) + const huey = await Factory.build( + 'user', + { + id: 'u4', + name: 'Huey', + slug: 'huey', + role: 'user', + }, + { + email: 'huey@example.org', + }, + ) + const dewey = await Factory.build( + 'user', + { + id: 'u5', + name: 'Dewey', + slug: 'dewey', + role: 'user', + }, + { + email: 'dewey@example.org', + avatar: null, + }, + ) + const louie = await Factory.build( + 'user', + { + id: 'u6', + name: 'Louie', + slug: 'louie', + role: 'user', + }, + { + email: 'louie@example.org', + }, + ) + const dagobert = await Factory.build( + 'user', + { + id: 'u7', + name: 'Dagobert', + slug: 'dagobert', + role: 'user', + }, + { + email: 'dagobert@example.org', + }, + ) + await peterLustig.relateTo(Berlin, 'isIn') + await bobDerBaumeister.relateTo(Hamburg, 'isIn') + await jennyRostock.relateTo(Paris, 'isIn') + await huey.relateTo(Paris, 'isIn') + + await peterLustig.relateTo(racoon, 'rewarded') + await peterLustig.relateTo(rhino, 'rewarded') + await peterLustig.relateTo(wolf, 'rewarded') + await bobDerBaumeister.relateTo(racoon, 'rewarded') + await bobDerBaumeister.relateTo(turtle, 'rewarded') + await jennyRostock.relateTo(bear, 'rewarded') + await dagobert.relateTo(rabbit, 'rewarded') + + await peterLustig.relateTo(bobDerBaumeister, 'friends') + await peterLustig.relateTo(jennyRostock, 'friends') + await bobDerBaumeister.relateTo(jennyRostock, 'friends') + + await peterLustig.relateTo(jennyRostock, 'following') + await peterLustig.relateTo(huey, 'following') + await bobDerBaumeister.relateTo(huey, 'following') + await jennyRostock.relateTo(huey, 'following') + await huey.relateTo(dewey, 'following') + await dewey.relateTo(huey, 'following') + await louie.relateTo(jennyRostock, 'following') + + await huey.relateTo(dagobert, 'muted') + await dewey.relateTo(dagobert, 'muted') + await louie.relateTo(dagobert, 'muted') + + await dagobert.relateTo(huey, 'blocked') + await dagobert.relateTo(dewey, 'blocked') + await dagobert.relateTo(louie, 'blocked') + + // categories await Promise.all( categories.map(({ icon, name }, index) => { 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([ - Factory.build('tag', { - id: 'Environment', - }), - Factory.build('tag', { - id: 'Nature', - }), - Factory.build('tag', { - id: 'Democracy', - }), - Factory.build('tag', { - id: 'Freedom', - }), - ]) - - // Create Groups + const environment = await Factory.build('tag', { + id: 'Environment', + }) + const nature = await Factory.build('tag', { + id: 'Nature', + }) + const democracy = await Factory.build('tag', { + id: 'Democracy', + }) + const freedom = await Factory.build('tag', { + id: 'Freedom', + }) + // groups authenticatedUser = await peterLustig.toJson() await Promise.all([ mutate({ @@ -668,166 +656,164 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 3).toISOString(), }) - // Create Posts (Articles) - - const [p0, p1, p3, p4, p5, p6, p9, p10, p11, p13, p14, p15] = await Promise.all([ - Factory.build( - 'post', - { - id: 'p0', - language: sample(languages), - }, - { - categoryIds: ['cat16'], - author: peterLustig, - image: Factory.build('image', { - url: faker.image.unsplash.food(300, 169), - sensitive: true, - aspectRatio: 300 / 169, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p1', - language: sample(languages), - }, - { - categoryIds: ['cat1'], - author: bobDerBaumeister, - image: Factory.build('image', { - url: faker.image.unsplash.technology(300, 1500), - aspectRatio: 300 / 1500, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p3', - language: sample(languages), - }, - { - categoryIds: ['cat3'], - author: huey, - }, - ), - Factory.build( - 'post', - { - id: 'p4', - language: sample(languages), - }, - { - categoryIds: ['cat4'], - author: dewey, - }, - ), - Factory.build( - 'post', - { - id: 'p5', - language: sample(languages), - }, - { - categoryIds: ['cat5'], - author: louie, - }, - ), - Factory.build( - 'post', - { - id: 'p6', - language: sample(languages), - }, - { - categoryIds: ['cat6'], - author: peterLustig, - image: Factory.build('image', { - url: faker.image.unsplash.buildings(300, 857), - aspectRatio: 300 / 857, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p9', - language: sample(languages), - }, - { - categoryIds: ['cat9'], - author: huey, - }, - ), - Factory.build( - 'post', - { - id: 'p10', - }, - { - categoryIds: ['cat10'], - author: dewey, - image: Factory.build('image', { - sensitive: true, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p11', - language: sample(languages), - }, - { - categoryIds: ['cat11'], - author: louie, - image: Factory.build('image', { - url: faker.image.unsplash.people(300, 901), - aspectRatio: 300 / 901, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p13', - language: sample(languages), - }, - { - categoryIds: ['cat13'], - author: bobDerBaumeister, - }, - ), - Factory.build( - 'post', - { - id: 'p14', - language: sample(languages), - }, - { - categoryIds: ['cat14'], - author: jennyRostock, - image: Factory.build('image', { - url: faker.image.unsplash.objects(300, 200), - aspectRatio: 300 / 450, - }), - }, - ), - Factory.build( - 'post', - { - id: 'p15', - language: sample(languages), - }, - { - categoryIds: ['cat15'], - author: huey, - }, - ), - ]) + // posts (articles) + const p0 = await Factory.build( + 'post', + { + id: 'p0', + language: sample(languages), + }, + { + categoryIds: ['cat16'], + author: peterLustig, + image: Factory.build('image', { + url: faker.image.unsplash.food(300, 169), + sensitive: true, + aspectRatio: 300 / 169, + }), + }, + ) + const p1 = await Factory.build( + 'post', + { + id: 'p1', + language: sample(languages), + }, + { + categoryIds: ['cat1'], + author: bobDerBaumeister, + image: Factory.build('image', { + url: faker.image.unsplash.technology(300, 1500), + aspectRatio: 300 / 1500, + }), + }, + ) + const p3 = await Factory.build( + 'post', + { + id: 'p3', + language: sample(languages), + }, + { + categoryIds: ['cat3'], + author: huey, + }, + ) + const p4 = await Factory.build( + 'post', + { + id: 'p4', + language: sample(languages), + }, + { + categoryIds: ['cat4'], + author: dewey, + }, + ) + const p5 = await Factory.build( + 'post', + { + id: 'p5', + language: sample(languages), + }, + { + categoryIds: ['cat5'], + author: louie, + }, + ) + const p6 = await Factory.build( + 'post', + { + id: 'p6', + language: sample(languages), + }, + { + categoryIds: ['cat6'], + author: peterLustig, + image: Factory.build('image', { + url: faker.image.unsplash.buildings(300, 857), + aspectRatio: 300 / 857, + }), + }, + ) + const p9 = await Factory.build( + 'post', + { + id: 'p9', + language: sample(languages), + }, + { + categoryIds: ['cat9'], + author: huey, + }, + ) + const p10 = await Factory.build( + 'post', + { + id: 'p10', + }, + { + categoryIds: ['cat10'], + author: dewey, + image: Factory.build('image', { + sensitive: true, + }), + }, + ) + const p11 = await Factory.build( + 'post', + { + id: 'p11', + language: sample(languages), + }, + { + categoryIds: ['cat11'], + author: louie, + image: Factory.build('image', { + url: faker.image.unsplash.people(300, 901), + aspectRatio: 300 / 901, + }), + }, + ) + const p13 = await Factory.build( + 'post', + { + id: 'p13', + language: sample(languages), + }, + { + categoryIds: ['cat13'], + author: bobDerBaumeister, + }, + ) + const p14 = await Factory.build( + 'post', + { + id: 'p14', + language: sample(languages), + }, + { + categoryIds: ['cat14'], + author: jennyRostock, + image: Factory.build('image', { + url: faker.image.unsplash.objects(300, 200), + aspectRatio: 300 / 450, + }), + }, + ) + const p15 = await Factory.build( + 'post', + { + id: 'p15', + language: sample(languages), + }, + { + categoryIds: ['cat15'], + author: huey, + }, + ) + // invite code await Factory.build( 'inviteCode', { @@ -924,8 +910,9 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] ]) authenticatedUser = null - const comments = await Promise.all([ - Factory.build( + const comments: any[] = [] + comments.push( + await Factory.build( 'comment', { id: 'c1', @@ -935,7 +922,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p1', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c2', @@ -945,7 +932,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p1', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c3', @@ -955,7 +942,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p3', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c5', @@ -965,7 +952,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p3', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c6', @@ -975,7 +962,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p4', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c7', @@ -985,7 +972,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p2', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c8', @@ -995,7 +982,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p15', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c9', @@ -1005,7 +992,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p15', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c10', @@ -1015,7 +1002,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p15', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c11', @@ -1025,7 +1012,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p15', }, ), - Factory.build( + await Factory.build( 'comment', { id: 'c12', @@ -1035,84 +1022,81 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] postId: 'p15', }, ), - ]) + ) const trollingComment = comments[0] - await Promise.all([ - democracy.relateTo(p3, 'post'), - democracy.relateTo(p11, 'post'), - democracy.relateTo(p15, 'post'), - democracy.relateTo(p7, 'post'), - environment.relateTo(p1, 'post'), - environment.relateTo(p5, 'post'), - environment.relateTo(p9, 'post'), - environment.relateTo(p13, 'post'), - freedom.relateTo(p0, 'post'), - freedom.relateTo(p4, 'post'), - freedom.relateTo(p8, 'post'), - freedom.relateTo(p12, 'post'), - nature.relateTo(p2, 'post'), - nature.relateTo(p6, 'post'), - nature.relateTo(p10, 'post'), - nature.relateTo(p14, 'post'), - peterLustig.relateTo(p15, 'emoted', { emotion: 'surprised' }), - bobDerBaumeister.relateTo(p15, 'emoted', { emotion: 'surprised' }), - jennyRostock.relateTo(p15, 'emoted', { emotion: 'surprised' }), - huey.relateTo(p15, 'emoted', { emotion: 'surprised' }), - dewey.relateTo(p15, 'emoted', { emotion: 'surprised' }), - louie.relateTo(p15, 'emoted', { emotion: 'surprised' }), - dagobert.relateTo(p15, 'emoted', { emotion: 'surprised' }), - bobDerBaumeister.relateTo(p14, 'emoted', { emotion: 'cry' }), - jennyRostock.relateTo(p13, 'emoted', { emotion: 'angry' }), - huey.relateTo(p12, 'emoted', { emotion: 'funny' }), - dewey.relateTo(p11, 'emoted', { emotion: 'surprised' }), - louie.relateTo(p10, 'emoted', { emotion: 'cry' }), - dewey.relateTo(p9, 'emoted', { emotion: 'happy' }), - huey.relateTo(p8, 'emoted', { emotion: 'angry' }), - jennyRostock.relateTo(p7, 'emoted', { emotion: 'funny' }), - bobDerBaumeister.relateTo(p6, 'emoted', { emotion: 'surprised' }), - peterLustig.relateTo(p5, 'emoted', { emotion: 'cry' }), - bobDerBaumeister.relateTo(p4, 'emoted', { emotion: 'happy' }), - jennyRostock.relateTo(p3, 'emoted', { emotion: 'angry' }), - huey.relateTo(p2, 'emoted', { emotion: 'funny' }), - dewey.relateTo(p1, 'emoted', { emotion: 'surprised' }), - louie.relateTo(p0, 'emoted', { emotion: 'cry' }), - ]) - - await Promise.all([ - peterLustig.relateTo(p1, 'shouted'), - peterLustig.relateTo(p6, 'shouted'), - bobDerBaumeister.relateTo(p0, 'shouted'), - bobDerBaumeister.relateTo(p6, 'shouted'), - jennyRostock.relateTo(p6, 'shouted'), - jennyRostock.relateTo(p7, 'shouted'), - huey.relateTo(p8, 'shouted'), - huey.relateTo(p9, 'shouted'), - dewey.relateTo(p10, 'shouted'), - peterLustig.relateTo(p2, 'shouted'), - peterLustig.relateTo(p6, 'shouted'), - bobDerBaumeister.relateTo(p0, 'shouted'), - bobDerBaumeister.relateTo(p6, 'shouted'), - jennyRostock.relateTo(p6, 'shouted'), - jennyRostock.relateTo(p7, 'shouted'), - huey.relateTo(p8, 'shouted'), - huey.relateTo(p9, 'shouted'), - louie.relateTo(p10, 'shouted'), - ]) - const reports = await Promise.all([ - Factory.build('report'), - Factory.build('report'), - Factory.build('report'), - Factory.build('report'), - ]) + await democracy.relateTo(p3, 'post') + await democracy.relateTo(p11, 'post') + await democracy.relateTo(p15, 'post') + await democracy.relateTo(p7, 'post') + await environment.relateTo(p1, 'post') + await environment.relateTo(p5, 'post') + await environment.relateTo(p9, 'post') + await environment.relateTo(p13, 'post') + await freedom.relateTo(p0, 'post') + await freedom.relateTo(p4, 'post') + await freedom.relateTo(p8, 'post') + await freedom.relateTo(p12, 'post') + await nature.relateTo(p2, 'post') + await nature.relateTo(p6, 'post') + await nature.relateTo(p10, 'post') + await nature.relateTo(p14, 'post') + await peterLustig.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await bobDerBaumeister.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await jennyRostock.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await huey.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await dewey.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await louie.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await dagobert.relateTo(p15, 'emoted', { emotion: 'surprised' }) + await bobDerBaumeister.relateTo(p14, 'emoted', { emotion: 'cry' }) + await jennyRostock.relateTo(p13, 'emoted', { emotion: 'angry' }) + await huey.relateTo(p12, 'emoted', { emotion: 'funny' }) + await dewey.relateTo(p11, 'emoted', { emotion: 'surprised' }) + await louie.relateTo(p10, 'emoted', { emotion: 'cry' }) + await dewey.relateTo(p9, 'emoted', { emotion: 'happy' }) + await huey.relateTo(p8, 'emoted', { emotion: 'angry' }) + await jennyRostock.relateTo(p7, 'emoted', { emotion: 'funny' }) + await bobDerBaumeister.relateTo(p6, 'emoted', { emotion: 'surprised' }) + await peterLustig.relateTo(p5, 'emoted', { emotion: 'cry' }) + await bobDerBaumeister.relateTo(p4, 'emoted', { emotion: 'happy' }) + await jennyRostock.relateTo(p3, 'emoted', { emotion: 'angry' }) + await huey.relateTo(p2, 'emoted', { emotion: 'funny' }) + await dewey.relateTo(p1, 'emoted', { emotion: 'surprised' }) + await louie.relateTo(p0, 'emoted', { emotion: 'cry' }) + + await peterLustig.relateTo(p1, 'shouted') + await peterLustig.relateTo(p6, 'shouted') + await bobDerBaumeister.relateTo(p0, 'shouted') + await bobDerBaumeister.relateTo(p6, 'shouted') + await jennyRostock.relateTo(p6, 'shouted') + await jennyRostock.relateTo(p7, 'shouted') + await huey.relateTo(p8, 'shouted') + await huey.relateTo(p9, 'shouted') + await dewey.relateTo(p10, 'shouted') + await peterLustig.relateTo(p2, 'shouted') + await peterLustig.relateTo(p6, 'shouted') + await bobDerBaumeister.relateTo(p0, 'shouted') + await bobDerBaumeister.relateTo(p6, 'shouted') + await jennyRostock.relateTo(p6, 'shouted') + await jennyRostock.relateTo(p7, 'shouted') + await huey.relateTo(p8, 'shouted') + await huey.relateTo(p9, 'shouted') + await louie.relateTo(p10, 'shouted') + + const reports: any[] = [] + reports.push( + await Factory.build('report'), + await Factory.build('report'), + await Factory.build('report'), + await Factory.build('report'), + ) const reportAgainstDagobert = reports[0] const reportAgainstTrollingPost = reports[1] const reportAgainstTrollingComment = reports[2] const reportAgainstDewey = reports[3] // report resource first time - await reportAgainstDagobert.relateTo(jennyRostock, 'filed', { resourceId: 'u7', reasonCategory: 'discrimination_etc', @@ -1139,27 +1123,25 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] await reportAgainstDewey.relateTo(dewey, 'belongsTo') // report resource a second time - await Promise.all([ - reportAgainstDagobert.relateTo(louie, 'filed', { - resourceId: 'u7', - reasonCategory: 'discrimination_etc', - reasonDescription: 'this user is attacking me for who I am!', - }), - reportAgainstDagobert.relateTo(dagobert, 'belongsTo'), - reportAgainstTrollingPost.relateTo(peterLustig, 'filed', { - resourceId: 'p2', - reasonCategory: 'discrimination_etc', - reasonDescription: 'This post is bigoted', - }), - reportAgainstTrollingPost.relateTo(p2, 'belongsTo'), + await reportAgainstDagobert.relateTo(louie, 'filed', { + resourceId: 'u7', + reasonCategory: 'discrimination_etc', + reasonDescription: 'this user is attacking me for who I am!', + }) + await reportAgainstDagobert.relateTo(dagobert, 'belongsTo') + await reportAgainstTrollingPost.relateTo(peterLustig, 'filed', { + resourceId: 'p2', + reasonCategory: 'discrimination_etc', + reasonDescription: 'This post is bigoted', + }) + await reportAgainstTrollingPost.relateTo(p2, 'belongsTo') - reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'filed', { - resourceId: 'c1', - reasonCategory: 'pornographic_content_links', - reasonDescription: 'This comment is porno!!!', - }), - reportAgainstTrollingComment.relateTo(trollingComment, 'belongsTo'), - ]) + await reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'filed', { + resourceId: 'c1', + reasonCategory: 'pornographic_content_links', + reasonDescription: 'This comment is porno!!!', + }) + await reportAgainstTrollingComment.relateTo(trollingComment, 'belongsTo') const disableVariables = { resourceId: 'undefined-resource', @@ -1168,46 +1150,46 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] } // review resource first time - await Promise.all([ - reportAgainstDagobert.relateTo(bobDerBaumeister, 'reviewed', { - ...disableVariables, - resourceId: 'u7', - }), - dagobert.update({ disabled: true, updatedAt: new Date().toISOString() }), - reportAgainstTrollingPost.relateTo(peterLustig, 'reviewed', { - ...disableVariables, - resourceId: 'p2', - }), - p2.update({ disabled: true, updatedAt: new Date().toISOString() }), - reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'reviewed', { - ...disableVariables, - resourceId: 'c1', - }), - trollingComment.update({ disabled: true, updatedAt: new Date().toISOString() }), - ]) + await reportAgainstDagobert.relateTo(bobDerBaumeister, 'reviewed', { + ...disableVariables, + resourceId: 'u7', + }) + await dagobert.update({ disabled: true, updatedAt: new Date().toISOString() }) + await reportAgainstTrollingPost.relateTo(peterLustig, 'reviewed', { + ...disableVariables, + resourceId: 'p2', + }) + await p2.update({ disabled: true, updatedAt: new Date().toISOString() }) + await reportAgainstTrollingComment.relateTo(bobDerBaumeister, 'reviewed', { + ...disableVariables, + resourceId: 'c1', + }) + await trollingComment.update({ disabled: true, updatedAt: new Date().toISOString() }) // second review of resource and close report - await Promise.all([ - reportAgainstDagobert.relateTo(peterLustig, 'reviewed', { - resourceId: 'u7', - disable: false, - closed: true, - }), - dagobert.update({ disabled: false, updatedAt: new Date().toISOString(), closed: true }), - reportAgainstTrollingPost.relateTo(bobDerBaumeister, 'reviewed', { - resourceId: 'p2', - disable: true, - closed: true, - }), - p2.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }), - reportAgainstTrollingComment.relateTo(peterLustig, 'reviewed', { - ...disableVariables, - resourceId: 'c1', - disable: true, - closed: true, - }), - trollingComment.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }), - ]) + await reportAgainstDagobert.relateTo(peterLustig, 'reviewed', { + resourceId: 'u7', + disable: false, + closed: true, + }) + await dagobert.update({ disabled: false, updatedAt: new Date().toISOString(), closed: true }) + await reportAgainstTrollingPost.relateTo(bobDerBaumeister, 'reviewed', { + resourceId: 'p2', + disable: true, + closed: true, + }) + await p2.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }) + await reportAgainstTrollingComment.relateTo(peterLustig, 'reviewed', { + ...disableVariables, + resourceId: 'c1', + disable: true, + closed: true, + }) + await trollingComment.update({ + disabled: true, + updatedAt: new Date().toISOString(), + closed: true, + }) const additionalUsers = await Promise.all( [...Array(30).keys()].map(() => Factory.build('user')),