diff --git a/.travis.yml b/.travis.yml index 42b427a11..4ca819f67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,9 @@ install: - wait-on http://localhost:7474 script: + - export CYPRESS_RETRIES=1 + - export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi) + - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH" # Backend - docker-compose exec backend yarn run lint - docker-compose exec backend yarn run test:jest --ci --verbose=false --coverage @@ -34,7 +37,9 @@ script: - docker-compose exec webapp yarn run test --ci --verbose=false --coverage - docker-compose exec -d backend yarn run test:before:seeder # Fullstack - - CYPRESS_RETRIES=1 yarn run cypress:run + # Disable recording cypress tests if we just update dependencies. This is to + # avoid running out of quota. + - if [[ $BRANCH == *"dependabot"* ]]; then yarn run cypress:run; else yarn run cypress:run --record; fi # Coverage - codecov diff --git a/backend/Dockerfile b/backend/Dockerfile index d24f2747e..f0251bddc 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -24,4 +24,5 @@ RUN yarn run build FROM base as production ENV NODE_ENV=production COPY --from=builder /nitro-backend/dist ./dist +COPY ./public/img/ ./public/img/ RUN yarn install --frozen-lockfile --non-interactive diff --git a/backend/package.json b/backend/package.json index 40ea9476d..f6cb0de6b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -61,7 +61,7 @@ "graphql-custom-directives": "~0.2.14", "graphql-iso-date": "~3.6.1", "graphql-middleware": "~3.0.2", - "graphql-shield": "~5.3.6", + "graphql-shield": "~5.3.8", "graphql-tag": "~2.10.1", "graphql-yoga": "~1.17.4", "helmet": "~3.18.0", @@ -105,7 +105,7 @@ "graphql-request": "~1.8.2", "jest": "~24.8.0", "nodemon": "~1.19.1", - "prettier": "~1.17.1", + "prettier": "~1.18.2", "supertest": "~4.0.2" } } diff --git a/backend/src/activitypub/NitroDataSource.js b/backend/src/activitypub/NitroDataSource.js index eea37337a..0900bed6c 100644 --- a/backend/src/activitypub/NitroDataSource.js +++ b/backend/src/activitypub/NitroDataSource.js @@ -505,9 +505,7 @@ export default class NitroDataSource { const result2 = await this.client.mutate({ mutation: gql` mutation { - AddCommentAuthor(from: {id: "${ - result.data.CreateComment.id - }"}, to: {id: "${toUserId}"}) { + AddCommentAuthor(from: {id: "${result.data.CreateComment.id}"}, to: {id: "${toUserId}"}) { id } } @@ -519,9 +517,7 @@ export default class NitroDataSource { result = await this.client.mutate({ mutation: gql` mutation { - AddCommentPost(from: { id: "${ - result.data.CreateComment.id - }", to: { id: "${postId}" }}) { + AddCommentPost(from: { id: "${result.data.CreateComment.id}", to: { id: "${postId}" }}) { id } } diff --git a/backend/src/middleware/fixImageUrlsMiddleware.js b/backend/src/middleware/fixImageUrlsMiddleware.js index c930915bf..3bfa8537a 100644 --- a/backend/src/middleware/fixImageUrlsMiddleware.js +++ b/backend/src/middleware/fixImageUrlsMiddleware.js @@ -6,8 +6,11 @@ const legacyUrls = [ export const fixUrl = url => { legacyUrls.forEach(legacyUrl => { - url = url.replace(legacyUrl, '/api') + url = url.replace(legacyUrl, '') }) + if (!url.startsWith('/')) { + url = `/${url}` + } return url } diff --git a/backend/src/middleware/fixImageUrlsMiddleware.spec.js b/backend/src/middleware/fixImageUrlsMiddleware.spec.js index b2d808dd9..0da66811a 100644 --- a/backend/src/middleware/fixImageUrlsMiddleware.spec.js +++ b/backend/src/middleware/fixImageUrlsMiddleware.spec.js @@ -1,12 +1,19 @@ import { fixImageURLs } from './fixImageUrlsMiddleware' describe('fixImageURLs', () => { + describe('edge case: image url is exact match of legacy url', () => { + it('replaces it with `/`', () => { + const url = 'https://api-alpha.human-connection.org' + expect(fixImageURLs(url)).toEqual('/') + }) + }) + describe('image url of legacy alpha', () => { it('removes domain', () => { const url = 'https://api-alpha.human-connection.org/uploads/4bfaf9172c4ba03d7645108bbbd16f0a696a37d01eacd025fb131e5da61b15d9.png' expect(fixImageURLs(url)).toEqual( - '/api/uploads/4bfaf9172c4ba03d7645108bbbd16f0a696a37d01eacd025fb131e5da61b15d9.png', + '/uploads/4bfaf9172c4ba03d7645108bbbd16f0a696a37d01eacd025fb131e5da61b15d9.png', ) }) }) @@ -16,7 +23,7 @@ describe('fixImageURLs', () => { const url = 'https://staging-api.human-connection.org/uploads/1b3c39a24f27e2fb62b69074b2f71363b63b263f0c4574047d279967124c026e.jpeg' expect(fixImageURLs(url)).toEqual( - '/api/uploads/1b3c39a24f27e2fb62b69074b2f71363b63b263f0c4574047d279967124c026e.jpeg', + '/uploads/1b3c39a24f27e2fb62b69074b2f71363b63b263f0c4574047d279967124c026e.jpeg', ) }) }) diff --git a/backend/src/middleware/notifications/spec.js b/backend/src/middleware/notifications/spec.js index 65212e544..985654b0f 100644 --- a/backend/src/middleware/notifications/spec.js +++ b/backend/src/middleware/notifications/spec.js @@ -87,9 +87,7 @@ describe('currentUser { notifications }', () => { describe('who mentions me again', () => { beforeEach(async () => { - const updatedContent = `${ - post.content - } One more mention to @al-capone` + const updatedContent = `${post.content} One more mention to @al-capone` // The response `post.content` contains a link but the XSSmiddleware // should have the `mention` CSS class removed. I discovered this // during development and thought: A feature not a bug! This way we diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 1287aa45f..6836f16fe 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -56,14 +56,14 @@ type User { contributionsCount: Int! @cypher( statement: """ MATCH (this)-[:WROTE]->(r:Post) - WHERE (NOT exists(r.deleted) OR r.deleted = false) - AND (NOT exists(r.disabled) OR r.disabled = false) + WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r) """ ) comments: [Comment]! @relation(name: "WROTE", direction: "OUT") commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") + commentedCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment)-[:COMMENTS]->(p:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true AND NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))") shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)") @@ -77,4 +77,4 @@ type User { badges: [Badge]! @relation(name: "REWARDED", direction: "IN") badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)") -} \ No newline at end of file +} diff --git a/backend/yarn.lock b/backend/yarn.lock index 61803eb1f..e92070fe9 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1119,10 +1119,10 @@ resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.9.tgz#693e76a52f61a2f1e7fb48c0eef167b95ea4ffd0" integrity sha512-sCZy4SxP9rN2w30Hlmg5dtdRwgYQfYRiLo9usw8X9cxlf+H4FqM1xX7+sNH7NNKVdbXMJWqva7iyy+fxh/V7fA== -"@types/yup@0.26.14": - version "0.26.14" - resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.14.tgz#d31f3b9a04039cca70ebb4db4d6c7fc3f694e80b" - integrity sha512-OcBtVLHvYULVSltpuBdhFiVOKoSsOS58D872HydO93oBf3OdGq5zb+LnqGo18TNNSV2aW8hjIdS6H+wp68zFtQ== +"@types/yup@0.26.16": + version "0.26.16" + resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.16.tgz#75c428236207c48d9f8062dd1495cda8c5485a15" + integrity sha512-E2RNc7DSeQ+2EIJ1H3+yFjYu6YiyQBUJ7yNpIxomrYJ3oFizLZ5yDS3T1JTUNBC2OCRkgnhLS0smob5UuCHfNA== "@types/zen-observable@^0.5.3": version "0.5.4" @@ -3772,12 +3772,12 @@ graphql-request@~1.8.2: dependencies: cross-fetch "2.2.2" -graphql-shield@~5.3.6: - version "5.3.6" - resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-5.3.6.tgz#20061b02f77056c0870a623c530ef28a1bf4fff4" - integrity sha512-ihw/i4X+d1kpj1SVA6iBkVl2DZhPsI+xV08geR2TX3FWhpU7zakk/16yBzDRJTTCUgKsWfgyebrgIBsuhTwMnA== +graphql-shield@~5.3.8: + version "5.3.8" + resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-5.3.8.tgz#f9e7ad2285f6cfbe20a8a49154ce6c1b184e3893" + integrity sha512-33rQ8U5jMurHIapctHk7hBcUg3nxC7fmMIMtyWiomJXhBmztFq/SG7jNaapnL5M7Q/0BmoaSQd3FLSpelP9KPw== dependencies: - "@types/yup" "0.26.14" + "@types/yup" "0.26.16" lightercollective "^0.3.0" object-hash "^1.3.1" yup "^0.27.0" @@ -6230,10 +6230,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@~1.17.1: - version "1.17.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.1.tgz#ed64b4e93e370cb8a25b9ef7fef3e4fd1c0995db" - integrity sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg== +prettier@~1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== pretty-format@^24.8.0: version "24.8.0" diff --git a/webapp/components/LoadMore.vue b/webapp/components/LoadMore.vue index 3d583ef50..ff8d4e6c4 100644 --- a/webapp/components/LoadMore.vue +++ b/webapp/components/LoadMore.vue @@ -1,5 +1,5 @@