Update cypress tests, fix broken comment reactivity

This commit is contained in:
Matt Rider 2019-08-20 21:27:00 +02:00
parent 8735045d11
commit 512bf32b0c
6 changed files with 28 additions and 34 deletions

View File

@ -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)
}
}
}

View File

@ -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)

View File

@ -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 }

View File

@ -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"
});
});

View File

@ -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"

View File

@ -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 })