Resolve pinnedAt undefinedToNull, clean up

- this was causing the noftications to break since they were using the
post fragment and pinnedAt was returning null
- remove unused bits of code
- revert changes to cypress since they were not causing the error
- can be changed in another PR
This commit is contained in:
mattwr18 2019-10-18 00:01:46 +02:00
parent 8b27250393
commit b800c7d5c9
5 changed files with 24 additions and 28 deletions

View File

@ -97,7 +97,7 @@ export default {
WITH post WITH post
MATCH (author:User {id: $userId}) MATCH (author:User {id: $userId})
MERGE (post)<-[:WROTE]-(author) MERGE (post)<-[:WROTE]-(author)
WITH post, author WITH post
UNWIND $categoryIds AS categoryId UNWIND $categoryIds AS categoryId
MATCH (category:Category {id: categoryId}) MATCH (category:Category {id: categoryId})
MERGE (post)-[:CATEGORIZED]->(category) MERGE (post)-[:CATEGORIZED]->(category)
@ -108,9 +108,7 @@ export default {
const session = context.driver.session() const session = context.driver.session()
try { try {
const transactionRes = await session.run(createPostCypher, createPostVariables) const transactionRes = await session.run(createPostCypher, createPostVariables)
const posts = transactionRes.records.map(record => { const posts = transactionRes.records.map(record => record.get('post').properties)
return record.get('post').properties
})
post = posts[0] post = posts[0]
} catch (e) { } catch (e) {
if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed') if (e.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
@ -124,9 +122,6 @@ export default {
}, },
UpdatePost: async (_parent, params, context, _resolveInfo) => { UpdatePost: async (_parent, params, context, _resolveInfo) => {
const { categoryIds } = params const { categoryIds } = params
const { id: userId } = context.user
delete params.pinned
delete params.unpinned
delete params.categoryIds delete params.categoryIds
params = await fileUpload(params, { file: 'imageUpload', url: 'image' }) params = await fileUpload(params, { file: 'imageUpload', url: 'image' })
const session = context.driver.session() const session = context.driver.session()
@ -154,7 +149,7 @@ export default {
} }
updatePostCypher += `RETURN post` updatePostCypher += `RETURN post`
const updatePostVariables = { categoryIds, params, userId } const updatePostVariables = { categoryIds, params }
const transactionRes = await session.run(updatePostCypher, updatePostVariables) const transactionRes = await session.run(updatePostCypher, updatePostVariables)
const [post] = transactionRes.records.map(record => { const [post] = transactionRes.records.map(record => {
@ -287,7 +282,7 @@ export default {
}, },
Post: { Post: {
...Resolver('Post', { ...Resolver('Post', {
undefinedToNull: ['activityId', 'objectId', 'image', 'language'], undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt'],
hasMany: { hasMany: {
tags: '-[:TAGGED]->(related:Tag)', tags: '-[:TAGGED]->(related:Tag)',
categories: '-[:CATEGORIZED]->(related:Category)', categories: '-[:CATEGORIZED]->(related:Category)',

View File

@ -67,12 +67,14 @@ When('I click on the author', () => {
}) })
When('I report the author', () => { When('I report the author', () => {
cy.get('.page-name-profile-id-slug') cy.get('.page-name-profile-id-slug').then(() => {
invokeReportOnElement('.ds-card') invokeReportOnElement('.ds-card').then(() => {
cy.get('button') cy.get('button')
.contains('Send') .contains('Send')
.click() .click()
}) })
})
})
When('I click on send in the confirmation dialog', () => { When('I click on send in the confirmation dialog', () => {
cy.get('button') cy.get('button')
@ -85,11 +87,12 @@ Then('I get a success message', () => {
}) })
Then('I see my reported user', () => { Then('I see my reported user', () => {
cy.get('table') cy.get('table').then(() => {
cy.get('tbody tr') cy.get('tbody tr')
.first() .first()
.contains(lastReportTitle.trim()) .contains(lastReportTitle.trim())
}) })
})
Then(`I can't see the moderation menu item`, () => { Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover') cy.get('.avatar-menu-popover')

View File

@ -36,8 +36,15 @@ const authenticatedHeaders = async (variables) => {
} }
Cypress.Commands.add("switchLanguage", (name, force) => { Cypress.Commands.add("switchLanguage", (name, force) => {
const { code } = helpers.getLangByName(name);
if (force) { if (force) {
switchLang(name); switchLang(name);
} else {
cy.get("html").then($html => {
if ($html && $html.attr("lang") !== code) {
switchLang(name);
}
});
} }
}); });

View File

@ -93,7 +93,7 @@ export default {
return data.notifications return data.notifications
}, },
error(error) { error(error) {
this.$toast.error(error) this.$toast.error(error.message)
}, },
}, },
}, },

View File

@ -79,7 +79,6 @@
</template> </template>
<script> <script>
import { mapMutations } from 'vuex'
import ContentViewer from '~/components/Editor/ContentViewer' import ContentViewer from '~/components/Editor/ContentViewer'
import HcCategory from '~/components/Category' import HcCategory from '~/components/Category'
import HcHashtag from '~/components/Hashtag/Hashtag' import HcHashtag from '~/components/Hashtag/Hashtag'
@ -145,9 +144,6 @@ export default {
}, },
}, },
methods: { methods: {
...mapMutations({
setCurrentUser: 'auth/SET_USER',
}),
isAuthor(id) { isAuthor(id) {
return this.$store.getters['auth/user'].id === id return this.$store.getters['auth/user'].id === id
}, },
@ -163,11 +159,6 @@ export default {
async createComment(comment) { async createComment(comment) {
this.post.comments.push(comment) this.post.comments.push(comment)
}, },
resetPostList() {
this.offset = 0
this.posts = []
this.hasMore = true
},
pinPost(post) { pinPost(post) {
this.$apollo this.$apollo
.mutate({ .mutate({