From 512bf32b0c16bd3ddc69f45925ec46209c5e20af Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Tue, 20 Aug 2019 21:27:00 +0200 Subject: [PATCH] Update cypress tests, fix broken comment reactivity --- backend/src/activitypub/ActivityPub.js | 12 ++++++++---- backend/src/activitypub/security/index.js | 2 +- backend/src/schema/resolvers/posts.js | 12 ++++++------ cypress/integration/common/steps.js | 16 ++-------------- .../integration/notifications/Mentions.feature | 18 ++++++++++-------- webapp/components/CommentForm/CommentForm.vue | 2 +- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/backend/src/activitypub/ActivityPub.js b/backend/src/activitypub/ActivityPub.js index cd16f620e..4da59bc26 100644 --- a/backend/src/activitypub/ActivityPub.js +++ b/backend/src/activitypub/ActivityPub.js @@ -102,11 +102,13 @@ export default class ActivityPub { handleUndoActivity(activity) { debug('inside UNDO') switch (activity.object.type) { - case 'Follow': + case 'Follow': { const followActivity = activity.object return this.dataSource.undoFollowActivity(followActivity.actor, followActivity.object) - case 'Like': + } + case 'Like': { return this.dataSource.deleteShouted(activity) + } default: } } @@ -115,13 +117,14 @@ export default class ActivityPub { debug('inside create') switch (activity.object.type) { case 'Article': - case 'Note': + case 'Note': { const articleObject = activity.object if (articleObject.inReplyTo) { return this.dataSource.createComment(activity) } else { return this.dataSource.createPost(activity) } + } default: } } @@ -159,13 +162,14 @@ export default class ActivityPub { async handleAcceptActivity(activity) { debug('inside accept') switch (activity.object.type) { - case 'Follow': + case 'Follow': { const followObject = activity.object const followingCollectionPage = await this.collections.getFollowingCollectionPage( followObject.actor, ) followingCollectionPage.orderedItems.push(followObject.object) await this.dataSource.saveFollowingCollectionPage(followingCollectionPage) + } } } diff --git a/backend/src/activitypub/security/index.js b/backend/src/activitypub/security/index.js index 05642ed26..9e0a63d22 100644 --- a/backend/src/activitypub/security/index.js +++ b/backend/src/activitypub/security/index.js @@ -51,7 +51,7 @@ export function createSignature(options) { // verifying export function verifySignature(url, headers) { return new Promise((resolve, reject) => { - const signatureHeader = headers['signature'] ? headers['signature'] : headers['Signature'] + const signatureHeader = headers.signature ? headers.signature : headers.Signature if (!signatureHeader) { debug('No Signature header present!') resolve(false) diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index b5ffc7755..5bb0c4f81 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -84,12 +84,12 @@ export default { await session.run(cypherDeletePreviousRelations, { params }) const updatePostCypher = `MATCH (post:Post {id: $params.id}) - SET post = $params - WITH post - UNWIND $categoryIds AS categoryId - MATCH (category:Category {id: categoryId}) - MERGE (post)-[:CATEGORIZED]->(category) - RETURN post` + SET post = $params + WITH post + UNWIND $categoryIds AS categoryId + MATCH (category:Category {id: categoryId}) + MERGE (post)-[:CATEGORIZED]->(category) + RETURN post` const updatePostVariables = { categoryIds, params } diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 61ae5d589..190184bd8 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -21,8 +21,7 @@ Given("I am logged in", () => { cy.login(loginCredentials); }); Given("we have a selection of categories", () => { - cy.factory() - .authenticateAs(loginCredentials) + cy.neode() .create("Category", { id: "cat1", name: "Just For Fun", @@ -374,7 +373,7 @@ When("mention {string} in the text", mention => { }); Then("the notification gets marked as read", () => { - cy.get(".notification") + cy.get(".post.createdAt") .first() .should("have.class", "read"); }); @@ -486,14 +485,3 @@ Then("I see only one post with the title {string}", title => { .should("have.length", 1); cy.get(".main-container").contains(".post-link", title); }); - -And("some categories exist", () => { - cy.factory() - .authenticateAs(loginCredentials) - .create("Category", { - id: "cat1", - name: "Just For Fun", - slug: `just-for-fun`, - icon: "smile" - }); -}); diff --git a/cypress/integration/notifications/Mentions.feature b/cypress/integration/notifications/Mentions.feature index 28f7cf456..d3bcb574d 100644 --- a/cypress/integration/notifications/Mentions.feature +++ b/cypress/integration/notifications/Mentions.feature @@ -4,25 +4,27 @@ Feature: Notifications for a mentions In order join conversations about or related to me Background: + Given we have a selection of categories Given we have the following user accounts: - | name | slug | email | password | - | Wolle aus Hamburg | wolle-aus-hamburg | wolle@example.org | 1234 | - | Matt Rider | matt-rider | matt@example.org | 4321 | + | name | slug | email | password | + | Wolle aus Hamburg | wolle-aus-hamburg | wolle@example.org | 1234 | + | Matt Rider | matt-rider | matt@example.org | 4321 | Scenario: Mention another user, re-login as this user and see notifications Given I log in with the following credentials: | email | password | | wolle@example.org | 1234 | And I start to write a new post with the title "Hey Matt" beginning with: - """ - Big shout to our fellow contributor - """ + """ + Big shout to our fellow contributor + """ And mention "@matt-rider" in the text + And I select a category And I click on "Save" When I log out And I log in with the following credentials: - | email | password | - | matt@example.org | 4321 | + | email | password | + | matt@example.org | 4321 | And see 1 unread notifications in the top menu And open the notification menu and click on the first item Then I get to the post page of ".../hey-matt" diff --git a/webapp/components/CommentForm/CommentForm.vue b/webapp/components/CommentForm/CommentForm.vue index 823b47fa6..14b28b91b 100644 --- a/webapp/components/CommentForm/CommentForm.vue +++ b/webapp/components/CommentForm/CommentForm.vue @@ -83,7 +83,7 @@ export default { update: (store, { data: { CreateComment } }) => { const data = store.readQuery({ query: PostQuery(this.$i18n), - variables: { slug: this.post.slug }, + variables: { id: this.post.id }, }) data.Post[0].comments.push(CreateComment) store.writeQuery({ query: PostQuery(this.$i18n), data })