mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
This technically lets the cypress tests pass
@appinteractive when I run the whole apollo request in `asyncData` I get errors that there is a mismatch of the virtual DOM trees for client and server. Any ideas?
This commit is contained in:
parent
804cb796b8
commit
eaa2017ba4
@ -223,6 +223,11 @@ Then('the first post on the landing page has the title:', title => {
|
||||
cy.get('.post-card:first').should('contain', title)
|
||||
})
|
||||
|
||||
Then('I see a 404 error with the following message:', message => {
|
||||
Then(
|
||||
'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)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
@ -20,8 +20,7 @@ Feature: Hide Posts
|
||||
|
||||
Scenario: Visiting a disabled post's page should return 404
|
||||
Given I am logged in with a "user" role
|
||||
When I visit the "/post/this-post-is-disabled" page
|
||||
Then I see a 404 error with the following message:
|
||||
Then the page "/post/this-post-is-disabled" returns a 404 error with a message:
|
||||
"""
|
||||
We cannot find that post :(
|
||||
"""
|
||||
|
||||
@ -162,6 +162,22 @@ export default {
|
||||
this.title = this.post.title
|
||||
}
|
||||
},
|
||||
async asyncData(context) {
|
||||
const {
|
||||
params,
|
||||
error,
|
||||
app: { apolloProvider }
|
||||
} = context
|
||||
const client = apolloProvider.defaultClient
|
||||
const query = gql('query Post($slug: String!) { Post(slug: $slug) { id } }')
|
||||
const variables = { slug: params.slug }
|
||||
const {
|
||||
data: { Post }
|
||||
} = await client.query({ query, variables })
|
||||
if (Post.length <= 0) {
|
||||
error({ statusCode: 404, message: 'We cannot find that post :(' })
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isAuthor(id) {
|
||||
return this.$store.getters['auth/user'].id === id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user