mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #6227 from Ocelot-Social-Community/seed-posts-as-articles
feat(backend): seed posts as article
This commit is contained in:
commit
6207920cc1
@ -165,7 +165,7 @@ Factory.define('post')
|
||||
})
|
||||
.after(async (buildObject, options) => {
|
||||
const [post, author, image, /* categories, */ tags] = await Promise.all([
|
||||
neode.create('Post', buildObject),
|
||||
neode.create('Article', buildObject),
|
||||
options.author,
|
||||
options.image,
|
||||
// options.categories,
|
||||
|
||||
@ -23,6 +23,7 @@ export function getNeode(options = {}) {
|
||||
if (!neodeInstance) {
|
||||
const { uri, username, password } = { ...defaultOptions, ...options }
|
||||
neodeInstance = new Neode(uri, username, password).with(models)
|
||||
neodeInstance.extend('Post', 'Article', {})
|
||||
return neodeInstance
|
||||
}
|
||||
return neodeInstance
|
||||
|
||||
@ -92,7 +92,7 @@ export default {
|
||||
[(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed,
|
||||
[(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed,
|
||||
[(resource)<-[:WROTE]-(author:User) | author {.*} ] as optionalAuthors,
|
||||
[(resource)-[:COMMENTS]->(post:Post) | post {.*} ] as optionalCommentedPosts,
|
||||
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author), postType: filter(l IN labels(post) WHERE NOT l = "Post")} ] as optionalCommentedPosts,
|
||||
resource {.*, __typename: labels(resource)[0] } as resourceWithType
|
||||
WITH report, optionalAuthors, optionalCommentedPosts, reviewed, filed,
|
||||
resourceWithType {.*, post: optionalCommentedPosts[0], author: optionalAuthors[0] } as finalResource
|
||||
@ -106,7 +106,7 @@ export default {
|
||||
})
|
||||
try {
|
||||
const reports = await reportsReadTxPromise
|
||||
return reports
|
||||
return reports || []
|
||||
} finally {
|
||||
session.close()
|
||||
}
|
||||
|
||||
@ -48,9 +48,10 @@ Cypress.Commands.add(
|
||||
Cypress.Commands.add(
|
||||
'mutate',
|
||||
{ prevSubject: true },
|
||||
(graphQLClient, mutation, variables) => {
|
||||
return new Cypress.Promise((resolve, reject) => {
|
||||
(graphQLClient, mutation, variables, response) => {
|
||||
return new Cypress.Promise(async (resolve, reject) => {
|
||||
graphQLClient.request(mutation, variables).then(() => resolve(graphQLClient))
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { When } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import 'cypress-network-idle';
|
||||
|
||||
When("I click on the avatar menu in the top right corner", () => {
|
||||
cy.get(".avatar-menu").click();
|
||||
cy.waitForNetworkIdle(2000);
|
||||
});
|
||||
|
||||
@ -1,6 +1,108 @@
|
||||
import { Then } from "@badeball/cypress-cucumber-preprocessor";
|
||||
|
||||
Then('I see all the reported posts including the one from above', () => {
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: '/api',
|
||||
hostname: 'localhost',
|
||||
}).as('getReports')
|
||||
|
||||
cy.wait(['@getReports'],{ timeout: 30000 }).then((interception) => {
|
||||
console.log('Cypress interception:', interception)
|
||||
cy.wrap(interception.response.statusCode).should('eq', 200)
|
||||
cy.wrap(interception.request.body)
|
||||
.should('have.property', 'query', `query ($orderBy: ReportOrdering, $first: Int, $offset: Int, $reviewed: Boolean, $closed: Boolean) {
|
||||
reports(orderBy: $orderBy, first: $first, offset: $offset, reviewed: $reviewed, closed: $closed) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
closed
|
||||
reviewed {
|
||||
createdAt
|
||||
updatedAt
|
||||
disable
|
||||
moderator {
|
||||
id
|
||||
slug
|
||||
name
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
resource {
|
||||
__typename
|
||||
... on User {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
... on Comment {
|
||||
id
|
||||
contentExcerpt
|
||||
disabled
|
||||
deleted
|
||||
author {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
post {
|
||||
id
|
||||
slug
|
||||
title
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
... on Post {
|
||||
id
|
||||
slug
|
||||
title
|
||||
disabled
|
||||
deleted
|
||||
author {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
filed {
|
||||
submitter {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
createdAt
|
||||
reasonCategory
|
||||
reasonDescription
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
`
|
||||
)
|
||||
cy.wrap(interception.response.body)
|
||||
.should('have.nested.property', 'data.reports.0.resource.author.id')
|
||||
.and('equal', 'annoying-user')
|
||||
})
|
||||
|
||||
cy.get('table tbody').within(() => {
|
||||
cy.contains('tr', 'The Truth about the Holocaust')
|
||||
})
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
import { Given } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import 'cypress-network-idle';
|
||||
|
||||
Given('somebody reported the following posts:', table => {
|
||||
const reportIdRegex = /^[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}$/
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: '/',
|
||||
hostname: 'localhost',
|
||||
}).as('postToLocalhost')
|
||||
|
||||
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
|
||||
const submitter = {
|
||||
email: submitterEmail,
|
||||
@ -18,5 +26,15 @@ Given('somebody reported the following posts:', table => {
|
||||
reasonCategory,
|
||||
reasonDescription
|
||||
})
|
||||
cy.wait(['@postToLocalhost']).then((interception) => {
|
||||
cy.wrap(interception.response.statusCode).should('eq', 200)
|
||||
})
|
||||
cy.wait(['@postToLocalhost']).then((interception) => {
|
||||
cy.wrap(interception.response.statusCode).should('eq', 200)
|
||||
cy.wrap(interception.response.body)
|
||||
.should('have.nested.property', 'data.fileReport.reportId')
|
||||
.and('match', reportIdRegex)
|
||||
})
|
||||
cy.waitForNetworkIdle(2000)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import { Given } from "@badeball/cypress-cucumber-preprocessor";
|
||||
import 'cypress-network-idle';
|
||||
|
||||
Given("I navigate to page {string}", page => {
|
||||
cy.visit(page);
|
||||
cy.waitForNetworkIdle(2000)
|
||||
});
|
||||
|
||||
@ -34,7 +34,8 @@
|
||||
"cucumber": "^6.0.5",
|
||||
"cypress": "^12.6.0",
|
||||
"cypress-file-upload": "^3.5.3",
|
||||
"date-fns": "^2.30.0",
|
||||
"cypress-network-idle": "^1.14.2",
|
||||
"date-fns": "^2.25.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"expect": "^29.5.0",
|
||||
"graphql-request": "^2.0.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user