From 760f899379e074ddf84612fb34d5a3735d3ffa71 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 1 Jul 2019 16:18:14 +0200 Subject: [PATCH 01/52] import emotions --- .../migration/neo4j/emotions/delete.cql | 1 + .../migration/neo4j/emotions/emotions.cql | 57 +++++++++++++------ .../migration/neo4j/import.sh | 6 +- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql index e69de29bb..18fb6699f 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql @@ -0,0 +1 @@ +MATCH (u:User)-[e:EMOTED]->(c:Post) DETACH DELETE e; \ No newline at end of file diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql index 8aad9e923..06341f277 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql @@ -5,31 +5,54 @@ // [-] Omitted in Nitro // [?] Unclear / has work to be done for Nitro { -[ ] userId: { -[ ] type: String, -[ ] required: true, +[X] userId: { +[X] type: String, +[X] required: true, [-] index: true }, -[ ] contributionId: { -[ ] type: String, -[ ] required: true, +[X] contributionId: { +[X] type: String, +[X] required: true, [-] index: true }, -[ ] rated: { -[ ] type: String, +[?] rated: { +[X] type: String, [ ] required: true, -[ ] enum: ['funny', 'happy', 'surprised', 'cry', 'angry'] +[?] enum: ['funny', 'happy', 'surprised', 'cry', 'angry'] }, -[ ] createdAt: { -[ ] type: Date, -[ ] default: Date.now +[X] createdAt: { +[X] type: Date, +[X] default: Date.now }, -[ ] updatedAt: { -[ ] type: Date, -[ ] default: Date.now +[X] updatedAt: { +[X] type: Date, +[X] default: Date.now }, -[ ] wasSeeded: { type: Boolean } +[-] wasSeeded: { type: Boolean } } */ -CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as emotion; +CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as emotion +MATCH (u:User {id: emotion.userId}), + (c:Post {id: emotion.contributionId}) +MERGE (u)-[e:EMOTED { + id: emotion._id["$oid"], + emotion: emotion.rated, + createdAt: datetime(emotion.createdAt.`$date`), + updatedAt: datetime(emotion.updatedAt.`$date`) + }]->(c) +RETURN e; +/* + // Queries + // user sets an emotion emotion: + // MERGE (u)-[e:EMOTED {id: ..., emotion: "funny", createdAt: ..., updatedAt: ...}]->(c) + // user removes emotion + // MATCH (u)-[e:EMOTED]->(c) DELETE e + // contribution distributions over every `emotion` property value for one post + // MATCH (u:User)-[e:EMOTED]->(c:Post {id: "5a70bbc8508f5b000b443b1a"}) RETURN e.emotion,COUNT(e.emotion) + // contribution distributions over every `emotion` property value for one user (advanced - "whats the primary emotion used by the user?") + // MATCH (u:User{id:"5a663b1ac64291000bf302a1"})-[e:EMOTED]->(c:Post) RETURN e.emotion,COUNT(e.emotion) + // contribution distributions over every `emotion` property value for all posts created by one user (advanced - "how do others react to my contributions?") + // MATCH (u:User)-[e:EMOTED]->(c:Post)<-[w:WROTE]-(a:User{id:"5a663b1ac64291000bf302a1"}) RETURN e.emotion,COUNT(e.emotion) + // if we can filter the above an a variable timescale that would be great (should be possible on createdAt and updatedAt fields) +*/ \ No newline at end of file diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index 8eef68c92..cef2846a7 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -60,8 +60,8 @@ delete_collection "contributions" "contributions_post" delete_collection "contributions" "contributions_cando" delete_collection "shouts" "shouts" delete_collection "comments" "comments" +delete_collection "emotions" "emotions" -#delete_collection "emotions" #delete_collection "invites" #delete_collection "notifications" #delete_collection "organizations" @@ -82,12 +82,12 @@ import_collection "users" "users/users.cql" import_collection "follows_users" "follows/follows.cql" #import_collection "follows_organizations" "follows/follows.cql" import_collection "contributions_post" "contributions/contributions.cql" -import_collection "contributions_cando" "contributions/contributions.cql" +#import_collection "contributions_cando" "contributions/contributions.cql" #import_collection "contributions_DELETED" "contributions/contributions.cql" import_collection "shouts" "shouts/shouts.cql" import_collection "comments" "comments/comments.cql" +import_collection "emotions" "emotions/emotions.cql" -# import_collection "emotions" # import_collection "invites" # import_collection "notifications" # import_collection "organizations" From 44205e72687a48752bbf055689f32f2d25f94e23 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 1 Jul 2019 16:18:49 +0200 Subject: [PATCH 02/52] delete follows correctly --- .../maintenance-worker/migration/neo4j/follows/delete.cql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql index 3624448c3..3de01f8ea 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql @@ -1 +1 @@ -// this is just a relation between users(?) - no need to delete \ No newline at end of file +MATCH (u1:User)-[f:FOLLOWS]->(u2:User) DETACH DELETE f; \ No newline at end of file From a264ff8eee2837d5d742bdfb6893e720779efc3a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 1 Jul 2019 16:21:11 +0200 Subject: [PATCH 03/52] emotion data modelling --- backend/src/schema/types/type/EMOTED.gql | 10 ++++++++++ backend/src/schema/types/type/Post.gql | 2 ++ backend/src/schema/types/type/User.gql | 2 ++ 3 files changed, 14 insertions(+) create mode 100644 backend/src/schema/types/type/EMOTED.gql diff --git a/backend/src/schema/types/type/EMOTED.gql b/backend/src/schema/types/type/EMOTED.gql new file mode 100644 index 000000000..4c79d88e3 --- /dev/null +++ b/backend/src/schema/types/type/EMOTED.gql @@ -0,0 +1,10 @@ +type EMOTED @relation(name: "EMOTED") { + from: User + to: Post + + emotion: String + #createdAt: DateTime + #updatedAt: DateTime + createdAt: String + updatedAt: String +} \ No newline at end of file diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 271d92750..4b5d67572 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -48,4 +48,6 @@ type Post { RETURN COUNT(u) >= 1 """ ) + + emotions: [EMOTED] } diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 6836f16fe..63151db8d 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -77,4 +77,6 @@ type User { badges: [Badge]! @relation(name: "REWARDED", direction: "IN") badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)") + + emotions: [EMOTED] } From 07b8116447c48c877aaaecd2330056fb9ce193a5 Mon Sep 17 00:00:00 2001 From: senderfm Date: Wed, 3 Jul 2019 22:51:39 +0200 Subject: [PATCH 04/52] Update of polish locales --- webapp/locales/pl.json | 295 +++++++++++++++++++++++++++++++---------- 1 file changed, 226 insertions(+), 69 deletions(-) diff --git a/webapp/locales/pl.json b/webapp/locales/pl.json index 506a04f1b..e1c825cca 100644 --- a/webapp/locales/pl.json +++ b/webapp/locales/pl.json @@ -1,13 +1,42 @@ { + "filter-menu": { + "title": "Twoja bańka filtrująca" + }, "login": { "copy": "Jeśli masz już konto Human Connection, zaloguj się tutaj.", "login": "logowanie", "logout": "Wyloguj się", "email": "Twój adres e-mail", "password": "Twoje hasło", + "forgotPassword": "Zapomniałeś hasła?", "moreInfo": "Co to jest Human Connection?", + "moreInfoURL": "https://human-connection.org/pl/", + "moreInfoHint": "na stronę prezentacji", "hello": "Cześć" }, + "password-reset": { + "title": "Zresetuj hasło", + "form": { + "description": "Na podany adres e-mail zostanie wysłany email z resetem hasła.", + "submit": "Poproś o wiadomość e-mail", + "submitted": "Na adres {email} została wysłana wiadomość z dalszymi instrukcjami." + } + }, + "verify-code": { + "form": { + "code": "Wprowadź swój kod", + "description": "Otwórz swoją skrzynkę odbiorczą i wpisz kod, który do Ciebie wysłaliśmy.", + "next": "Kontynuuj", + "change-password": { + "success": "Zmiana hasła zakończyła się sukcesem!", + "error": "Zmiana hasła nie powiodła się. Może kod bezpieczeństwa nie był poprawny?", + "help": "W przypadku problemów, zachęcamy do zwrócenia się o pomoc, wysyłając do nas wiadomość e-mail:" + } + } + }, + "editor": { + "placeholder": "Zostaw swoje inspirujące myśli...." + }, "profile": { "name": "Mój profil", "memberSince": "Członek od", @@ -16,7 +45,27 @@ "following": "Obserwowani", "shouted": "Krzyknij", "commented": "Skomentuj", - "userAnonym": "Anonymous" + "userAnonym": "Anonimowy", + "socialMedia": "Gdzie indziej mogę znaleźć", + "network": { + "title": "Sieć", + "following": "jest następująca:", + "followingNobody": "nie podąża za nikim.", + "followedBy": "po którym następuje:", + "followedByNobody": "nie jest śledzona przez nikogo.", + "and": "i", + "more": "więcej" + } + }, + "notifications": { + "menu": { + "mentioned": "wspomniała o tobie na posterunku." + } + }, + "search": { + "placeholder": "Wyszukiwanie", + "hint": "Czego szukasz?", + "failed": "Nic nie znaleziono" }, "settings": { "name": "Ustawienia", @@ -25,10 +74,28 @@ "labelName": "Twoje dane", "namePlaceholder": "Anonymous", "labelCity": "Twoje miasto lub region", - "labelBio": "O Tobie" + "labelBio": "O Tobie", + "success": "Twoje dane zostały pomyślnie zaktualizowane!" }, "security": { - "name": "Bezpieczeństwo" + "name": "Bezpieczeństwo", + "change-password": { + "button": "Zmień hasło", + "success": "Hasło zostało pomyślnie zmienione!", + "label-old-password": "Twoje stare hasło", + "label-new-password": "Twoje nowe hasło", + "label-new-password-confirm": "Potwierdź nowe hasło", + "message-old-password-required": "Wprowadź swoje stare hasło", + "message-new-password-required": "Wprowadź nowe hasło", + "message-new-password-confirm-required": "Potwierdź nowe hasło.", + "message-new-password-missmatch": "Wpisz ponownie to samo hasło.", + "passwordSecurity": "Zabezpieczenie hasłem", + "passwordStrength0": "Bardzo niepewne hasło", + "passwordStrength1": "Niepewne hasło", + "passwordStrength2": "Hasło pośredniczące", + "passwordStrength3": "Silne hasło", + "passwordStrength4": "Bardzo mocne hasło" + } }, "invites": { "name": "Zaproszenia" @@ -36,29 +103,42 @@ "download": { "name": "Pobierz dane" }, - "delete": { - "name": "Usuń konto" + "deleteUserAccount": { + "name": "Usuwanie danych", + "contributionsCount": "Usuń moje stanowiska.", + "commentsCount": "Usuń moje komentarze {liczba}.", + "accountDescription": "Bądź świadomy, że Twój post i komentarze są ważne dla naszej społeczności. Jeśli nadal chcesz je usunąć, musisz zaznaczyć je poniżej.", + "accountWarning": "Nie możesz zarządzać i Nie możesz REKOVER swoje konto, posty lub komentarze po usunięciu konta!", + "success": "Konto zostało pomyślnie usunięte", + "pleaseConfirm": "Niszczycielskie działanie! Typ {potwierdź} aby potwierdzić" }, "organizations": { - "name": "Moje organizacje" + "name": "My Organizations" }, "languages": { - "name": "Języki" + "name": "Languages" + }, + "social-media": { + "name": "Social media", + "placeholder": "Add social media url", + "submit": "Add link", + "successAdd": "Added social media. Updated user profile!", + "successDelete": "Deleted social media. Updated user profile!" } }, "admin": { - "name": "Administrator", + "name": "Admin", "dashboard": { "name": "Tablica rozdzielcza", "users": "Użytkownicy", - "posts": "Posty", + "posts": "Stanowiska", "comments": "Komentarze", "notifications": "Powiadomienia", "organizations": "Organizacje", "projects": "Projekty", - "invites": "Zaproszenia", - "follows": "Obserwowań", - "shouts": "Okrzyk" + "invites": "Zaprasza", + "follows": "Podąża za", + "shouts": "Zalecane" }, "organizations": { "name": "Organizacje" @@ -75,116 +155,193 @@ "categories": { "name": "Kategorie", "categoryName": "Nazwa", - "postCount": "Posty" + "postCount": "Stanowiska" }, "tags": { - "name": "Tagi", + "name": "Znaczniki", "tagCountUnique": "Użytkownicy", - "tagCount": "Posty" + "tagCount": "Stanowiska" }, "settings": { "name": "Ustawienia" } }, "post": { - "name": "Post", + "name": "Poczta", "moreInfo": { "name": "Więcej informacji" }, "takeAction": { - "name": "Podejmij działanie" + "name": "Podejmij działania" + }, + "menu": { + "edit": "Edytuj Post", + "delete": "Usuń wpis" + }, + "comment": { + "submit": "Komentarz", + "submitted": "Przedłożony komentarz" } }, + "comment": { + "content": { + "unavailable-placeholder": " ...ten komentarz nie jest już dostępny." + }, + "menu": { + "edit": "Edytuj komentarz", + "delete": "Usuń komentarz" + }, + "show": { + "more": "Pokaż więcej", + "less": "Pokaż mniej" + } + + }, "quotes": { "african": { - "quote": "Wielu małych ludzi w wielu małych miejscach robi wiele małych rzeczy, które mogą zmienić oblicze świata.", + "quote": "Wielu małych ludzi w wielu małych miejscowościach robi wiele małych rzeczy, które mogą zmienić oblicze świata.", "author": "Afrykańskie przysłowie" } }, "common": { - "post": "Post ::: Posty", + "post": "Poczta ::: Posty", "comment": "Komentarz ::: Komentarze", "letsTalk": "Porozmawiajmy", - "versus": "Versus", + "versus": "werset", "moreInfo": "Więcej informacji", - "takeAction": "Podejmij działanie", - "shout": "okrzyk okrzyki", + "takeAction": "Podejmij działania", + "shout": "przekazanie sprawy ::: Polecam tę stronę", "user": "Użytkownik ::: Użytkownicy", - "category": "kategoria kategorie", - "organization": "Organizacja ::: Organizacje", + "category": "Kategoria ::: Kategorie", + "organization": "Organization ::: Organizations", "project": "Projekt ::: Projekty", - "tag": "Tag ::: Tagi", - "name": "imię", - "loadMore": "załaduj więcej", - "loading": "ładowanie", - "reportContent": "Raport" + "tag": "Znacznik ::: Znaczniki", + "name": "Nazwa", + "loadMore": "Obciążenie więcej", + "loading": "załadunek", + "reportContent": "Sprawozdanie", + "validations": { + "email": "musi być ważny adres e-mail.", + "verification-code": "musi mieć długość 6 znaków." + } }, "actions": { - "loading": "ładowanie", - "loadMore": "załaduj więcej", - "create": "Stwórz", - "save": "Zapisz", - "edit": "Edytuj", + "loading": "załadunek", + "loadMore": "Obciążenie więcej", + "create": "Tworzenie", + "save": "Oszczędzaj", + "edit": "Edycja", "delete": "Usuń", - "cancel": "Anuluj" + "cancel": "Odwołaj" }, "moderation": { - "name": "Moderacja", + "name": "Umiarkowanie", "reports": { - "empty": "Gratulacje, moderacja nie jest potrzebna", - "name": "Raporty", - "reporter": "zgłoszone przez" + "empty": "Gratulacje, nic do umiarkowanego.", + "name": "Sprawozdania", + "submitter": "zgłaszane przez", + "disabledBy": "niepełnosprawni przez" } }, "disable": { + "submit": "Niepełnosprawność", + "cancel": "Odwołaj", + "success": "Niepełnosprawni skutecznie", "user": { - "title": "Ukryj użytkownika", + "title": "Wyłączenie użytkownika", "type": "Użytkownik", - "message": "Czy na pewno chcesz wyłączyć użytkownika \" {name} \"?" + "message": "Czy naprawdę chcesz wyłączyć użytkownika \"{name}\"?" }, "contribution": { - "title": "Ukryj wpis", - "type": "Wpis / Post", - "message": "Czy na pewno chcesz ukryć wpis \" tytuł} \"?" + "title": "Wyłącz Wkład", + "type": "Wkład", + "message": "Naprawdę chcesz unieszkodliwić ten wkład \"{name}\"?" }, "comment": { - "title": "Ukryj wpis", + "title": "Wyłącz komentarz", "type": "Komentarz", - "message": "Czy na pewno chcesz ukryć komentarz użytkownika\"(Imie/Avatar\"?" + "message": "Naprawdę chcesz wyłączyć komentarz \"{name}\"?" + } + }, + "delete": { + "submit": "Usuń", + "cancel": "Odwołaj", + "contribution": { + "title": "Usuń Post", + "type": "Wkład", + "message": "Naprawdę chcesz usunąć post \"{name}\"?", + "success": "Wyślij pomyślnie usunięty!" + }, + "comment": { + "title": "Usuń komentarz", + "type": "Komentarz", + "message": "Czy naprawdę chcesz usunąć komentarz \"{name}\"?", + "success": "Komentarz został pomyślnie usunięty!" } }, "report": { - "submit": "Wyślij raport", - "cancel": "Anuluj", + "submit": "Sprawozdanie", + "cancel": "Odwołaj", + "success": "Dzięki za zgłoszenie!", "user": { - "title": "Zgłoś użytkownika", + "title": "Raport Użytkownik", "type": "Użytkownik", - "message": "Czy na pewno chcesz zgłosić użytkownika \" {Imie} \"?" + "message": "Naprawdę chcesz zgłosić użytkownika \"{name}\"?", + "error": "Zgłosiłeś już użytkownika!" }, "contribution": { - "title": "Zgłoś wpis", - "type": "Wpis / Post", - "message": "Czy na pewno chcesz zgłosić ten wpis użytkownika \" {Imie} \"?" + "title": "Wkład w raport", + "type": "Wkład", + "message": "Naprawdę chcesz zgłosić wkład, jaki wniosłaś do programu \"{name}\"?", + "error": "Zgłosiłeś już ten wkład!" }, "comment": { - "title": "Zgłoś komentarz", + "title": "Sprawozdanie Komentarz", "type": "Komentarz", - "message": "Czy na pewno chcesz zgłosić komentarz użytkownika\"(Imie/Avatar\"?" + "message": "Naprawdę chcesz zgłosić komentarz od \"{name}\"?", + "error": "Zgłosiłeś już komentarz!" + } + }, + "followButton": { + "follow": "naśladować", + "following": "w skutek" + }, + "shoutButton": { + "shouted": "wykrzyczany" + }, + "release": { + "submit": "Zwolnienie", + "cancel": "Odwołaj", + "success": "Wydany z powodzeniem!", + "user": { + "title": "Zwolnienie użytkownika", + "type": "Użytkownik", + "message": "Naprawdę chcesz uwolnić użytkownika \"{name}\"?" + }, + "contribution": { + "title": "Zwolnienie Wkład", + "type": "Wkład", + "message": "Naprawdę chcesz uwolnić swój wkład \"{name}\"?" + }, + "comment": { + "title": "Zwolnienie komentarz", + "type": "komentarz", + "message": "Czy naprawdę chcesz opublikować komentarz od \"{name}\"?" + } + }, + "user": { + "avatar": { + "submitted": "Przesłanie udane" } }, "contribution": { - "edit": "Edytuj wpis", - "delete": "Usuń wpis" - }, - "comment": { - "edit": "Edytuj komentarz", - "delete": "Usuń komentarz" - }, - "followButton": { - "follow": "Obserwuj", - "following": "Obserwowani" - }, - "shoutButton": { - "shouted": "krzyczeć" + "newPost": "Utwórz nowy post", + "filterFollow": "Filtrowanie wkładu użytkowników, za którymi podążam", + "filterALL": "Wyświetl wszystkie wkłady", + "success": "Zachowany!", + "languageSelectLabel": "Język", + "categories": { + "infoSelectedNoOfMaxCategories": "{chosen} z {max} wybrane kategorie" + } } -} \ No newline at end of file +} From c6b261853f9aef26fc1d72b3f87fd62d947c6a9e Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Wed, 3 Jul 2019 19:46:26 -0300 Subject: [PATCH 05/52] Add test for filter posts by category --- backend/src/schema/resolvers/posts.spec.js | 52 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/backend/src/schema/resolvers/posts.spec.js b/backend/src/schema/resolvers/posts.spec.js index 763945527..4c288fc25 100644 --- a/backend/src/schema/resolvers/posts.spec.js +++ b/backend/src/schema/resolvers/posts.spec.js @@ -32,6 +32,26 @@ const postQueryWithCategories = ` } } ` +const createPostWithoutCategoriesVariables = { + title: 'This is a post without categories', + content: 'I should be able to filter it out', + categoryIds: null, +} +const postQueryFilteredByCategory = ` + query($name: String) { + Post(filter: { categories_some: { name: $name } }) { + title + id + categories { + name + } + } + } +` +const postCategoriesFilterParam = 'Environment & Nature' +const postQueryFilteredByCategoryVariables = { + name: postCategoriesFilterParam, +} beforeEach(async () => { await factory.create('User', { email: 'test@example.org', @@ -124,7 +144,8 @@ describe('CreatePost', () => { }) describe('categories', () => { - it('allows a user to set the categories of the post', async () => { + let postWithCategories + beforeEach(async () => { await Promise.all([ factory.create('Category', { id: 'cat9', @@ -142,11 +163,14 @@ describe('CreatePost', () => { icon: 'shopping-cart', }), ]) - const expected = [{ id: 'cat9' }, { id: 'cat4' }, { id: 'cat15' }] - const postWithCategories = await client.request( + postWithCategories = await client.request( createPostWithCategoriesMutation, creatPostWithCategoriesVariables, ) + }) + + it('allows a user to set the categories of the post', async () => { + const expected = [{ id: 'cat9' }, { id: 'cat4' }, { id: 'cat15' }] const postQueryWithCategoriesVariables = { id: postWithCategories.CreatePost.id, } @@ -154,6 +178,28 @@ describe('CreatePost', () => { client.request(postQueryWithCategories, postQueryWithCategoriesVariables), ).resolves.toEqual({ Post: [{ categories: expect.arrayContaining(expected) }] }) }) + + it('allows a user to filter for posts by category', async () => { + await client.request(createPostWithCategoriesMutation, createPostWithoutCategoriesVariables) + const categoryNames = [ + { name: 'Democracy & Politics' }, + { name: 'Environment & Nature' }, + { name: 'Consumption & Sustainability' }, + ] + const expected = { + Post: [ + { + title: postTitle, + id: postWithCategories.CreatePost.id, + categories: expect.arrayContaining(categoryNames), + }, + ], + } + + await expect( + client.request(postQueryFilteredByCategory, postQueryFilteredByCategoryVariables), + ).resolves.toEqual(expected) + }) }) }) }) From bb93052b88da55c9c551cacd2934a91b38319e28 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Wed, 3 Jul 2019 19:46:49 -0300 Subject: [PATCH 06/52] Add FilterPosts dropdown with category names --- webapp/components/FilterPosts/FilterPosts.vue | 86 +++++++++++++++++++ webapp/layouts/default.vue | 21 ++++- webapp/store/categories.js | 42 +++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 webapp/components/FilterPosts/FilterPosts.vue create mode 100644 webapp/store/categories.js diff --git a/webapp/components/FilterPosts/FilterPosts.vue b/webapp/components/FilterPosts/FilterPosts.vue new file mode 100644 index 000000000..7fff1d477 --- /dev/null +++ b/webapp/components/FilterPosts/FilterPosts.vue @@ -0,0 +1,86 @@ + + diff --git a/webapp/layouts/default.vue b/webapp/layouts/default.vue index e3fc1cccd..1c1ace9de 100644 --- a/webapp/layouts/default.vue +++ b/webapp/layouts/default.vue @@ -4,12 +4,12 @@
- + - + + + + + +