Merge branch 'master' into 6376-refactor-cypress-upgrad-all-relevant-packages-to-current-versions

This commit is contained in:
mahula 2023-06-08 09:34:18 +02:00 committed by GitHub
commit 44ef732825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 938 additions and 1244 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,7 +34,8 @@
"cucumber": "^6.0.5",
"cypress": "^12.13.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",

View File

@ -20,9 +20,10 @@ module.exports = {
lines: 83,
},
},
coverageProvider: 'v8',
setupFiles: ['<rootDir>/test/registerContext.js', '<rootDir>/test/testSetup.js'],
transform: {
'.*\\.(vue)$': 'vue-jest',
'.*\\.(vue)$': '@vue/vue2-jest',
'^.+\\.js$': 'babel-jest',
},
testMatch: ['**/?(*.)+(spec|test).js?(x)'],

View File

@ -66,9 +66,9 @@
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@babel/core": "~7.21.4",
"@babel/core": "~7.22.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.20.2",
"@babel/preset-env": "^7.22.4",
"@faker-js/faker": "5.1.0",
"@nuxtjs/composition-api": "0.32.0",
"@storybook/addon-a11y": "^6.3.6",
@ -79,8 +79,9 @@
"@vue/eslint-config-prettier": "~6.0.0",
"@vue/server-test-utils": "~1.0.0-beta.31",
"@vue/test-utils": "1.3.4",
"@vue/vue2-jest": "29",
"async-validator": "^3.2.4",
"babel-core": "~7.0.0-bridge.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "~10.1.0",
"babel-jest": "29.5",
"babel-loader": "~8.1.0",
@ -110,7 +111,6 @@
"storybook-vue-router": "^1.0.7",
"style-loader": "~0.23.1",
"style-resources-loader": "~1.3.3",
"vue-jest": "~3.0.5",
"vue-svg-loader": "~0.16.0",
"vue-template-compiler": "^2.6.11"
},

View File

@ -33,6 +33,9 @@ export default {
user: 'auth/user',
}),
},
data() {
return { contribution: {} }
},
async asyncData(context) {
const {
app,

View File

@ -8,6 +8,9 @@ import SearchResults from '~/components/_new/features/SearchResults/SearchResult
export default {
layout: 'default',
watchQuery: ['search'],
data() {
return { search: null }
},
head() {
return {
title: this.$t('search.title'),

File diff suppressed because it is too large Load Diff

1008
yarn.lock

File diff suppressed because it is too large Load Diff