From aa54433afb8292b1b6cfe9b6aa366ebe9e314870 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 19 Jun 2019 13:35:21 +0200 Subject: [PATCH 01/35] improved accuracy of import to reflect different types of contributions & follows. Cleaned neo4j import folder structure --- .../migration/mongo/export.sh | 16 +++++++++++--- .../migration/neo4j/{ => badges}/badges.cql | 0 .../{badges_delete.cql => badges/delete.cql} | 0 .../neo4j/{ => categories}/categories.cql | 0 .../delete.cql} | 0 .../neo4j/{ => comments}/comments.cql | 0 .../delete.cql} | 0 .../{ => contributions}/contributions.cql | 0 .../delete.cql} | 0 .../neo4j/{_delete_all.cql => delete_all.cql} | 0 .../delete.cql} | 0 .../neo4j/{ => emotions}/emotions.cql | 0 .../delete.cql} | 0 .../migration/neo4j/{ => follows}/follows.cql | 0 .../migration/neo4j/import.sh | 21 +++++++++++-------- .../delete.cql} | 0 .../migration/neo4j/{ => invites}/invites.cql | 0 .../delete.cql} | 0 .../{ => notifications}/notifications.cql | 0 .../delete.cql} | 0 .../{ => organizations}/organizations.cql | 0 .../{pages_delete.cql => pages/delete.cql} | 0 .../migration/neo4j/{ => pages}/pages.cql | 0 .../delete.cql} | 0 .../neo4j/{ => projects}/projects.cql | 0 .../delete.cql} | 0 .../neo4j/{ => settings}/settings.cql | 0 .../{shouts_delete.cql => shouts/delete.cql} | 0 .../migration/neo4j/{ => shouts}/shouts.cql | 0 .../{status_delete.cql => status/delete.cql} | 0 .../migration/neo4j/{ => status}/status.cql | 0 .../delete.cql} | 0 .../systemnotifications.cql | 0 .../{users_delete.cql => users/delete.cql} | 0 .../migration/neo4j/{ => users}/users.cql | 0 .../delete.cql} | 0 .../neo4j/{ => userscandos}/userscandos.cql | 0 .../delete.cql} | 0 .../neo4j/{ => usersettings}/usersettings.cql | 0 39 files changed, 25 insertions(+), 12 deletions(-) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => badges}/badges.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{badges_delete.cql => badges/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => categories}/categories.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{categories_delete.cql => categories/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => comments}/comments.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{comments_delete.cql => comments/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => contributions}/contributions.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{contributions_delete.cql => contributions/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{_delete_all.cql => delete_all.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{emotions_delete.cql => emotions/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => emotions}/emotions.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{follows_delete.cql => follows/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => follows}/follows.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{invites_delete.cql => invites/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => invites}/invites.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{notifications_delete.cql => notifications/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => notifications}/notifications.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{organizations_delete.cql => organizations/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => organizations}/organizations.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{pages_delete.cql => pages/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => pages}/pages.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{projects_delete.cql => projects/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => projects}/projects.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{settings_delete.cql => settings/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => settings}/settings.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{shouts_delete.cql => shouts/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => shouts}/shouts.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{status_delete.cql => status/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => status}/status.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{systemnotifications_delete.cql => systemnotifications/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => systemnotifications}/systemnotifications.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{users_delete.cql => users/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => users}/users.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{userscandos_delete.cql => userscandos/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => userscandos}/userscandos.cql (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{usersettings_delete.cql => usersettings/delete.cql} (100%) rename deployment/legacy-migration/maintenance-worker/migration/neo4j/{ => usersettings}/usersettings.cql (100%) diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh index abed9b0f5..8d16f42fa 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh @@ -8,11 +8,18 @@ set +o allexport # Export collection function defintion function export_collection () { - "${EXPORT_MONGOEXPORT_BIN}" --db ${MONGODB_DATABASE} --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --collection $1 --collection $1 --out "${EXPORT_PATH}$1.json" + "${EXPORT_MONGOEXPORT_BIN}" --db ${MONGODB_DATABASE} --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --collection $1 --out "${EXPORT_PATH}$1.json" mkdir -p ${EXPORT_PATH}splits/$1/ split -l ${MONGO_EXPORT_SPLIT_SIZE} -a 3 ${EXPORT_PATH}$1.json ${EXPORT_PATH}splits/$1/ } +# Export collection with query function defintion +function export_collection_query () { + "${EXPORT_MONGOEXPORT_BIN}" --db ${MONGODB_DATABASE} --host localhost -d ${MONGODB_DATABASE} --port 27018 --username ${MONGODB_USERNAME} --password ${MONGODB_PASSWORD} --authenticationDatabase ${MONGODB_AUTH_DB} --collection $1 --out "${EXPORT_PATH}$1_$3.json" --query "$2" + mkdir -p ${EXPORT_PATH}splits/$1_$3/ + split -l ${MONGO_EXPORT_SPLIT_SIZE} -a 3 ${EXPORT_PATH}$1_$3.json ${EXPORT_PATH}splits/$1_$3/ +} + # Delete old export & ensure directory rm -rf ${EXPORT_PATH}* mkdir -p ${EXPORT_PATH} @@ -24,9 +31,12 @@ ssh -4 -M -S my-ctrl-socket -fnNT -L 27018:localhost:27017 -l ${SSH_USERNAME} ${ export_collection "badges" export_collection "categories" export_collection "comments" -export_collection "contributions" +export_collection_query "contributions" "{'type': 'DELETED'}" "DELETED" +export_collection_query "contributions" "{'type': 'post'}" "post" +export_collection_query "contributions" "{'type': 'cando'}" "cando" export_collection "emotions" -export_collection "follows" +export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations" +export_collection_query "follows" "{'foreignService': 'users'}" "users" export_collection "invites" export_collection "notifications" export_collection "organizations" diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/badges.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/badges/badges.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/badges.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/badges/badges.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/badges_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/badges/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/badges_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/badges/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/categories.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/categories/categories.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/categories.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/categories/categories.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/categories_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/categories/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/categories_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/categories/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/comments.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/comments/comments.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/comments.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/comments/comments.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/comments_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/comments/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/comments_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/comments/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/_delete_all.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/delete_all.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/_delete_all.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/delete_all.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/emotions/emotions.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/follows_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/follows.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/follows.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/follows/follows.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index ac256e3f0..23bd2e94c 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -10,7 +10,7 @@ set +o allexport function delete_collection () { # Delete from Database echo "Delete $1" - "${IMPORT_CYPHERSHELL_BIN}" < $(dirname "$0")/$1_delete.cql > /dev/null + "${IMPORT_CYPHERSHELL_BIN}" < $(dirname "$0")/$1/delete.cql > /dev/null # Delete index file rm -f "${IMPORT_PATH}splits/$1.index" } @@ -34,7 +34,7 @@ function import_collection () { # calculate the path of the chunk export IMPORT_CHUNK_PATH_CQL_FILE="${IMPORT_CHUNK_PATH_CQL}$1/${CHUNK_FILE_NAME}" # load the neo4j command and replace file variable with actual path - NEO4J_COMMAND="$(envsubst '${IMPORT_CHUNK_PATH_CQL_FILE}' < $(dirname "$0")/$1.cql)" + NEO4J_COMMAND="$(envsubst '${IMPORT_CHUNK_PATH_CQL_FILE}' < $(dirname "$0")/$2)" # run the import of the chunk echo "Import $1 ${CHUNK_FILE_NAME} (${chunk})" echo "${NEO4J_COMMAND}" | "${IMPORT_CYPHERSHELL_BIN}" > /dev/null @@ -75,13 +75,16 @@ echo "DONE" # Import Data echo "Start Importing Data" -import_collection "badges" -import_collection "categories" -import_collection "users" -import_collection "follows" -import_collection "contributions" -import_collection "shouts" -import_collection "comments" +import_collection "badges" "badges/badges.cql" +import_collection "categories" "categories/categories.cql" +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_DELETED" "contributions/contributions.cql" +import_collection "shouts" "shouts/shouts.cql" +import_collection "comments" "comments/comments.cql" # import_collection "emotions" # import_collection "invites" diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/invites_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/invites/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/invites_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/invites/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/invites.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/invites/invites.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/invites.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/invites/invites.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications/notifications.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/notifications/notifications.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations/organizations.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/organizations/organizations.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/pages_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/pages/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/pages_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/pages/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/pages.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/pages/pages.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/pages.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/pages/pages.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/projects_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/projects/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/projects_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/projects/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/projects.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/projects/projects.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/projects.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/projects/projects.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/settings_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/settings/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/settings_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/settings/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/settings.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/settings/settings.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/settings.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/settings/settings.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts/shouts.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/shouts/shouts.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/status_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/status/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/status_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/status/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/status.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/status/status.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/status.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/status/status.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications/systemnotifications.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/systemnotifications/systemnotifications.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/users_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/users.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos/userscandos.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/userscandos/userscandos.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings_delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings/delete.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings_delete.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings/delete.cql diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings/usersettings.cql similarity index 100% rename from deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings.cql rename to deployment/legacy-migration/maintenance-worker/migration/neo4j/usersettings/usersettings.cql From 9cbb736d70ee6bc2789982cf99e931b76c736045 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 19 Jun 2019 13:54:20 +0200 Subject: [PATCH 02/35] cleanup import todo --- .../maintenance-worker/migration/neo4j/import.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index 23bd2e94c..3b87601d2 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -91,13 +91,17 @@ import_collection "comments" "comments/comments.cql" # import_collection "notifications" # import_collection "organizations" # import_collection "pages" -# import_collection "projects" -# import_collection "settings" -# import_collection "status" # import_collection "systemnotifications" # import_collection "userscandos" # import_collection "usersettings" +# does only contain dummy data +# import_collection "projects" + +# does only contain alpha specifc data +# import_collection "status +# import_collection "settings"" + echo "DONE" echo "Time elapsed: $SECONDS seconds" From f551e9a6377c181f622ef808e8676f01b4876ba1 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Sat, 22 Jun 2019 12:01:00 -0300 Subject: [PATCH 03/35] Fix failing build due to lorempixel.com being down --- backend/package.json | 2 +- backend/src/seed/factories/posts.js | 2 +- backend/src/seed/seed-db.js | 12 +- backend/yarn.lock | 5 +- cypress/integration/common/steps.js | 514 +++++++++++---------- cypress/integration/post/WritePost.feature | 8 +- webapp/components/Avatar/Avatar.spec.js | 4 +- 7 files changed, 280 insertions(+), 267 deletions(-) diff --git a/backend/package.json b/backend/package.json index 85a51fa14..e2ddfaa48 100644 --- a/backend/package.json +++ b/backend/package.json @@ -56,7 +56,7 @@ "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", - "faker": "~4.1.0", + "faker": "github:Marak/faker.js#master", "graphql": "~14.3.1", "graphql-custom-directives": "~0.2.14", "graphql-iso-date": "~3.6.1", diff --git a/backend/src/seed/factories/posts.js b/backend/src/seed/factories/posts.js index ea92f7d9f..4b098a62e 100644 --- a/backend/src/seed/factories/posts.js +++ b/backend/src/seed/factories/posts.js @@ -13,7 +13,7 @@ export default function(params) { faker.lorem.sentence(), faker.lorem.sentence(), ].join('. '), - image = faker.image.image(), + image = faker.image.unsplash.image(), visibility = 'public', deleted = false, } = params diff --git a/backend/src/seed/seed-db.js b/backend/src/seed/seed-db.js index 27af1106a..27c07868d 100644 --- a/backend/src/seed/seed-db.js +++ b/backend/src/seed/seed-db.js @@ -214,21 +214,21 @@ import Factory from './factories' 'Hey @jenny-rostock, here is another notification for you!' await Promise.all([ - asAdmin.create('Post', { id: 'p0' }), - asModerator.create('Post', { id: 'p1' }), + asAdmin.create('Post', { id: 'p0', image: faker.image.unsplash.food() }), + asModerator.create('Post', { id: 'p1', image: faker.image.unsplash.technology() }), asUser.create('Post', { id: 'p2' }), asTick.create('Post', { id: 'p3' }), asTrick.create('Post', { id: 'p4' }), asTrack.create('Post', { id: 'p5' }), - asAdmin.create('Post', { id: 'p6' }), + asAdmin.create('Post', { id: 'p6', image: faker.image.unsplash.buildings() }), asModerator.create('Post', { id: 'p7', content: `${mention1} ${faker.lorem.paragraph()}` }), - asUser.create('Post', { id: 'p8' }), + asUser.create('Post', { id: 'p8', image: faker.image.unsplash.nature() }), asTick.create('Post', { id: 'p9' }), asTrick.create('Post', { id: 'p10' }), - asTrack.create('Post', { id: 'p11' }), + asTrack.create('Post', { id: 'p11', image: faker.image.unsplash.people() }), asAdmin.create('Post', { id: 'p12', content: `${mention2} ${faker.lorem.paragraph()}` }), asModerator.create('Post', { id: 'p13' }), - asUser.create('Post', { id: 'p14' }), + asUser.create('Post', { id: 'p14', image: faker.image.unsplash.objects() }), asTick.create('Post', { id: 'p15' }), ]) diff --git a/backend/yarn.lock b/backend/yarn.lock index dee5b8d20..ab3025c03 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3373,10 +3373,9 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -faker@~4.1.0: +"faker@github:Marak/faker.js#master": version "4.1.0" - resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" - integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8= + resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" fast-deep-equal@^2.0.1: version "2.0.1" diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 8f5bcc8ea..73313d331 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -1,347 +1,361 @@ -import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' -import { getLangByName } from '../../support/helpers' +import { Given, When, Then } from "cypress-cucumber-preprocessor/steps"; +import { getLangByName } from "../../support/helpers"; /* global cy */ -let lastPost = {} +let lastPost = {}; let loginCredentials = { - email: 'peterpan@example.org', - password: '1234' -} + email: "peterpan@example.org", + password: "1234" +}; const narratorParams = { - name: 'Peter Pan', - avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg', + name: "Peter Pan", + avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg", ...loginCredentials -} +}; -Given('I am logged in', () => { - cy.login(loginCredentials) -}) +Given("I am logged in", () => { + cy.login(loginCredentials); +}); -Given('we have a selection of tags and categories as well as posts', () => { +Given("we have a selection of tags and categories as well as posts", () => { cy.factory() .authenticateAs(loginCredentials) - .create('Category', { - id: 'cat1', - name: 'Just For Fun', - slug: 'justforfun', - icon: 'smile' + .create("Category", { + id: "cat1", + name: "Just For Fun", + slug: "justforfun", + icon: "smile" }) - .create('Category', { - id: 'cat2', - name: 'Happyness & Values', - slug: 'happyness-values', - icon: 'heart-o' + .create("Category", { + id: "cat2", + name: "Happyness & Values", + slug: "happyness-values", + icon: "heart-o" }) - .create('Category', { - id: 'cat3', - name: 'Health & Wellbeing', - slug: 'health-wellbeing', - icon: 'medkit' + .create("Category", { + id: "cat3", + name: "Health & Wellbeing", + slug: "health-wellbeing", + icon: "medkit" }) - .create('Tag', { id: 't1', name: 'Ecology' }) - .create('Tag', { id: 't2', name: 'Nature' }) - .create('Tag', { id: 't3', name: 'Democracy' }) + .create("Tag", { id: "t1", name: "Ecology" }) + .create("Tag", { id: "t2", name: "Nature" }) + .create("Tag", { id: "t3", name: "Democracy" }); const someAuthor = { - id: 'authorId', - email: 'author@example.org', - password: '1234' - } + id: "authorId", + email: "author@example.org", + password: "1234" + }; const yetAnotherAuthor = { - id: 'yetAnotherAuthor', - email: 'yet-another-author@example.org', - password: '1234' - } + id: "yetAnotherAuthor", + email: "yet-another-author@example.org", + password: "1234" + }; cy.factory() - .create('User', someAuthor) + .create("User", someAuthor) .authenticateAs(someAuthor) - .create('Post', { id: 'p0' }) - .create('Post', { id: 'p1' }) + .create("Post", { id: "p0" }) + .create("Post", { id: "p1" }); cy.factory() - .create('User', yetAnotherAuthor) + .create("User", yetAnotherAuthor) .authenticateAs(yetAnotherAuthor) - .create('Post', { id: 'p2' }) + .create("Post", { id: "p2" }); cy.factory() .authenticateAs(loginCredentials) - .create('Post', { id: 'p3' }) - .relate('Post', 'Categories', { from: 'p0', to: 'cat1' }) - .relate('Post', 'Categories', { from: 'p1', to: 'cat2' }) - .relate('Post', 'Categories', { from: 'p2', to: 'cat1' }) - .relate('Post', 'Tags', { from: 'p0', to: 't1' }) - .relate('Post', 'Tags', { from: 'p0', to: 't2' }) - .relate('Post', 'Tags', { from: 'p0', to: 't3' }) - .relate('Post', 'Tags', { from: 'p1', to: 't2' }) - .relate('Post', 'Tags', { from: 'p1', to: 't3' }) - .relate('Post', 'Tags', { from: 'p2', to: 't2' }) - .relate('Post', 'Tags', { from: 'p2', to: 't3' }) - .relate('Post', 'Tags', { from: 'p3', to: 't3' }) -}) + .create("Post", { id: "p3" }) + .relate("Post", "Categories", { from: "p0", to: "cat1" }) + .relate("Post", "Categories", { from: "p1", to: "cat2" }) + .relate("Post", "Categories", { from: "p2", to: "cat1" }) + .relate("Post", "Tags", { from: "p0", to: "t1" }) + .relate("Post", "Tags", { from: "p0", to: "t2" }) + .relate("Post", "Tags", { from: "p0", to: "t3" }) + .relate("Post", "Tags", { from: "p1", to: "t2" }) + .relate("Post", "Tags", { from: "p1", to: "t3" }) + .relate("Post", "Tags", { from: "p2", to: "t2" }) + .relate("Post", "Tags", { from: "p2", to: "t3" }) + .relate("Post", "Tags", { from: "p3", to: "t3" }); +}); -Given('we have the following user accounts:', table => { +Given("we have the following user accounts:", table => { table.hashes().forEach(params => { - cy.factory().create('User', params) - }) -}) + cy.factory().create("User", params); + }); +}); -Given('I have a user account', () => { - cy.factory().create('User', narratorParams) -}) +Given("I have a user account", () => { + cy.factory().create("User", narratorParams); +}); -Given('my user account has the role {string}', role => { - cy.factory().create('User', { +Given("my user account has the role {string}", role => { + cy.factory().create("User", { role, ...loginCredentials - }) -}) + }); +}); -When('I log out', cy.logout) +When("I log out", cy.logout); -When('I visit {string}', page => { - cy.openPage(page) -}) +When("I visit {string}", page => { + cy.openPage(page); +}); -When('I visit the {string} page', page => { - cy.openPage(page) -}) +When("I visit the {string} page", page => { + cy.openPage(page); +}); -Given('I am on the {string} page', page => { - cy.openPage(page) -}) +Given("I am on the {string} page", page => { + cy.openPage(page); +}); -When('I fill in my email and password combination and click submit', () => { - cy.login(loginCredentials) -}) +When("I fill in my email and password combination and click submit", () => { + cy.login(loginCredentials); +}); When(/(?:when )?I refresh the page/, () => { - cy.reload() -}) + cy.reload(); +}); -When('I log out through the menu in the top right corner', () => { - cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover') +When("I log out through the menu in the top right corner", () => { + cy.get(".avatar-menu").click(); + cy.get(".avatar-menu-popover") .find('a[href="/logout"]') - .click() -}) + .click(); +}); -Then('I can see my name {string} in the dropdown menu', () => { - cy.get('.avatar-menu-popover').should('contain', narratorParams.name) -}) +Then("I can see my name {string} in the dropdown menu", () => { + cy.get(".avatar-menu-popover").should("contain", narratorParams.name); +}); -Then('I see the login screen again', () => { - cy.location('pathname').should('contain', '/login') -}) +Then("I see the login screen again", () => { + cy.location("pathname").should("contain", "/login"); +}); -Then('I can click on my profile picture in the top right corner', () => { - cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover') -}) +Then("I can click on my profile picture in the top right corner", () => { + cy.get(".avatar-menu").click(); + cy.get(".avatar-menu-popover"); +}); -Then('I am still logged in', () => { - cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover').contains(narratorParams.name) -}) +Then("I am still logged in", () => { + cy.get(".avatar-menu").click(); + cy.get(".avatar-menu-popover").contains(narratorParams.name); +}); -When('I select {string} in the language menu', name => { - cy.switchLanguage(name, true) -}) -Given('I previously switched the language to {string}', name => { - cy.switchLanguage(name, true) -}) -Then('the whole user interface appears in {string}', name => { - const lang = getLangByName(name) - cy.get(`html[lang=${lang.code}]`) - cy.getCookie('locale').should('have.property', 'value', lang.code) -}) -Then('I see a button with the label {string}', label => { - cy.contains('button', label) -}) +When("I select {string} in the language menu", name => { + cy.switchLanguage(name, true); +}); +Given("I previously switched the language to {string}", name => { + cy.switchLanguage(name, true); +}); +Then("the whole user interface appears in {string}", name => { + const lang = getLangByName(name); + cy.get(`html[lang=${lang.code}]`); + cy.getCookie("locale").should("have.property", "value", lang.code); +}); +Then("I see a button with the label {string}", label => { + cy.contains("button", label); +}); When(`I click on {string}`, linkOrButton => { - cy.contains(linkOrButton).click() -}) + cy.contains(linkOrButton).click(); +}); When(`I click on the menu item {string}`, linkOrButton => { - cy.contains('.ds-menu-item', linkOrButton).click() -}) + cy.contains(".ds-menu-item", linkOrButton).click(); +}); -When('I press {string}', label => { - cy.contains(label).click() -}) +When("I press {string}", label => { + cy.contains(label).click(); +}); -Given('we have the following posts in our database:', table => { +Given("we have the following posts in our database:", table => { table.hashes().forEach(({ Author, ...postAttributes }) => { const userAttributes = { name: Author, email: `${Author}@example.org`, - password: '1234' - } - postAttributes.deleted = Boolean(postAttributes.deleted) - const disabled = Boolean(postAttributes.disabled) + password: "1234" + }; + postAttributes.deleted = Boolean(postAttributes.deleted); + const disabled = Boolean(postAttributes.disabled); cy.factory() - .create('User', userAttributes) + .create("User", userAttributes) .authenticateAs(userAttributes) - .create('Post', postAttributes) + .create("Post", postAttributes); if (disabled) { const moderatorParams = { - email: 'moderator@example.org', - role: 'moderator', - password: '1234' - } + email: "moderator@example.org", + role: "moderator", + password: "1234" + }; cy.factory() - .create('User', moderatorParams) + .create("User", moderatorParams) .authenticateAs(moderatorParams) - .mutate('mutation($id: ID!) { disable(id: $id) }', postAttributes) + .mutate("mutation($id: ID!) { disable(id: $id) }", postAttributes); } - }) -}) + }); +}); -Then('I see a success message:', message => { - cy.contains(message) -}) +Then("I see a success message:", message => { + cy.contains(message); +}); -When('I click on the avatar menu in the top right corner', () => { - cy.get('.avatar-menu').click() -}) +When("I click on the avatar menu in the top right corner", () => { + cy.get(".avatar-menu").click(); +}); When( - 'I click on the big plus icon in the bottom right corner to create post', + "I click on the big plus icon in the bottom right corner to create post", () => { - cy.get('.post-add-button').click() + cy.get(".post-add-button").click(); } -) +); -Given('I previously created a post', () => { +Given("I previously created a post", () => { + lastPost.title = "previously created post"; + lastPost.content = "with some content"; cy.factory() .authenticateAs(loginCredentials) - .create('Post', lastPost) -}) + .create("Post", lastPost); +}); -When('I choose {string} as the title of the post', title => { - lastPost.title = title.replace('\n', ' ') - cy.get('input[name="title"]').type(lastPost.title) -}) +When("I choose {string} as the title of the post", title => { + lastPost.title = title.replace("\n", " "); + cy.get('input[name="title"]').type(lastPost.title); +}); -When('I type in the following text:', text => { - lastPost.content = text.replace('\n', ' ') - cy.get('.ProseMirror').type(lastPost.content) -}) +When("I type in the following text:", text => { + lastPost.content = text.replace("\n", " "); + cy.get(".ProseMirror").type(lastPost.content); +}); -Then('the post shows up on the landing page at position {int}', index => { - cy.openPage('landing') - const selector = `.post-card:nth-child(${index}) > .ds-card-content` - cy.get(selector).should('contain', lastPost.title) - cy.get(selector).should('contain', lastPost.content) -}) +Then("the post shows up on the landing page at position {int}", index => { + cy.openPage("landing"); + const selector = `.post-card:nth-child(${index}) > .ds-card-content`; + cy.get(selector).should("contain", lastPost.title); + cy.get(selector).should("contain", lastPost.content); +}); -Then('I get redirected to {string}', route => { - cy.location('pathname').should('contain', route.replace('...', '')) -}) +Then("I get redirected to {string}", route => { + cy.location("pathname").should("contain", route.replace("...", "")); +}); -Then('the post was saved successfully', () => { - cy.get('.ds-card-content > .ds-heading').should('contain', lastPost.title) - cy.get('.content').should('contain', lastPost.content) -}) +Then("the post was saved successfully", () => { + cy.get(".ds-card-content > .ds-heading").should("contain", lastPost.title); + cy.get(".content").should("contain", lastPost.content); +}); Then(/^I should see only ([0-9]+) posts? on the landing page/, postCount => { - cy.get('.post-card').should('have.length', postCount) -}) + cy.get(".post-card").should("have.length", postCount); +}); -Then('the first post on the landing page has the title:', title => { - cy.get('.post-card:first').should('contain', title) -}) +Then("the first post on the landing page has the title:", title => { + cy.get(".post-card:first").should("contain", title); +}); Then( - 'the page {string} returns a 404 error with a message:', + "the page {string} returns a 404 error with a message:", (route, message) => { // TODO: how can we check HTTP codes with cypress? - cy.visit(route, { failOnStatusCode: false }) - cy.get('.error').should('contain', message) + cy.visit(route, { failOnStatusCode: false }); + cy.get(".error").should("contain", message); } -) +); -Given('my user account has the following login credentials:', table => { - loginCredentials = table.hashes()[0] - cy.debug() - cy.factory().create('User', loginCredentials) -}) +Given("my user account has the following login credentials:", table => { + loginCredentials = table.hashes()[0]; + cy.debug(); + cy.factory().create("User", loginCredentials); +}); -When('I fill the password form with:', table => { - table = table.rowsHash() - cy.get('input[id=oldPassword]') - .type(table['Your old password']) - .get('input[id=newPassword]') - .type(table['Your new passsword']) - .get('input[id=confirmPassword]') - .type(table['Confirm new password']) -}) +When("I fill the password form with:", table => { + table = table.rowsHash(); + cy.get("input[id=oldPassword]") + .type(table["Your old password"]) + .get("input[id=newPassword]") + .type(table["Your new passsword"]) + .get("input[id=confirmPassword]") + .type(table["Confirm new password"]); +}); -When('submit the form', () => { - cy.get('form').submit() -}) +When("submit the form", () => { + cy.get("form").submit(); +}); -Then('I cannot login anymore with password {string}', password => { - cy.reload() - const { email } = loginCredentials - cy.visit(`/login`) - cy.get('input[name=email]') - .trigger('focus') - .type(email) - cy.get('input[name=password]') - .trigger('focus') - .type(password) - cy.get('button[name=submit]') - .as('submitButton') - .click() - cy.get('.iziToast-wrapper').should('contain', 'Incorrect email address or password.') -}) +Then("I cannot login anymore with password {string}", password => { + cy.reload(); + const { email } = loginCredentials; + cy.visit(`/login`); + cy.get("input[name=email]") + .trigger("focus") + .type(email); + cy.get("input[name=password]") + .trigger("focus") + .type(password); + cy.get("button[name=submit]") + .as("submitButton") + .click(); + cy.get(".iziToast-wrapper").should( + "contain", + "Incorrect email address or password." + ); +}); -Then('I can login successfully with password {string}', password => { - cy.reload() +Then("I can login successfully with password {string}", password => { + cy.reload(); cy.login({ ...loginCredentials, - ...{password} - }) - cy.get('.iziToast-wrapper').should('contain', "You are logged in!") -}) + ...{ password } + }); + cy.get(".iziToast-wrapper").should("contain", "You are logged in!"); +}); -When('I log in with the following credentials:', table => { - const { email, password } = table.hashes()[0] - cy.login({ email, password }) -}) +When("I log in with the following credentials:", table => { + const { email, password } = table.hashes()[0]; + cy.login({ email, password }); +}); -When('open the notification menu and click on the first item', () => { - cy.get('.notifications-menu').click() - cy.get('.notification-mention-post').first().click() -}) +When("open the notification menu and click on the first item", () => { + cy.get(".notifications-menu").click(); + cy.get(".notification-mention-post") + .first() + .click(); +}); -Then('see {int} unread notifications in the top menu', count => { - cy.get('.notifications-menu').should('contain', count) -}) +Then("see {int} unread notifications in the top menu", count => { + cy.get(".notifications-menu").should("contain", count); +}); -Then('I get to the post page of {string}', path => { - path = path.replace('...', '') - cy.url().should('contain', '/post/') - cy.url().should('contain', path) -}) +Then("I get to the post page of {string}", path => { + path = path.replace("...", ""); + cy.url().should("contain", "/post/"); + cy.url().should("contain", path); +}); -When('I start to write a new post with the title {string} beginning with:', (title, intro) => { - cy.get('.post-add-button').click() - cy.get('input[name="title"]').type(title) - cy.get('.ProseMirror').type(intro) -}) +When( + "I start to write a new post with the title {string} beginning with:", + (title, intro) => { + cy.get(".post-add-button").click(); + cy.get('input[name="title"]').type(title); + cy.get(".ProseMirror").type(intro); + } +); -When('mention {string} in the text', (mention) => { - cy.get('.ProseMirror').type(' @') - cy.get('.suggestion-list__item').contains(mention).click() - cy.debug() -}) +When("mention {string} in the text", mention => { + cy.get(".ProseMirror").type(" @"); + cy.get(".suggestion-list__item") + .contains(mention) + .click(); + cy.debug(); +}); -Then('the notification gets marked as read', () => { - cy.get('.notification').first().should('have.class', 'read') -}) +Then("the notification gets marked as read", () => { + cy.get(".notification") + .first() + .should("have.class", "read"); +}); -Then('there are no notifications in the top menu', () => { - cy.get('.notifications-menu').should('contain', '0') -}) +Then("there are no notifications in the top menu", () => { + cy.get(".notifications-menu").should("contain", "0"); +}); diff --git a/cypress/integration/post/WritePost.feature b/cypress/integration/post/WritePost.feature index fed1bbf2f..06ac4a175 100644 --- a/cypress/integration/post/WritePost.feature +++ b/cypress/integration/post/WritePost.feature @@ -12,10 +12,10 @@ Feature: Create a post When I click on the big plus icon in the bottom right corner to create post And I choose "My first post" as the title of the post And I type in the following text: - """ - Human Connection is a free and open-source social network - for active citizenship. - """ + """ + Human Connection is a free and open-source social network + for active citizenship. + """ And I click on "Save" Then I get redirected to ".../my-first-post" And the post was saved successfully diff --git a/webapp/components/Avatar/Avatar.spec.js b/webapp/components/Avatar/Avatar.spec.js index d3ebcb030..626e584c9 100644 --- a/webapp/components/Avatar/Avatar.spec.js +++ b/webapp/components/Avatar/Avatar.spec.js @@ -53,7 +53,7 @@ describe('Avatar.vue', () => { beforeEach(() => { propsData = { user: { - avatar: 'http://lorempixel.com/640/480/animals', + avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/sawalazar/128.jpg', }, } }) @@ -64,7 +64,7 @@ describe('Avatar.vue', () => { Wrapper() .find('img') .attributes('src'), - ).toBe('http://lorempixel.com/640/480/animals') + ).toBe('https://s3.amazonaws.com/uifaces/faces/twitter/sawalazar/128.jpg') }) }) }) From f029439024e1dbb8a60d4ae835036ead9f04ec14 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Sat, 22 Jun 2019 12:31:44 -0300 Subject: [PATCH 04/35] Force install all dependencies in the backend --- backend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index f0251bddc..a6bcd48c2 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -15,7 +15,7 @@ COPY .env.template .env CMD ["yarn", "run", "start"] FROM base as builder -RUN yarn install --frozen-lockfile --non-interactive +RUN yarn install --frozen-lockfile --non-interactive --force COPY . . RUN cp .env.template .env RUN yarn run build From 6bd153b7cc149f44bc7376e13ceba72fe9b8e2f2 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Sat, 22 Jun 2019 13:57:20 -0300 Subject: [PATCH 05/35] Remove --force as it didn't make a difference --- backend/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index a6bcd48c2..f0251bddc 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -15,7 +15,7 @@ COPY .env.template .env CMD ["yarn", "run", "start"] FROM base as builder -RUN yarn install --frozen-lockfile --non-interactive --force +RUN yarn install --frozen-lockfile --non-interactive COPY . . RUN cp .env.template .env RUN yarn run build From c14a4f31346c945eb061be1c4023353c562eaf10 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 24 Jun 2019 12:06:09 +0200 Subject: [PATCH 06/35] fixed deleted flag import --- .../neo4j/contributions/contributions.cql | 6 +++--- .../migration/neo4j/import.sh | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql index 98d8f24e9..a0cb6e8e8 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql @@ -109,8 +109,8 @@ } } }, -[?] deleted: { -[X] type: Boolean, +[?] deleted: { // THis field is not always present in the alpha-data +[?] type: Boolean, [ ] default: false, // Default value is missing in Nitro [-] index: true }, @@ -137,7 +137,7 @@ p.contentExcerpt = post.contentExcerpt, p.visibility = toLower(post.visibility), p.createdAt = post.createdAt.`$date`, p.updatedAt = post.updatedAt.`$date`, -p.deleted = post.deleted, +p.deleted = COALESCE(post.deleted,false), p.disabled = NOT post.isEnabled WITH p, post MATCH (u:User {id: post.userId}) diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index 3b87601d2..8eef68c92 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -9,10 +9,10 @@ set +o allexport # Delete collection function defintion function delete_collection () { # Delete from Database - echo "Delete $1" + echo "Delete $2" "${IMPORT_CYPHERSHELL_BIN}" < $(dirname "$0")/$1/delete.cql > /dev/null # Delete index file - rm -f "${IMPORT_PATH}splits/$1.index" + rm -f "${IMPORT_PATH}splits/$2.index" } # Import collection function defintion @@ -52,13 +52,14 @@ SECONDS=0 # Delete all Neo4J Database content echo "Deleting Database Contents" -delete_collection "badges" -delete_collection "categories" -delete_collection "users" -delete_collection "follows" -delete_collection "contributions" -delete_collection "shouts" -delete_collection "comments" +delete_collection "badges" "badges" +delete_collection "categories" "categories" +delete_collection "users" "users" +delete_collection "follows" "follows_users" +delete_collection "contributions" "contributions_post" +delete_collection "contributions" "contributions_cando" +delete_collection "shouts" "shouts" +delete_collection "comments" "comments" #delete_collection "emotions" #delete_collection "invites" From a2d99c98317822af87d08641993c7ce7500ca948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 24 Jun 2019 12:53:22 +0200 Subject: [PATCH 07/35] Write kubernetes deployment for dummy mailserver --- .../https/templates/ingress.template.yaml | 8 +++++ .../mailserver/deployment-mailserver.yaml | 34 +++++++++++++++++++ .../mailserver/service-mailserver.yaml | 17 ++++++++++ .../templates/configmap.template.yaml | 4 +++ 4 files changed, 63 insertions(+) create mode 100644 deployment/human-connection/mailserver/deployment-mailserver.yaml create mode 100644 deployment/human-connection/mailserver/service-mailserver.yaml diff --git a/deployment/digital-ocean/https/templates/ingress.template.yaml b/deployment/digital-ocean/https/templates/ingress.template.yaml index ba4681bc8..9d0068e08 100644 --- a/deployment/digital-ocean/https/templates/ingress.template.yaml +++ b/deployment/digital-ocean/https/templates/ingress.template.yaml @@ -10,6 +10,7 @@ metadata: spec: tls: - hosts: + # - nitro-mailserver.human-connection.org - nitro-staging.human-connection.org secretName: tls rules: @@ -20,3 +21,10 @@ spec: backend: serviceName: nitro-web servicePort: 3000 + # - host: nitro-mailserver.human-connection.org + # http: + # paths: + # - path: / + # backend: + # serviceName: mailserver + # servicePort: 80 diff --git a/deployment/human-connection/mailserver/deployment-mailserver.yaml b/deployment/human-connection/mailserver/deployment-mailserver.yaml new file mode 100644 index 000000000..d97a66bc9 --- /dev/null +++ b/deployment/human-connection/mailserver/deployment-mailserver.yaml @@ -0,0 +1,34 @@ +--- + apiVersion: extensions/v1beta1 + kind: Deployment + metadata: + name: mailserver + namespace: human-connection + spec: + replicas: 1 + minReadySeconds: 15 + progressDeadlineSeconds: 60 + selector: + matchLabels: + human-connection.org/selector: deployment-human-connection-mailserver + template: + metadata: + labels: + human-connection.org/selector: deployment-human-connection-mailserver + name: "mailserver" + spec: + containers: + - name: mailserver + image: djfarrelly/maildev + imagePullPolicy: Always + ports: + - containerPort: 80 + - containerPort: 25 + envFrom: + - configMapRef: + name: configmap + - secretRef: + name: human-connection + restartPolicy: Always + terminationGracePeriodSeconds: 30 + status: {} diff --git a/deployment/human-connection/mailserver/service-mailserver.yaml b/deployment/human-connection/mailserver/service-mailserver.yaml new file mode 100644 index 000000000..655488b89 --- /dev/null +++ b/deployment/human-connection/mailserver/service-mailserver.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: mailserver + namespace: human-connection + labels: + human-connection.org/selector: deployment-human-connection-mailserver +spec: + ports: + - name: web + port: 80 + targetPort: 80 + - name: smtp + port: 25 + targetPort: 25 + selector: + human-connection.org/selector: deployment-human-connection-mailserver diff --git a/deployment/human-connection/templates/configmap.template.yaml b/deployment/human-connection/templates/configmap.template.yaml index 87b51a7d3..b2d2bc1d6 100644 --- a/deployment/human-connection/templates/configmap.template.yaml +++ b/deployment/human-connection/templates/configmap.template.yaml @@ -2,6 +2,10 @@ apiVersion: v1 kind: ConfigMap data: + SMTP_HOST: "http://mailserver.human-connection" + SMTP_PORT: "25" + SMTP_USERNAME: "" + SMTP_PASSWORD: "" GRAPHQL_PORT: "4000" GRAPHQL_URI: "http://nitro-backend.human-connection:4000" MOCKS: "false" From dd1d77f2bbd5426b87bcbb32cc661421b99b0f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 24 Jun 2019 12:56:57 +0200 Subject: [PATCH 08/35] Add env to configmap --- deployment/human-connection/templates/configmap.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/human-connection/templates/configmap.template.yaml b/deployment/human-connection/templates/configmap.template.yaml index b2d2bc1d6..10bc09213 100644 --- a/deployment/human-connection/templates/configmap.template.yaml +++ b/deployment/human-connection/templates/configmap.template.yaml @@ -7,7 +7,7 @@ SMTP_USERNAME: "" SMTP_PASSWORD: "" GRAPHQL_PORT: "4000" - GRAPHQL_URI: "http://nitro-backend.human-connection:4000" + GRAPHQL_URI: "http://backend.human-connection:4000" MOCKS: "false" NEO4J_URI: "bolt://nitro-neo4j.human-connection:7687" NEO4J_USER: "neo4j" From ce0e3cb520f57c5d73a58b3752e0ec4073506ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 24 Jun 2019 13:15:05 +0200 Subject: [PATCH 09/35] Write documentation for mailserver deployment --- SUMMARY.md | 1 + .../human-connection/mailserver/README.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 deployment/human-connection/mailserver/README.md diff --git a/SUMMARY.md b/SUMMARY.md index 701eac2d0..c281e2fae 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -27,6 +27,7 @@ * [Kubernetes Dashboard](deployment/digital-ocean/dashboard/README.md) * [HTTPS](deployment/digital-ocean/https/README.md) * [Human Connection](deployment/human-connection/README.md) + * [Mailserver](deployment/human-connection/mailserver/README.md) * [Volumes](deployment/volumes/README.md) * [Neo4J Offline-Backups](deployment/volumes/neo4j-offline-backup/README.md) * [Volume Snapshots](deployment/volumes/volume-snapshots/README.md) diff --git a/deployment/human-connection/mailserver/README.md b/deployment/human-connection/mailserver/README.md new file mode 100644 index 000000000..9a224a3b9 --- /dev/null +++ b/deployment/human-connection/mailserver/README.md @@ -0,0 +1,18 @@ +# Development Mail Server + +You can deploy a fake smtp server which captures all send mails and displays +them in a web interface. The [sample configuration](../templates/configmap.template.yml) +is assuming such a dummy server in the `SMTP_HOST` configuration and points to +a cluster-internal SMTP server. + +To deploy the SMTP server just uncomment the relevant code in the +[ingress server configuration](../../https/templates/ingress.template.yaml) and +run the following: + +```bash +# in folder deployment/human-connection +kubectl apply -f mailserver/ +``` + +You might need to refresh the TLS secret to enable HTTPS on the publicly +available web interface. From 6ce96d906bb0fe421d01bf7fb4821161d4f5032a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 24 Jun 2019 13:31:13 +0200 Subject: [PATCH 10/35] Fix configmap template --- deployment/human-connection/templates/configmap.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/human-connection/templates/configmap.template.yaml b/deployment/human-connection/templates/configmap.template.yaml index 10bc09213..b2d2bc1d6 100644 --- a/deployment/human-connection/templates/configmap.template.yaml +++ b/deployment/human-connection/templates/configmap.template.yaml @@ -7,7 +7,7 @@ SMTP_USERNAME: "" SMTP_PASSWORD: "" GRAPHQL_PORT: "4000" - GRAPHQL_URI: "http://backend.human-connection:4000" + GRAPHQL_URI: "http://nitro-backend.human-connection:4000" MOCKS: "false" NEO4J_URI: "bolt://nitro-neo4j.human-connection:7687" NEO4J_USER: "neo4j" From a85aa3c244e18ddb6d1b4d2bdafdbd59adfdefd7 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 09:22:07 -0300 Subject: [PATCH 11/35] Update package.json faker import --- backend/package.json | 2 +- backend/yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index e2ddfaa48..b5af10a3d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -56,7 +56,7 @@ "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", - "faker": "github:Marak/faker.js#master", + "faker": "git+https://github.com/Marak/faker.js.git#master", "graphql": "~14.3.1", "graphql-custom-directives": "~0.2.14", "graphql-iso-date": "~3.6.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index ab3025c03..ed122de9e 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3373,9 +3373,9 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -"faker@github:Marak/faker.js#master": +"faker@git+https://github.com/Marak/faker.js.git#master": version "4.1.0" - resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" + resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" fast-deep-equal@^2.0.1: version "2.0.1" From debbf2299bb5bee492ded27019f3092e54577c66 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 09:40:02 -0300 Subject: [PATCH 12/35] Use yarn add to add the faker master branch --- backend/package.json | 2 +- backend/yarn.lock | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index b5af10a3d..3d07b58f1 100644 --- a/backend/package.json +++ b/backend/package.json @@ -56,7 +56,7 @@ "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", - "faker": "git+https://github.com/Marak/faker.js.git#master", + "faker": "Marak/faker.js#master", "graphql": "~14.3.1", "graphql-custom-directives": "~0.2.14", "graphql-iso-date": "~3.6.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index ed122de9e..1a63381d6 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3373,6 +3373,11 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= +faker@Marak/faker.js#master: + version "4.1.0" + uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" + resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" + "faker@git+https://github.com/Marak/faker.js.git#master": version "4.1.0" resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" From 91e7e2adafd2ea575d844435b4b49f59d61599ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 24 Jun 2019 14:49:45 +0200 Subject: [PATCH 13/35] The protocol is not supposed to go into SMTP_HOST --- deployment/human-connection/templates/configmap.template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/human-connection/templates/configmap.template.yaml b/deployment/human-connection/templates/configmap.template.yaml index b2d2bc1d6..762901ae8 100644 --- a/deployment/human-connection/templates/configmap.template.yaml +++ b/deployment/human-connection/templates/configmap.template.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ConfigMap data: - SMTP_HOST: "http://mailserver.human-connection" + SMTP_HOST: "mailserver.human-connection" SMTP_PORT: "25" SMTP_USERNAME: "" SMTP_PASSWORD: "" From b84bd6fbb3a13626b00ed9d85e67e10f4615c969 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 11:44:03 -0300 Subject: [PATCH 14/35] Try with imageUrl --- backend/src/seed/factories/posts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/seed/factories/posts.js b/backend/src/seed/factories/posts.js index 4b098a62e..b8e30ee2e 100644 --- a/backend/src/seed/factories/posts.js +++ b/backend/src/seed/factories/posts.js @@ -13,7 +13,7 @@ export default function(params) { faker.lorem.sentence(), faker.lorem.sentence(), ].join('. '), - image = faker.image.unsplash.image(), + image = faker.image.unsplash.imageUrl(), visibility = 'public', deleted = false, } = params From 0336e860d075650d1a1e784d0172428907519073 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 12:01:21 -0300 Subject: [PATCH 15/35] Fix failing build - adding updated faker to root level package.json --- package.json | 4 ++-- yarn.lock | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fed6c742b..38c5c9a39 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,9 @@ "cypress-file-upload": "^3.1.4", "cypress-plugin-retries": "^1.2.2", "dotenv": "^8.0.0", - "faker": "^4.1.0", + "faker": "Marak/faker.js#master", "graphql-request": "^1.8.2", "neo4j-driver": "^1.7.5", "npm-run-all": "^4.1.5" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 8f9a3f1b3..a0c7c3288 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2303,10 +2303,9 @@ extsprintf@^1.2.0: resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= -faker@^4.1.0: +faker@Marak/faker.js#master: version "4.1.0" - resolved "https://registry.yarnpkg.com/faker/-/faker-4.1.0.tgz#1e45bbbecc6774b3c195fad2835109c6d748cc3f" - integrity sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8= + resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" fast-deep-equal@^2.0.1: version "2.0.1" From 90fe507791b4b1bc4e6bf023e2f1c670f7f8ed3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sat, 22 Jun 2019 09:05:20 +0200 Subject: [PATCH 16/35] Page size of 12 entries on / page It annoys me that there are gaps for the 3 column layout, even if there are more records left. So, the newsfeed layout has 1 column on mobile, 2 columns on tablet, and 3 columns on a desktop pc. So we should choose a page size which is dividable by 1,2 and 3 that is 6. I have chosen 12 which is 2*6 to avoid clicking the reload posts button so often. --- webapp/pages/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index a18c80b9f..40cbebcca 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -45,7 +45,7 @@ export default { // Initialize your apollo data Post: [], page: 1, - pageSize: 10, + pageSize: 12, filter: {}, } }, From 0ebfdd27c58c309e46e5fc44ab642bb1d460c86d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 19:28:15 +0000 Subject: [PATCH 17/35] Bump eslint-plugin-jest from 22.7.0 to 22.7.1 in /backend Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 22.7.0 to 22.7.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v22.7.0...v22.7.1) Signed-off-by: dependabot-preview[bot] --- backend/package.json | 2 +- backend/yarn.lock | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/package.json b/backend/package.json index 3d07b58f1..159a2a588 100644 --- a/backend/package.json +++ b/backend/package.json @@ -98,7 +98,7 @@ "eslint-config-prettier": "~5.0.0", "eslint-config-standard": "~12.0.0", "eslint-plugin-import": "~2.17.3", - "eslint-plugin-jest": "~22.7.0", + "eslint-plugin-jest": "~22.7.1", "eslint-plugin-node": "~9.1.0", "eslint-plugin-prettier": "~3.1.0", "eslint-plugin-promise": "~4.1.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index 1a63381d6..704e8c061 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3053,10 +3053,10 @@ eslint-plugin-import@~2.17.3: read-pkg-up "^2.0.0" resolve "^1.11.0" -eslint-plugin-jest@~22.7.0: - version "22.7.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.7.0.tgz#a1d325bccb024b04f5354c56fe790baba54a454c" - integrity sha512-0U9nBd9V6+GKpM/KvRDcmMuPsewSsdM7NxCozgJkVAh8IrwHmQ0aw44/eYuVkhT8Fcdhsz0zYiyPtKg147eXMQ== +eslint-plugin-jest@~22.7.1: + version "22.7.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.7.1.tgz#5dcdf8f7a285f98040378220d6beca581f0ab2a1" + integrity sha512-CrT3AzA738neimv8G8iK2HCkrCwHnAJeeo7k5TEHK86VMItKl6zdJT/tHBDImfnVVAYsVs4Y6BUdBZQCCgfiyw== eslint-plugin-node@~9.1.0: version "9.1.0" @@ -3378,10 +3378,6 @@ faker@Marak/faker.js#master: uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" -"faker@git+https://github.com/Marak/faker.js.git#master": - version "4.1.0" - resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" From be737e4dc869da8d38511ea9eb123c90f7a7fef1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 19:28:32 +0000 Subject: [PATCH 18/35] Bump eslint-plugin-jest from 22.7.0 to 22.7.1 in /webapp Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 22.7.0 to 22.7.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v22.7.0...v22.7.1) Signed-off-by: dependabot-preview[bot] --- webapp/package.json | 2 +- webapp/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webapp/package.json b/webapp/package.json index 7f78b83ee..0455d0252 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -95,7 +95,7 @@ "eslint-config-standard": "~12.0.0", "eslint-loader": "~2.1.2", "eslint-plugin-import": "~2.17.3", - "eslint-plugin-jest": "~22.7.0", + "eslint-plugin-jest": "~22.7.1", "eslint-plugin-node": "~9.1.0", "eslint-plugin-prettier": "~3.1.0", "eslint-plugin-promise": "~4.1.1", diff --git a/webapp/yarn.lock b/webapp/yarn.lock index ba2cf19bc..c18ccfbc0 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -4300,10 +4300,10 @@ eslint-plugin-import@~2.17.3: read-pkg-up "^2.0.0" resolve "^1.11.0" -eslint-plugin-jest@~22.7.0: - version "22.7.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.7.0.tgz#a1d325bccb024b04f5354c56fe790baba54a454c" - integrity sha512-0U9nBd9V6+GKpM/KvRDcmMuPsewSsdM7NxCozgJkVAh8IrwHmQ0aw44/eYuVkhT8Fcdhsz0zYiyPtKg147eXMQ== +eslint-plugin-jest@~22.7.1: + version "22.7.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.7.1.tgz#5dcdf8f7a285f98040378220d6beca581f0ab2a1" + integrity sha512-CrT3AzA738neimv8G8iK2HCkrCwHnAJeeo7k5TEHK86VMItKl6zdJT/tHBDImfnVVAYsVs4Y6BUdBZQCCgfiyw== eslint-plugin-node@~9.1.0: version "9.1.0" From b30b7d7d786c1616114f55737007da02f7010263 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 19:28:36 +0000 Subject: [PATCH 19/35] Bump date-fns from 2.0.0-alpha.35 to 2.0.0-alpha.36 in /webapp Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.0.0-alpha.35 to 2.0.0-alpha.36. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](https://github.com/date-fns/date-fns/compare/v2.0.0-alpha.35...v2.0.0-alpha.36) Signed-off-by: dependabot-preview[bot] --- webapp/package.json | 2 +- webapp/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webapp/package.json b/webapp/package.json index 7f78b83ee..785178c04 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -60,7 +60,7 @@ "apollo-client": "~2.6.3", "cookie-universal-nuxt": "~2.0.16", "cross-env": "~5.2.0", - "date-fns": "2.0.0-alpha.35", + "date-fns": "2.0.0-alpha.36", "express": "~4.17.1", "graphql": "~14.3.1", "jsonwebtoken": "~8.5.1", diff --git a/webapp/yarn.lock b/webapp/yarn.lock index ba2cf19bc..33266cb99 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -3754,10 +3754,10 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@2.0.0-alpha.35: - version "2.0.0-alpha.35" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.35.tgz#185813cdc51b05cc1468a95116494bb3f3440934" - integrity sha512-dAY1ujqRtyUsa9mVeupyMzUluWo1d7kAMwyXTQHFImKYSHKvxDw/dipiY6fdswQOs8CwpGoiKysGfaaRP5r3bA== +date-fns@2.0.0-alpha.36: + version "2.0.0-alpha.36" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.36.tgz#e3d106fbc6a7247e951916229b948d47848d6102" + integrity sha512-VcO89v0bmgw1V6wVlg9iYiOfyS9/m8T/TDhLBlERkF9NxVEatVr3LcwronDtUGMwGAK6KxUzs2TrOx7TzANMkw== date-now@^0.1.4: version "0.1.4" From 96cda680bbd467158a9c90daf28cb2228df451c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sat, 22 Jun 2019 09:22:40 +0200 Subject: [PATCH 20/35] Use upstream neo4j-graphql-js After the relevant PR of mine has been merged, we should point our `package.json` back to the published npm version of `neo4j-graphql-js`. That way we are receiving updates again. --- backend/package.json | 2 +- backend/yarn.lock | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/package.json b/backend/package.json index 3d07b58f1..a45c941e8 100644 --- a/backend/package.json +++ b/backend/package.json @@ -70,7 +70,7 @@ "lodash": "~4.17.11", "merge-graphql-schemas": "^1.5.8", "neo4j-driver": "~1.7.4", - "neo4j-graphql-js": "git+https://github.com/Human-Connection/neo4j-graphql-js.git#temporary_fixes", + "neo4j-graphql-js": "^2.6.3", "node-fetch": "~2.6.0", "nodemailer": "^6.2.1", "npm-run-all": "~4.1.5", diff --git a/backend/yarn.lock b/backend/yarn.lock index 1a63381d6..5c24bd154 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3375,13 +3375,8 @@ extsprintf@^1.2.0: faker@Marak/faker.js#master: version "4.1.0" - uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" -"faker@git+https://github.com/Marak/faker.js.git#master": - version "4.1.0" - resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" @@ -5618,9 +5613,10 @@ neo4j-driver@^1.7.3, neo4j-driver@~1.7.4: text-encoding "^0.6.4" uri-js "^4.2.1" -"neo4j-graphql-js@git+https://github.com/Human-Connection/neo4j-graphql-js.git#temporary_fixes": - version "2.6.1" - resolved "git+https://github.com/Human-Connection/neo4j-graphql-js.git#84d529b9ecbc5c284cce4f86238c6d19b192cf0f" +neo4j-graphql-js@^2.6.3: + version "2.6.3" + resolved "https://registry.yarnpkg.com/neo4j-graphql-js/-/neo4j-graphql-js-2.6.3.tgz#8f28c2479adda08c90abcc32a784587ef49b8b95" + integrity sha512-WZdEqQ8EL9GOIB1ZccbLk1BZz5Dqdbk9i8BDXqxhp1SOI07P9y2cZ244f2Uz4zyES9AVXGmv+861N5xLhrSL2A== dependencies: graphql "^14.2.1" graphql-auth-directives "^2.1.0" From 37e8eb9a686811465d667eefd68f5e4e60b0eb72 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 19:37:14 +0000 Subject: [PATCH 21/35] Bump date-fns from 2.0.0-alpha.34 to 2.0.0-alpha.36 in /backend Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.0.0-alpha.34 to 2.0.0-alpha.36. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](https://github.com/date-fns/date-fns/compare/v2.0.0-alpha.34...v2.0.0-alpha.36) Signed-off-by: dependabot-preview[bot] --- backend/package.json | 2 +- backend/yarn.lock | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/package.json b/backend/package.json index 3d07b58f1..fad88098c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -52,7 +52,7 @@ "cheerio": "~1.0.0-rc.3", "cors": "~2.8.5", "cross-env": "~5.2.0", - "date-fns": "2.0.0-alpha.35", + "date-fns": "2.0.0-alpha.36", "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index 1a63381d6..30f1c86c0 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -2584,10 +2584,10 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@2.0.0-alpha.35: - version "2.0.0-alpha.35" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.35.tgz#185813cdc51b05cc1468a95116494bb3f3440934" - integrity sha512-dAY1ujqRtyUsa9mVeupyMzUluWo1d7kAMwyXTQHFImKYSHKvxDw/dipiY6fdswQOs8CwpGoiKysGfaaRP5r3bA== +date-fns@2.0.0-alpha.36: + version "2.0.0-alpha.36" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.36.tgz#e3d106fbc6a7247e951916229b948d47848d6102" + integrity sha512-VcO89v0bmgw1V6wVlg9iYiOfyS9/m8T/TDhLBlERkF9NxVEatVr3LcwronDtUGMwGAK6KxUzs2TrOx7TzANMkw== debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" @@ -3378,10 +3378,6 @@ faker@Marak/faker.js#master: uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" -"faker@git+https://github.com/Marak/faker.js.git#master": - version "4.1.0" - resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" From 49fff114b3bd1af981976da4143ff8599d7933f3 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 16:38:33 -0300 Subject: [PATCH 22/35] Write tests for UpdatePost, refactor tests --- .../ContributionForm/ContributionForm.spec.js | 83 ++++++++++++++++--- webapp/components/ContributionForm/index.vue | 2 +- 2 files changed, 73 insertions(+), 12 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index 8b741443f..6856a64b2 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -2,6 +2,7 @@ import { config, mount, createLocalVue } from '@vue/test-utils' import ContributionForm from './index.vue' import Styleguide from '@human-connection/styleguide' import Vuex from 'vuex' +import PostMutations from '~/graphql/PostMutations.js' const localVue = createLocalVue() @@ -17,9 +18,9 @@ describe('ContributionForm.vue', () => { let deutschOption let cancelBtn let mocks + let propsData const postTitle = 'this is a title for a post' const postContent = 'this is a post' - const computed = { locale: () => 'English' } beforeEach(() => { mocks = { @@ -52,6 +53,7 @@ describe('ContributionForm.vue', () => { push: jest.fn(), }, } + propsData = {} }) describe('mount', () => { @@ -64,7 +66,7 @@ describe('ContributionForm.vue', () => { getters, }) const Wrapper = () => { - return mount(ContributionForm, { mocks, localVue, computed, store }) + return mount(ContributionForm, { mocks, localVue, store, propsData }) } beforeEach(() => { @@ -73,29 +75,36 @@ describe('ContributionForm.vue', () => { }) describe('CreatePost', () => { + describe('language placeholder', () => { + it("displays the name that corresponds with the user's location code", () => { + expect(wrapper.find('.ds-select-placeholder').text()).toEqual('English') + }) + }) + describe('invalid form submission', () => { it('title required for form submission', async () => { postTitleInput = wrapper.find('.ds-input') - postTitleInput.setValue('this is a title for a post') + postTitleInput.setValue(postTitle) await wrapper.find('form').trigger('submit') expect(mocks.$apollo.mutate).not.toHaveBeenCalled() }) it('content required for form submission', async () => { - wrapper.vm.updateEditorContent('this is a post') + wrapper.vm.updateEditorContent(postContent) await wrapper.find('form').trigger('submit') expect(mocks.$apollo.mutate).not.toHaveBeenCalled() }) }) describe('valid form submission', () => { - expectedParams = { - variables: { title: postTitle, content: postContent, language: 'en', id: null }, - } beforeEach(async () => { + expectedParams = { + mutation: PostMutations().CreatePost, + variables: { title: postTitle, content: postContent, language: 'en', id: null }, + } postTitleInput = wrapper.find('.ds-input') - postTitleInput.setValue('this is a title for a post') - wrapper.vm.updateEditorContent('this is a post') + postTitleInput.setValue(postTitle) + wrapper.vm.updateEditorContent(postContent) await wrapper.find('form').trigger('submit') }) @@ -136,8 +145,8 @@ describe('ContributionForm.vue', () => { beforeEach(async () => { wrapper = Wrapper() postTitleInput = wrapper.find('.ds-input') - postTitleInput.setValue('this is a title for a post') - wrapper.vm.updateEditorContent('this is a post') + postTitleInput.setValue(postTitle) + wrapper.vm.updateEditorContent(postContent) // second submission causes mutation to reject await wrapper.find('form').trigger('submit') }) @@ -148,5 +157,57 @@ describe('ContributionForm.vue', () => { }) }) }) + + describe('UpdatePost', () => { + beforeEach(() => { + propsData = { + contribution: { + id: 'p1456', + slug: 'dies-ist-ein-post', + title: 'dies ist ein Post', + content: 'auf Deutsch geschrieben', + language: 'de', + }, + } + wrapper = Wrapper() + }) + + it('sets id equal to contribution id', () => { + expect(wrapper.vm.id).toEqual(propsData.contribution.id) + }) + + it('sets slug equal to contribution slug', () => { + expect(wrapper.vm.slug).toEqual(propsData.contribution.slug) + }) + + it('sets title equal to contribution title', () => { + expect(wrapper.vm.form.title).toEqual(propsData.contribution.title) + }) + + it('sets content equal to contribution content', () => { + expect(wrapper.vm.form.content).toEqual(propsData.contribution.content) + }) + + it('sets language equal to contribution language', () => { + expect(wrapper.vm.form.language).toEqual({ value: propsData.contribution.language }) + }) + + it('calls the UpdatePost apollo mutation', async () => { + expectedParams = { + mutation: PostMutations().UpdatePost, + variables: { + title: postTitle, + content: postContent, + language: propsData.contribution.language, + id: propsData.contribution.id, + }, + } + postTitleInput = wrapper.find('.ds-input') + postTitleInput.setValue(postTitle) + wrapper.vm.updateEditorContent(postContent) + await wrapper.find('form').trigger('submit') + expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams)) + }) + }) }) }) diff --git a/webapp/components/ContributionForm/index.vue b/webapp/components/ContributionForm/index.vue index 62c3650c8..c925a6dca 100644 --- a/webapp/components/ContributionForm/index.vue +++ b/webapp/components/ContributionForm/index.vue @@ -88,7 +88,7 @@ export default { this.slug = contribution.slug this.form.content = contribution.content this.form.title = contribution.title - this.form.language = this.locale + this.form.language = { value: contribution.language } }, }, }, From c6203ad8eb33a67a3127e6e5dba0ed8c3ab2e3c1 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Mon, 24 Jun 2019 18:21:52 -0300 Subject: [PATCH 23/35] Refactor CreateComments functionality - update apollo cache on successful mutation - remove global event listener - avoid refetch Post to update CommentsList - return comment with its author from resolver --- backend/src/schema/resolvers/comments.js | 31 +++++++++++++++---- backend/yarn.lock | 5 --- .../components/comments/CommentForm/index.vue | 22 +++++++------ .../components/comments/CommentForm/spec.js | 5 --- .../comments/CommentList/CommentList.spec.js | 5 --- .../components/comments/CommentList/index.vue | 18 ++--------- webapp/graphql/CommentMutations.js | 23 ++++++++++++++ webapp/graphql/PostCommentsQuery.js | 4 +-- 8 files changed, 65 insertions(+), 48 deletions(-) create mode 100644 webapp/graphql/CommentMutations.js diff --git a/backend/src/schema/resolvers/comments.js b/backend/src/schema/resolvers/comments.js index 7f3b11da4..d2e296596 100644 --- a/backend/src/schema/resolvers/comments.js +++ b/backend/src/schema/resolvers/comments.js @@ -38,22 +38,41 @@ export default { if (!post) { throw new UserInputError(NO_POST_ERR_MESSAGE) } - const comment = await neo4jgraphql(object, params, context, resolveInfo, false) + const commentWithoutRelationships = await neo4jgraphql( + object, + params, + context, + resolveInfo, + false, + ) - await session.run( + let transactionRes = await session.run( ` MATCH (post:Post {id: $postId}), (comment:Comment {id: $commentId}), (author:User {id: $userId}) MERGE (post)<-[:COMMENTS]-(comment)<-[:WROTE]-(author) - RETURN post`, + RETURN comment, author`, { userId: context.user.id, postId, - commentId: comment.id, + commentId: commentWithoutRelationships.id, }, ) - session.close() - return comment + const [commentWithAuthor] = transactionRes.records.map(record => { + return { + comment: record.get('comment'), + author: record.get('author'), + } + }) + + const { comment, author } = commentWithAuthor + + const commentReturnedWithAuthor = { + ...comment.properties, + author: author.properties, + } + session.close() + return commentReturnedWithAuthor }, DeleteComment: async (object, params, context, resolveInfo) => { const comment = await neo4jgraphql(object, params, context, resolveInfo, false) diff --git a/backend/yarn.lock b/backend/yarn.lock index 1a63381d6..426ed0d57 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3375,13 +3375,8 @@ extsprintf@^1.2.0: faker@Marak/faker.js#master: version "4.1.0" - uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" -"faker@git+https://github.com/Marak/faker.js.git#master": - version "4.1.0" - resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/comments/CommentForm/index.vue index f105bd5ff..753d09c13 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/comments/CommentForm/index.vue @@ -25,6 +25,8 @@