diff --git a/.github/file-filters.yml b/.github/file-filters.yml new file mode 100644 index 000000000..d7f9cb6c0 --- /dev/null +++ b/.github/file-filters.yml @@ -0,0 +1,9 @@ +backend: &backend + - 'backend/**/*' + - 'neo4j/**/*' + +docker: &docker + - 'docker-compose.*' + +webapp: &webapp + - 'webapp/**/*' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ca5e52945..e386b7efa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -306,4 +306,12 @@ jobs: token: ${{ secrets.OCELOT_PUBLISH_EVENT_PAT }} # this token is required to access the other repository event-type: trigger-ocelot-build-success repository: 'Ocelot-Social-Community/stage.ocelot.social' + client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "GITHUB_RUN_NUMBER": "${{ env.GITHUB_RUN_NUMBER }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' + + - name: Repository Dispatch stage.yunite.me + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.OCELOT_PUBLISH_EVENT_PAT }} # this token is required to access the other repository + event-type: trigger-ocelot-build-success + repository: 'Yunite-Net/stage.yunite.me' client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "GITHUB_RUN_NUMBER": "${{ env.GITHUB_RUN_NUMBER }}", "VERSION": "${VERSION}", "BUILD_DATE": "${BUILD_DATE}", "BUILD_COMMIT": "${BUILD_COMMIT}", "BUILD_VERSION": "${BUILD_VERSION}"}' \ No newline at end of file diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml new file mode 100644 index 000000000..84d87c770 --- /dev/null +++ b/.github/workflows/test-backend.yml @@ -0,0 +1,120 @@ +name: ocelot.social backend test CI + + +on: [push] + +jobs: + files-changed: + name: Detect File Changes - Backend + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.changes.outputs.backend }} + docker: ${{ steps.changes.outputs.docker }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + build_test_neo4j: + name: Docker Build Test - Neo4J + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Neo4J | Build 'community' image + run: | + docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ + docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/neo4j.tar + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: docker-neo4j-image + path: /tmp/neo4j.tar + + build_test_backend: + name: Docker Build Test - Backend + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: backend | Build 'test' image + run: | + docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ + docker save "ocelotsocialnetwork/backend:test" > /tmp/backend.tar + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: docker-backend-test + path: /tmp/backend.tar + + lint_backend: + name: Lint Backend + if: needs.files-changed.outputs.backend == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: backend | Lint + run: cd backend && yarn && yarn run lint + + unit_test_backend: + name: Unit tests - Backend + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.docker == 'true' + needs: [files-changed, build_test_neo4j, build_test_backend] + runs-on: ubuntu-latest + permissions: + checks: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Docker Image (Neo4J) + uses: actions/download-artifact@v3 + with: + name: docker-neo4j-image + path: /tmp + + - name: Load Docker Image + run: docker load < /tmp/neo4j.tar + + - name: Download Docker Image (Backend) + uses: actions/download-artifact@v3 + with: + name: docker-backend-test + path: /tmp + + - name: Load Docker Image + run: docker load < /tmp/backend.tar + + - name: backend | copy env files webapp + run: cp webapp/.env.template webapp/.env + - name: backend | copy env files backend + run: cp backend/.env.template backend/.env + + - name: backend | docker-compose + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend + + - name: backend | Initialize Database + run: docker-compose exec -T backend yarn db:migrate init + + - name: backend | Migrate Database Up + run: docker-compose exec -T backend yarn db:migrate up + + - name: backend | Unit test incl. coverage check + run: docker-compose exec -T backend yarn test diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml new file mode 100644 index 000000000..d76ab129f --- /dev/null +++ b/.github/workflows/test-e2e.yml @@ -0,0 +1,41 @@ +name: ocelot.social end-to-end test CI +on: push + +jobs: + fullstack_tests: + name: Fullstack tests + runs-on: ubuntu-latest + env: + jobs: 8 + strategy: + matrix: + # run copies of the current job in parallel + job: [1, 2, 3, 4, 5, 6, 7, 8] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: webapp | copy env file + run: cp webapp/.env.template webapp/.env + + - name: backend | copy env file + run: cp backend/.env.template backend/.env + + - name: boot up test system | docker-compose + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend + + - name: cypress | Fullstack tests + id: e2e-tests + run: | + yarn install + yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) + + ########################################################################## + # UPLOAD SCREENSHOTS - IF TESTS FAIL ##################################### + ########################################################################## + - name: Full stack tests | if any test failed, upload screenshots + if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} + uses: actions/upload-artifact@v3 + with: + name: cypress-screenshots + path: cypress/screenshots/ diff --git a/.github/workflows/test-webapp.yml b/.github/workflows/test-webapp.yml new file mode 100644 index 000000000..9ca3023cc --- /dev/null +++ b/.github/workflows/test-webapp.yml @@ -0,0 +1,101 @@ +name: ocelot.social webapp test CI + + +on: [push] + +jobs: + files-changed: + name: Detect File Changes - Webapp + runs-on: ubuntu-latest + outputs: + docker: ${{ steps.changes.outputs.docker }} + webapp: ${{ steps.changes.outputs.webapp }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for frontend file changes + uses: dorny/paths-filter@v2.11.1 + id: changes + with: + token: ${{ github.token }} + filters: .github/file-filters.yml + list-files: shell + + prepare: + name: Prepare + if: needs.files-changed.outputs.webapp + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check translation files + run: | + scripts/translations/sort.sh + scripts/translations/missing-keys.sh + + build_test_webapp: + name: Docker Build Test - Webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp + needs: [files-changed, prepare] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: webapp | Build 'test' image + run: | + docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ + docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: docker-webapp-test + path: /tmp/webapp.tar + + lint_webapp: + name: Lint Webapp + if: needs.files-changed.outputs.webapp + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: webapp | Lint + run: cd webapp && yarn && yarn run lint + + unit_test_webapp: + name: Unit Tests - Webapp + if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.webapp + needs: [files-changed, build_test_webapp] + runs-on: ubuntu-latest + permissions: + checks: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Docker Image (Webapp) + uses: actions/download-artifact@v3 + with: + name: docker-webapp-test + path: /tmp + + - name: Load Docker Image + run: docker load < /tmp/webapp.tar + + - name: backend | copy env files webapp + run: cp webapp/.env.template webapp/.env + + - name: backend | copy env files backend + run: cp backend/.env.template backend/.env + + - name: backend | docker-compose + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp + + - name: webapp | Unit tests incl. coverage check + run: docker-compose exec -T webapp yarn test + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1740c09fe..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,344 +0,0 @@ -name: ocelot.social test CI - - -on: [push] - -jobs: - ############################################################################## - # JOB: PREPARE ##################################################### - ############################################################################## - prepare: - name: Prepare - runs-on: ubuntu-latest - # needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # TODO: DO STUFF ??? ##################################################### - ########################################################################## - - name: Check translation files - run: | - scripts/translations/sort.sh - scripts/translations/missing-keys.sh - - ############################################################################## - # JOB: DOCKER BUILD TEST NEO4J ############################################### - ############################################################################## - build_test_neo4j: - name: Docker Build Test - Neo4J - runs-on: ubuntu-latest - needs: [prepare] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # NEO4J ################################################################## - ########################################################################## - - name: Neo4J | Build `community` image - run: | - docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ - docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/neo4j.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-neo4j-image - path: /tmp/neo4j.tar - - ############################################################################## - # JOB: DOCKER BUILD TEST BACKEND ############################################# - ############################################################################## - build_test_backend: - name: Docker Build Test - Backend - runs-on: ubuntu-latest - needs: [prepare] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BUILD BACKEND DOCKER IMAGE (build) ##################################### - ########################################################################## - - name: backend | Build `test` image - run: | - docker build --target test -t "ocelotsocialnetwork/backend:test" backend/ - docker save "ocelotsocialnetwork/backend:test" > /tmp/backend.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-backend-test - path: /tmp/backend.tar - - ############################################################################## - # JOB: DOCKER BUILD TEST WEBAPP ############################################## - ############################################################################## - build_test_webapp: - name: Docker Build Test - WebApp - runs-on: ubuntu-latest - needs: [prepare] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BUILD WEBAPP DOCKER IMAGE (build) ###################################### - ########################################################################## - - name: webapp | Build `test` image - run: | - docker build --target test -t "ocelotsocialnetwork/webapp:test" webapp/ - docker save "ocelotsocialnetwork/webapp:test" > /tmp/webapp.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-webapp-test - path: /tmp/webapp.tar - - ############################################################################## - # JOB: LINT BACKEND ########################################################## - ############################################################################## - lint_backend: - name: Lint backend - runs-on: ubuntu-latest - needs: [build_test_backend] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGE ################################################## - ########################################################################## - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar - ########################################################################## - # LINT BACKEND ########################################################### - ########################################################################## - - name: backend | Lint - run: docker run --rm ocelotsocialnetwork/backend:test yarn run lint - - ############################################################################## - # JOB: LINT WEBAPP ########################################################### - ############################################################################## - lint_webapp: - name: Lint webapp - runs-on: ubuntu-latest - needs: [build_test_webapp] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGE ################################################## - ########################################################################## - - name: Download Docker Image (Webapp) - uses: actions/download-artifact@v3 - with: - name: docker-webapp-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/webapp.tar - ########################################################################## - # LINT WEBAPP ############################################################ - ########################################################################## - - name: webapp | Lint - run: docker run --rm ocelotsocialnetwork/webapp:test yarn run lint - - ############################################################################## - # JOB: UNIT TEST BACKEND ##################################################### - ############################################################################## - unit_test_backend: - name: Unit tests - backend - runs-on: ubuntu-latest - needs: [build_test_neo4j,build_test_backend] - permissions: - checks: write - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - - name: Download Docker Image (Neo4J) - uses: actions/download-artifact@v3 - with: - name: docker-neo4j-image - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/neo4j.tar - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar - ########################################################################## - # UNIT TESTS BACKEND ##################################################### - ########################################################################## - - name: backend | copy env files webapp - run: cp webapp/.env.template webapp/.env - - name: backend | copy env files backend - run: cp backend/.env.template backend/.env - - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps neo4j backend - - name: backend | Initialize Database - run: docker-compose exec -T backend yarn db:migrate init - - name: backend | Migrate Database Up - run: docker-compose exec -T backend yarn db:migrate up - - name: backend | Unit test - run: docker-compose exec -T backend yarn test - ########################################################################## - # COVERAGE CHECK BACKEND ################################################# - ########################################################################## - - name: backend | Coverage check - uses: webcraftmedia/coverage-check-action@master - with: - report_name: Coverage Backend - type: lcov - result_path: ./coverage/lcov.info - min_coverage: 57 - token: ${{ github.token }} - - ############################################################################## - # JOB: UNIT TEST WEBAPP ###################################################### - ############################################################################## - unit_test_webapp: - name: Unit tests - webapp - runs-on: ubuntu-latest - needs: [build_test_webapp] - permissions: - checks: write - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - - name: Download Docker Image (Webapp) - uses: actions/download-artifact@v3 - with: - name: docker-webapp-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/webapp.tar - ########################################################################## - # UNIT TESTS WEBAPP ###################################################### - ########################################################################## - - name: backend | copy env files webapp - run: cp webapp/.env.template webapp/.env - - name: backend | copy env files backend - run: cp backend/.env.template backend/.env - - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp - - name: webapp | Unit tests - run: docker-compose exec -T webapp yarn test - ########################################################################## - # COVERAGE REPORT FRONTEND ################################################ - ########################################################################## - #- name: frontend | Coverage report - # uses: romeovs/lcov-reporter-action@v0.2.21 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # lcov-file: ./coverage/lcov.info - ########################################################################## - # COVERAGE CHECK WEBAPP ################################################## - ########################################################################## - - name: webapp | Coverage check - uses: webcraftmedia/coverage-check-action@master - with: - report_name: Coverage Webapp - type: lcov - result_path: ./coverage/lcov.info - min_coverage: 83 - token: ${{ github.token }} - - ############################################################################## - # JOB: FULLSTACK TESTS ####################################################### - ############################################################################## - fullstack_tests: - name: Fullstack tests - runs-on: ubuntu-latest - needs: [build_test_webapp, build_test_backend, build_test_neo4j] - env: - jobs: 8 - strategy: - matrix: - # run copies of the current job in parallel - job: [1, 2, 3, 4, 5, 6, 7, 8] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - - name: Download Docker Image (Neo4J) - uses: actions/download-artifact@v3 - with: - name: docker-neo4j-image - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/neo4j.tar - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar - - name: Download Docker Image (Webapp) - uses: actions/download-artifact@v3 - with: - name: docker-webapp-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/webapp.tar - ########################################################################## - # FULLSTACK TESTS CYPRESS ################################################ - ########################################################################## - - name: webapp | copy env files webapp - run: cp webapp/.env.template webapp/.env - - name: backend | copy env files backend - run: cp backend/.env.template backend/.env - - name: backend | docker-compose - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps webapp neo4j backend - - name: cypress | Fullstack tests - id: e2e-tests - run: | - yarn install - yarn run cypress:run --spec $(cypress/parallel-features.sh ${{ matrix.job }} ${{ env.jobs }} ) - ########################################################################## - # UPLOAD SCREENSHOTS - IF TESTS FAIL ##################################### - ########################################################################## - - name: Full stack tests | if any test failed, upload screenshots - if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} - uses: actions/upload-artifact@v3 - with: - name: cypress-screenshots - path: cypress/screenshots/ diff --git a/backend/Dockerfile b/backend/Dockerfile index dd8237a4e..cd9bcdd3c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,7 +1,7 @@ ################################################################################## # BASE (Is pushed to DockerHub for rebranding) ################################### ################################################################################## -FROM node:19.8.1-alpine3.17 as base +FROM node:19.9.0-alpine3.17 as base # ENVs ## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame diff --git a/backend/jest.config.js b/backend/jest.config.js index aabb59083..0f8017fb1 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -8,7 +8,11 @@ module.exports = { '!**/dist/**', '!**/src/**/?(*.)+(spec|test).js?(x)' ], - coverageReporters: ['lcov', 'text'], + coverageThreshold: { + global: { + lines: 57, + }, + }, testMatch: ['**/src/**/?(*.)+(spec|test).js?(x)'], setupFilesAfterEnv: ['/test/setup.js'] } diff --git a/backend/package.json b/backend/package.json index ff847a784..f32881357 100644 --- a/backend/package.json +++ b/backend/package.json @@ -76,9 +76,9 @@ "metascraper-lang-detector": "^4.10.2", "metascraper-logo": "^5.33.5", "metascraper-publisher": "^5.33.5", - "metascraper-soundcloud": "^5.33.5", + "metascraper-soundcloud": "^5.34.2", "metascraper-title": "^5.33.5", - "metascraper-url": "^5.33.5", + "metascraper-url": "^5.34.2", "metascraper-video": "^5.33.5", "metascraper-youtube": "^5.33.5", "migrate": "^1.7.0", diff --git a/backend/src/schema/resolvers/embeds.spec.js b/backend/src/schema/resolvers/embeds.spec.js index 0f0d41357..b22927d1b 100644 --- a/backend/src/schema/resolvers/embeds.spec.js +++ b/backend/src/schema/resolvers/embeds.spec.js @@ -126,7 +126,7 @@ describe('Query', () => { author: null, date: expect.any(String), description: - 'Human Connection, Weilheim an der Teck. Gefällt 24.407 Mal. An upcoming non-profit social network focused on local and global positive change. Twitter accounts : @hc_world (EN), @hc_deutschland (GE),...', + 'Human Connection, Weilheim an der Teck. Gefällt 24.407 Mal. An upcoming non-profit social network focused on local and global positive change. Twitter accounts : @hc_world (EN), @hc_deutschland (GE),…', html: null, image: 'https://scontent.ftxl3-1.fna.fbcdn.net/v/t1.0-1/c5.0.200.200a/p200x200/12108307_997373093648222_70057205881020137_n.jpg?_nc_cat=110&_nc_oc=AQnPPYQlR0dU556gOfl4xkXr7IPZdRIAUfQeXl3fpUv4DAsFN8T4PfgOjPwuq85GPKGZ5S5E5mWQ8IVV1UiRBAIZ&_nc_ht=scontent.ftxl3-1.fna&oh=90309adddaab38839782f16e7d4b7bcf&oe=5DEEDFE5', @@ -196,7 +196,7 @@ Have all the information for the brand in separate config files. Set these defau publisher: 'YouTube', date: expect.any(String), description: - 'She’s incapable of controlling her limbs when her kitty is around. The obsession grows every day. Ps. That’s a sleep sack she’s in. Not a starfish outfit. Al...', + 'She’s incapable of controlling her limbs when her kitty is around. The obsession grows every day. Ps. That’s a sleep sack she’s in. Not a starfish outfit. Al…', url: 'https://www.youtube.com/watch?v=qkdXAtO40Fo', image: 'https://i.ytimg.com/vi/qkdXAtO40Fo/maxresdefault.jpg', audio: null, diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index d806f3803..063b2210d 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -310,6 +310,7 @@ export default { ` MATCH (user:User {id: $userId}) WHERE user.role = 'admin' MATCH (post:Post {id: $params.id}) + WHERE NOT((post)-[:IN]->(:Group)) MERGE (user)-[pinned:PINNED {createdAt: toString(datetime())}]->(post) SET post.pinned = true RETURN post, pinned.createdAt as pinnedAt @@ -322,10 +323,12 @@ export default { })) }) const [transactionResult] = await writeTxResultPromise - const { pinnedPost, pinnedAt } = transactionResult - pinnedPostWithNestedAttributes = { - ...pinnedPost, - pinnedAt, + if (transactionResult) { + const { pinnedPost, pinnedAt } = transactionResult + pinnedPostWithNestedAttributes = { + ...pinnedPost, + pinnedAt, + } } } finally { session.close() diff --git a/backend/src/schema/resolvers/searches.js b/backend/src/schema/resolvers/searches.js index 3fdf22da3..a67abe90d 100644 --- a/backend/src/schema/resolvers/searches.js +++ b/backend/src/schema/resolvers/searches.js @@ -223,8 +223,7 @@ export default { }, searchResults: async (_parent, args, context, _resolveInfo) => { const { query, limit } = args - let userId = null - if (context.user) userId = context.user.id + const userId = context.user?.id || null const searchType = query.replace(/^([!@#&]?).*$/, '$1') const searchString = query.replace(/^([!@#&])/, '') diff --git a/backend/src/schema/resolvers/searches/queryString.js b/backend/src/schema/resolvers/searches/queryString.js index 5ef84cdce..8f415c5e6 100644 --- a/backend/src/schema/resolvers/searches/queryString.js +++ b/backend/src/schema/resolvers/searches/queryString.js @@ -33,7 +33,7 @@ const matchSomeWordsExactly = (str, boost = 2) => { const matchBeginningOfWords = (str) => { return str .split(' ') - .filter((s) => s.length > 3) + .filter((s) => s.length >= 2) .map((s) => s + '*') .join(' ') } diff --git a/backend/src/schema/resolvers/searches/queryString.spec.js b/backend/src/schema/resolvers/searches/queryString.spec.js index 23a746be1..fe3c91d3c 100644 --- a/backend/src/schema/resolvers/searches/queryString.spec.js +++ b/backend/src/schema/resolvers/searches/queryString.spec.js @@ -37,7 +37,7 @@ describe('queryString', () => { describe('globbing for longer words', () => { it('globs words with more than three characters', () => { - expect(queryString('a couple of words')).toContain('couple* words*') + expect(queryString('a couple of words')).toContain('couple* of* words*') }) }) }) diff --git a/backend/yarn.lock b/backend/yarn.lock index 683b69973..293e189dc 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1516,13 +1516,13 @@ url-regex "~4.1.1" video-extensions "~1.1.0" -"@metascraper/helpers@^5.33.5": - version "5.33.5" - resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.33.5.tgz#f980b41b3b7d7e67e11f849664727ef9d4802740" - integrity sha512-gcULKpM00CNxlf7iWRTi4hQQIXWQUjeFal0V5U60C4P4YyfLXfjuQVBk6mmKSYENSRh7oBQhAR+YVnMalVWBcw== +"@metascraper/helpers@^5.33.5", "@metascraper/helpers@^5.34.2": + version "5.34.2" + resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.34.2.tgz#3c6ef10c1ab7e8b09b67219c91c7b8d30fedd0c1" + integrity sha512-7mlQ1uYCUGw5OZU52leHbbjO8UrmmTvLCt6p4E4yWAvEW1oi9t7Pq1AmizX4hNUW+FgMvXCcv4t5BCfxiY8LhA== dependencies: audio-extensions "0.0.0" - chrono-node "~2.5.0" + chrono-node "~2.6.2" condense-whitespace "~2.0.0" entities "~4.4.0" file-extension "~4.0.5" @@ -1532,7 +1532,7 @@ is-uri "~1.2.4" iso-639-3 "~2.2.0" isostring "0.0.1" - jsdom "~21.1.0" + jsdom "~21.1.1" lodash "~4.17.21" memoize-one "~6.0.0" microsoft-capitalize "~1.0.5" @@ -1540,7 +1540,7 @@ normalize-url "~6.1.0" re2 "~1.18.0" smartquotes "~2.3.2" - tldts "~5.7.103" + tldts "~6.0.1" url-regex-safe "~3.0.0" video-extensions "~1.2.0" @@ -2166,7 +2166,7 @@ acorn@^7.1.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.1.0, acorn@^8.8.1: +acorn@^8.1.0, acorn@^8.8.2: version "8.8.2" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== @@ -3424,10 +3424,10 @@ chrono-node@~1.3.11: dependencies: moment "2.21.0" -chrono-node@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/chrono-node/-/chrono-node-2.5.0.tgz#c4d5f4f4db9d72604a5beb79fdc5fd57be4b212f" - integrity sha512-GasdFCw4tsb8UKlwyJW1S+3bdN06vsyGR2cEDMlhEGI7ic4SQRnLyl/hbItwSum6pPkkUTrzFcaR3C2tZnnO5Q== +chrono-node@~2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/chrono-node/-/chrono-node-2.6.3.tgz#fa257cffb2dfc33fa5a01b26bd86f93741ca6dc5" + integrity sha512-VkWaaZnNulqzNH9i4XCdyI05OX6MFEnCMNKdZOR4w//wS5/E2qkwAss/O5sj6SfTZK84fX4SSOG4pzqjqIseiA== dependencies: dayjs "^1.10.0" @@ -3858,22 +3858,12 @@ cssfilter@0.0.10: resolved "https://registry.yarnpkg.com/cssfilter/-/cssfilter-0.0.10.tgz#c6d2672632a2e5c83e013e6864a42ce8defd20ae" integrity sha1-xtJnJjKi5cg+AT5oZKQs6N79IK4= -cssom@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.5.0.tgz#d254fa92cd8b6fbd83811b9fbaed34663cc17c36" - integrity sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw== - -cssom@~0.3.6: - version "0.3.8" - resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.8.tgz#9f1276f5b2b463f2114d3f2c75250af8c1a36f4a" - integrity sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg== - -cssstyle@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-2.3.0.tgz#ff665a0ddbdc31864b09647f34163443d90b0852" - integrity sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A== +cssstyle@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-3.0.0.tgz#17ca9c87d26eac764bb8cfd00583cff21ce0277a" + integrity sha512-N4u2ABATi3Qplzf0hWbVCdjenim8F3ojEXpBDF5hBpjzW182MjNGLqfmQ0SkSPeQ+V86ZXgeH8aXj6kayd4jgg== dependencies: - cssom "~0.3.6" + rrweb-cssom "^0.6.0" cucumber-expressions@^8.1.0: version "8.2.1" @@ -3941,14 +3931,14 @@ dasherize@2.0.0: resolved "https://registry.yarnpkg.com/dasherize/-/dasherize-2.0.0.tgz#6d809c9cd0cf7bb8952d80fc84fa13d47ddb1308" integrity sha1-bYCcnNDPe7iVLYD8hPoT1H3bEwg= -data-urls@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-3.0.2.tgz#9cf24a477ae22bcef5cd5f6f0bfbc1d2d3be9143" - integrity sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ== +data-urls@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-4.0.0.tgz#333a454eca6f9a5b7b0f1013ff89074c3f522dd4" + integrity sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g== dependencies: abab "^2.0.6" whatwg-mimetype "^3.0.0" - whatwg-url "^11.0.0" + whatwg-url "^12.0.0" date-fns@2.22.1: version "2.22.1" @@ -3993,7 +3983,7 @@ debug@^4.1.0, debug@^4.1.1, debug@^4.3.3: dependencies: ms "2.1.2" -decimal.js@^10.4.2: +decimal.js@^10.4.3: version "10.4.3" resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.3.tgz#1044092884d245d1b7f65725fa4ad4c6f781cc23" integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA== @@ -7008,18 +6998,17 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== -jsdom@~21.1.0: - version "21.1.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-21.1.0.tgz#d56ba4a84ed478260d83bd53dc181775f2d8e6ef" - integrity sha512-m0lzlP7qOtthD918nenK3hdItSd2I+V3W9IrBcB36sqDwG+KnUs66IF5GY7laGWUnlM9vTsD0W1QwSEBYWWcJg== +jsdom@~21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-21.1.1.tgz#ab796361e3f6c01bcfaeda1fea3c06197ac9d8ae" + integrity sha512-Jjgdmw48RKcdAIQyUD1UdBh2ecH7VqwaXPN3ehoZN6MqgVbMn+lRm1aAT1AsdJRAJpwfa4IpwgzySn61h2qu3w== dependencies: abab "^2.0.6" - acorn "^8.8.1" + acorn "^8.8.2" acorn-globals "^7.0.0" - cssom "^0.5.0" - cssstyle "^2.3.0" - data-urls "^3.0.2" - decimal.js "^10.4.2" + cssstyle "^3.0.0" + data-urls "^4.0.0" + decimal.js "^10.4.3" domexception "^4.0.0" escodegen "^2.0.0" form-data "^4.0.0" @@ -7028,7 +7017,8 @@ jsdom@~21.1.0: https-proxy-agent "^5.0.1" is-potential-custom-element-name "^1.0.1" nwsapi "^2.2.2" - parse5 "^7.1.1" + parse5 "^7.1.2" + rrweb-cssom "^0.6.0" saxes "^6.0.0" symbol-tree "^3.2.4" tough-cookie "^4.1.2" @@ -7036,8 +7026,8 @@ jsdom@~21.1.0: webidl-conversions "^7.0.0" whatwg-encoding "^2.0.0" whatwg-mimetype "^3.0.0" - whatwg-url "^11.0.0" - ws "^8.11.0" + whatwg-url "^12.0.1" + ws "^8.13.0" xml-name-validator "^4.0.0" jsesc@^2.5.1: @@ -7624,12 +7614,12 @@ metascraper-publisher@^5.33.5: dependencies: "@metascraper/helpers" "^5.33.5" -metascraper-soundcloud@^5.33.5: - version "5.33.5" - resolved "https://registry.yarnpkg.com/metascraper-soundcloud/-/metascraper-soundcloud-5.33.5.tgz#9cd39e7ff432e715f8ecdca5256e7ea67f485557" - integrity sha512-hkDhRfTKEUugIN9Gxh/l9HuWlkNAOKEBXov/9fYKbIMgaj7e2UU7bkNYjaDOXzMikCRWEIrrGP3UzwwIcs6Gjg== +metascraper-soundcloud@^5.34.2: + version "5.34.2" + resolved "https://registry.yarnpkg.com/metascraper-soundcloud/-/metascraper-soundcloud-5.34.2.tgz#ee1077b4836321ccfb22bcab4bfae7360dd571a3" + integrity sha512-1VafeFnlzJaYUlq8XbppQauz0i9xM8QycJU8k4ONftZwRtikQBIjRe5BMXr/s5n32831vBooRz8ksz0CXkjVlQ== dependencies: - "@metascraper/helpers" "^5.33.5" + "@metascraper/helpers" "^5.34.2" metascraper-title@^5.33.5: version "5.33.5" @@ -7638,12 +7628,12 @@ metascraper-title@^5.33.5: dependencies: "@metascraper/helpers" "^5.33.5" -metascraper-url@^5.33.5: - version "5.33.5" - resolved "https://registry.yarnpkg.com/metascraper-url/-/metascraper-url-5.33.5.tgz#eb0ba736f47aef7c9a511ca04e509d11ee51c95d" - integrity sha512-bXKfsfxCfy6uhhnb9lMlIu1Uwqkn9eXa4QVcHdq/+1UWTOE8b2u4NTH4YgJMjcPmdth7s3cKXBxG1yBnsAoN0w== +metascraper-url@^5.34.2: + version "5.34.2" + resolved "https://registry.yarnpkg.com/metascraper-url/-/metascraper-url-5.34.2.tgz#1136dbf1177d08835d6b8677a64d9f10f0517fb0" + integrity sha512-ijPe3G64kyxFRWPA7YmH01dt5JImqBgWV07WIpgPj8wuD4ThwteGqV1CtjNYJN8yo/tCQeFNJPoubwiv9RsrJw== dependencies: - "@metascraper/helpers" "^5.33.5" + "@metascraper/helpers" "^5.34.2" metascraper-video@^5.33.5: version "5.33.5" @@ -8659,7 +8649,7 @@ parse5@^3.0.1: dependencies: "@types/node" "*" -parse5@^7.0.0, parse5@^7.1.1: +parse5@^7.0.0, parse5@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.1.2.tgz#0736bebbfd77793823240a23b7fc5e010b7f8e32" integrity sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw== @@ -8967,7 +8957,7 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= -punycode@^2.1.0, punycode@^2.1.1: +punycode@^2.1.0, punycode@^2.1.1, punycode@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== @@ -9469,6 +9459,11 @@ rosie@^2.0.1: resolved "https://registry.yarnpkg.com/rosie/-/rosie-2.0.1.tgz#c250c4787ce450b72aa9eff26509f68589814fa2" integrity sha1-wlDEeHzkULcqqe/yZQn2hYmBT6I= +rrweb-cssom@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz#ed298055b97cbddcdeb278f904857629dec5e0e1" + integrity sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw== + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -10363,17 +10358,17 @@ tlds@^1.228.0: resolved "https://registry.yarnpkg.com/tlds/-/tlds-1.236.0.tgz#a118eebe33261c577e3a3025144faeabb7dd813c" integrity sha512-oP2PZ3KeGlgpHgsEfrtva3/K9kzsJUNliQSbCfrJ7JMCWFoCdtG+9YMq/g2AnADQ1v5tVlbtvKJZ4KLpy/P6MA== -tldts-core@^5.7.104: - version "5.7.104" - resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-5.7.104.tgz#4313a9663e4085332750a5fb04bfa0b0d91b826d" - integrity sha512-8vhSgc2nzPNT0J7XyCqcOtQ6+ySBn+gsPmj5h95YytIZ7L2Xl40paUmj0T6Uko42HegHGQxXieunHIQuABWSmQ== +tldts-core@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/tldts-core/-/tldts-core-6.0.3.tgz#b59d87507c51cd2488c322b92020b973b608b59a" + integrity sha512-PLiEM2aCkfGifyr8npbd93eWIW4isFRB44vTiup5DRie6e2Qy3+9quwHb252v12JyoM+RmF1cxtDgwD2PVBOjA== -tldts@~5.7.103: - version "5.7.104" - resolved "https://registry.yarnpkg.com/tldts/-/tldts-5.7.104.tgz#c964cf8a194936b086fa4c72994e92d4cd4d2562" - integrity sha512-PlziEIVPH/ogbqOhS35K6MOeD09rd9U5g2NHO5n9NZeMC1PGpXgsjQpoJ1KiRnjhZsWDkzN8EoX3xQZuz5ZyFQ== +tldts@~6.0.1: + version "6.0.3" + resolved "https://registry.yarnpkg.com/tldts/-/tldts-6.0.3.tgz#6a4a8bb550f396d6d72818606150e0e0263ae826" + integrity sha512-rcdUIwrcGuMWe5+fg5FFBrmWTYdbfpHwkk1AjBKoSDbpsdAsYqJYKoZOVOHn8MQCYatADKGAx/SU+jpSKxSYNw== dependencies: - tldts-core "^5.7.104" + tldts-core "^6.0.3" tmp@^0.0.33: version "0.0.33" @@ -10464,12 +10459,12 @@ tough-cookie@^4.1.2: universalify "^0.2.0" url-parse "^1.5.3" -tr46@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" - integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== +tr46@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-4.1.1.tgz#281a758dcc82aeb4fe38c7dfe4d11a395aac8469" + integrity sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw== dependencies: - punycode "^2.1.1" + punycode "^2.3.0" trigram-utils@^1.0.0: version "1.0.2" @@ -10931,12 +10926,12 @@ whatwg-mimetype@^3.0.0: resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz#5fa1a7623867ff1af6ca3dc72ad6b8a4208beba7" integrity sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q== -whatwg-url@^11.0.0: - version "11.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-11.0.0.tgz#0a849eebb5faf2119b901bb76fd795c2848d4018" - integrity sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ== +whatwg-url@^12.0.0, whatwg-url@^12.0.1: + version "12.0.1" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-12.0.1.tgz#fd7bcc71192e7c3a2a97b9a8d6b094853ed8773c" + integrity sha512-Ed/LrqB8EPlGxjS+TrsXcpUond1mhccS3pchLhzSgPCnTimUCKj3IZE75pAs5m6heB2U2TMerKFUXheyHY+VDQ== dependencies: - tr46 "^3.0.0" + tr46 "^4.1.1" webidl-conversions "^7.0.0" which@^1.2.9: @@ -11047,10 +11042,10 @@ ws@^6.0.0: dependencies: async-limiter "~1.0.0" -ws@^8.11.0: - version "8.12.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.0.tgz#485074cc392689da78e1828a9ff23585e06cddd8" - integrity sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig== +ws@^8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== x-xss-protection@1.3.0: version "1.3.0" diff --git a/deployment/configurations/stage.ocelot.social b/deployment/configurations/stage.ocelot.social index b3f7838c2..be3ac7ad2 160000 --- a/deployment/configurations/stage.ocelot.social +++ b/deployment/configurations/stage.ocelot.social @@ -1 +1 @@ -Subproject commit b3f7838c2612a81b031c2ab7b372d0c66e8b9466 +Subproject commit be3ac7ad29f37d6a00fb3203db302cd91cebb9fa diff --git a/deployment/docker-compose.yml b/deployment/docker-compose.yml index a0dda4dc0..973dc6ac5 100644 --- a/deployment/docker-compose.yml +++ b/deployment/docker-compose.yml @@ -65,10 +65,10 @@ services: backend: image: ocelotsocialnetwork/backend-branded:local-${CONFIGURATION} - container_name: backend + container_name: backend-branded build: dockerfile: src/docker/backend.Dockerfile - target: branded-branded + target: branded context: . args: - CONFIGURATION=$CONFIGURATION @@ -143,7 +143,7 @@ services: neo4j: image: ocelotsocialnetwork/neo4j-community:latest - container_name: neo4j + container_name: neo4j-branded networks: - test-network volumes: diff --git a/deployment/scripts/branded-images.build.sh b/deployment/scripts/branded-images.build.sh index bb86b29a6..fa9da67d1 100755 --- a/deployment/scripts/branded-images.build.sh +++ b/deployment/scripts/branded-images.build.sh @@ -16,6 +16,13 @@ if [ -z ${CONFIGURATION} ]; then fi echo "Using CONFIGURATION=${CONFIGURATION}" +# check DOCKERHUB_BRAND_VARRIANT +if [ -z ${DOCKERHUB_BRAND_VARRIANT} ]; then + echo "You must provide a `DOCKERHUB_BRAND_VARRIANT` via environment variable" + exit 1 +fi +echo "Using DOCKERHUB_BRAND_VARRIANT=${DOCKERHUB_BRAND_VARRIANT}" + # configuration DOCKERHUB_ORGANISATION=${DOCKERHUB_ORGANISATION:-"ocelotsocialnetwork"} OCELOT_VERSION=${OCELOT_VERSION:-$(node -p -e "require('${SCRIPT_DIR}/../../package.json').version")} @@ -29,11 +36,11 @@ BUILD_COMMIT=${GITHUB_SHA:-"0000000"} # backend docker build --target branded \ - -t "${DOCKERHUB_ORGANISATION}/backend-branded:latest" \ - -t "${DOCKERHUB_ORGANISATION}/backend-branded:${OCELOT_VERSION}" \ - -t "${DOCKERHUB_ORGANISATION}/backend-branded:${OCELOT_VERSION_BUILD}" \ - -t "${DOCKERHUB_ORGANISATION}/backend-branded:${BUILD_VERSION_BASE}" \ - -t "${DOCKERHUB_ORGANISATION}/backend-branded:${BUILD_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:latest" \ + -t "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD}" \ + -t "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE}" \ + -t "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION}" \ -f "${SCRIPT_DIR}/../src/docker/backend.Dockerfile" \ --build-arg "CONFIGURATION=${CONFIGURATION}" \ --build-arg "APP_IMAGE_TAG_CODE=${OCELOT_VERSION}-code" \ @@ -42,11 +49,11 @@ docker build --target branded \ # webapp docker build --target branded \ - -t "${DOCKERHUB_ORGANISATION}/webapp-branded:latest" \ - -t "${DOCKERHUB_ORGANISATION}/webapp-branded:${OCELOT_VERSION}" \ - -t "${DOCKERHUB_ORGANISATION}/webapp-branded:${OCELOT_VERSION_BUILD}" \ - -t "${DOCKERHUB_ORGANISATION}/webapp-branded:${BUILD_VERSION_BASE}" \ - -t "${DOCKERHUB_ORGANISATION}/webapp-branded:${BUILD_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:latest" \ + -t "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD}" \ + -t "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE}" \ + -t "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION}" \ -f "${SCRIPT_DIR}/../src/docker/webapp.Dockerfile" \ --build-arg "CONFIGURATION=${CONFIGURATION}" \ --build-arg "APP_IMAGE_TAG_CODE=${OCELOT_VERSION}-code" \ @@ -55,11 +62,11 @@ docker build --target branded \ # mainteance docker build --target branded \ - -t "${DOCKERHUB_ORGANISATION}/maintenance-branded:latest" \ - -t "${DOCKERHUB_ORGANISATION}/maintenance-branded:${OCELOT_VERSION}" \ - -t "${DOCKERHUB_ORGANISATION}/maintenance-branded:${OCELOT_VERSION_BUILD}" \ - -t "${DOCKERHUB_ORGANISATION}/maintenance-branded:${BUILD_VERSION_BASE}" \ - -t "${DOCKERHUB_ORGANISATION}/maintenance-branded:${BUILD_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:latest" \ + -t "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION}" \ + -t "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD}" \ + -t "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE}" \ + -t "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION}" \ -f "${SCRIPT_DIR}/../src/docker/maintenance.Dockerfile" \ --build-arg "CONFIGURATION=${CONFIGURATION}" \ --build-arg "APP_IMAGE_TAG_CODE=${OCELOT_VERSION}-code" \ diff --git a/deployment/scripts/branded-images.upload.sh b/deployment/scripts/branded-images.upload.sh index 0d3fdb6d6..83e27496b 100755 --- a/deployment/scripts/branded-images.upload.sh +++ b/deployment/scripts/branded-images.upload.sh @@ -10,6 +10,13 @@ SCRIPT_PATH=$(realpath $0) SCRIPT_DIR=$(dirname $SCRIPT_PATH) +# check DOCKERHUB_BRAND_VARRIANT +if [ -z ${DOCKERHUB_BRAND_VARRIANT} ]; then + echo "You must provide a `DOCKERHUB_BRAND_VARRIANT` via environment variable" + exit 1 +fi +echo "Using DOCKERHUB_BRAND_VARRIANT=${DOCKERHUB_BRAND_VARRIANT}" + # configuration DOCKERHUB_ORGANISATION=${DOCKERHUB_ORGANISATION:-"ocelotsocialnetwork"} OCELOT_VERSION=${OCELOT_VERSION:-$(node -p -e "require('${SCRIPT_DIR}/../../package.json').version")} @@ -23,22 +30,22 @@ BUILD_VERSION=${BRANDED_VERSION}-ocelot.social${OCELOT_VERSION_BUILD} echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin # push backend images -docker push ${DOCKERHUB_ORGANISATION}/backend-branded:latest -docker push ${DOCKERHUB_ORGANISATION}/backend-branded:${OCELOT_VERSION} -docker push ${DOCKERHUB_ORGANISATION}/backend-branded:${OCELOT_VERSION_BUILD} -docker push ${DOCKERHUB_ORGANISATION}/backend-branded:${BUILD_VERSION_BASE} -docker push ${DOCKERHUB_ORGANISATION}/backend-branded:${BUILD_VERSION} +docker push ${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:latest +docker push ${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION} +docker push ${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD} +docker push ${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE} +docker push ${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION} # push webapp images -docker push ${DOCKERHUB_ORGANISATION}/webapp-branded:latest -docker push ${DOCKERHUB_ORGANISATION}/webapp-branded:${OCELOT_VERSION} -docker push ${DOCKERHUB_ORGANISATION}/webapp-branded:${OCELOT_VERSION_BUILD} -docker push ${DOCKERHUB_ORGANISATION}/webapp-branded:${BUILD_VERSION_BASE} -docker push ${DOCKERHUB_ORGANISATION}/webapp-branded:${BUILD_VERSION} +docker push ${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:latest +docker push ${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION} +docker push ${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD} +docker push ${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE} +docker push ${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION} # push maintenance images -docker push ${DOCKERHUB_ORGANISATION}/maintenance-branded:latest -docker push ${DOCKERHUB_ORGANISATION}/maintenance-branded:${OCELOT_VERSION} -docker push ${DOCKERHUB_ORGANISATION}/maintenance-branded:${OCELOT_VERSION_BUILD} -docker push ${DOCKERHUB_ORGANISATION}/maintenance-branded:${BUILD_VERSION_BASE} -docker push ${DOCKERHUB_ORGANISATION}/maintenance-branded:${BUILD_VERSION} \ No newline at end of file +docker push ${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:latest +docker push ${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION} +docker push ${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${OCELOT_VERSION_BUILD} +docker push ${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION_BASE} +docker push ${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}:${BUILD_VERSION} \ No newline at end of file diff --git a/deployment/src/kubernetes/templates/backend/Deployment.yaml b/deployment/src/kubernetes/templates/backend/Deployment.yaml index 7125363f5..4d0f66dbc 100644 --- a/deployment/src/kubernetes/templates/backend/Deployment.yaml +++ b/deployment/src/kubernetes/templates/backend/Deployment.yaml @@ -41,9 +41,9 @@ spec: name: secret-{{ .Release.Name }}-backend resources: requests: - memory: {{ .Values.BACKEND.RESOURCE_REQUESTS_MEMORY | default "1G" | quote }} + memory: {{ .Values.BACKEND.RESOURCE_REQUESTS_MEMORY | default "500M" | quote }} limits: - memory: {{ .Values.BACKEND.RESOURCE_LIMITS_MEMORY | default "2G" | quote }} + memory: {{ .Values.BACKEND.RESOURCE_LIMITS_MEMORY | default "1G" | quote }} ports: - containerPort: 4000 protocol: TCP diff --git a/deployment/src/kubernetes/templates/webapp/Deployment.yaml b/deployment/src/kubernetes/templates/webapp/Deployment.yaml index 9dbe6aefb..41221185c 100644 --- a/deployment/src/kubernetes/templates/webapp/Deployment.yaml +++ b/deployment/src/kubernetes/templates/webapp/Deployment.yaml @@ -42,8 +42,8 @@ spec: name: secret-{{ .Release.Name }}-webapp resources: requests: - memory: {{ .Values.WEBAPP.RESOURCE_REQUESTS_MEMORY | default "1G" | quote }} + memory: {{ .Values.WEBAPP.RESOURCE_REQUESTS_MEMORY | default "500M" | quote }} limits: - memory: {{ .Values.WEBAPP.RESOURCE_LIMITS_MEMORY | default "2G" | quote }} + memory: {{ .Values.WEBAPP.RESOURCE_LIMITS_MEMORY | default "1G" | quote }} restartPolicy: {{ .Values.WEBAPP.CONTAINER_RESTART_POLICY }} terminationGracePeriodSeconds: {{ .Values.WEBAPP.CONTAINER_TERMINATION_GRACE_PERIOD_SECONDS }} \ No newline at end of file diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 067dc58e3..d4f1f3fe1 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -1,7 +1,7 @@ ################################################################################## # BASE (Is pushed to DockerHub for rebranding) ################################### ################################################################################## -FROM node:19.8.1-alpine3.17 as base +FROM node:19.9.0-alpine3.17 as base # ENVs ## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame diff --git a/webapp/Dockerfile.maintenance b/webapp/Dockerfile.maintenance index e285ca40e..3d844e915 100644 --- a/webapp/Dockerfile.maintenance +++ b/webapp/Dockerfile.maintenance @@ -1,7 +1,7 @@ ################################################################################## # BASE ########################################################################### ################################################################################## -FROM node:19.8.1-alpine3.17 as base +FROM node:19.9.0-alpine3.17 as base # ENVs ## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame diff --git a/webapp/components/CategoriesSelect/CategoriesSelect.vue b/webapp/components/CategoriesSelect/CategoriesSelect.vue index 4f7a555a3..91fb7704c 100644 --- a/webapp/components/CategoriesSelect/CategoriesSelect.vue +++ b/webapp/components/CategoriesSelect/CategoriesSelect.vue @@ -43,6 +43,14 @@ export default { selectedCategoryIds: this.existingCategoryIds, } }, + watch: { + existingCategoryIds() { + if (!this.selectedCategoryIds.length && this.existingCategoryIds.length) { + this.selectedCategoryIds = this.existingCategoryIds + this.$forceUpdate() + } + }, + }, computed: { selectedCount() { return this.selectedCategoryIds.length diff --git a/webapp/components/ContentMenu/ContentMenu.vue b/webapp/components/ContentMenu/ContentMenu.vue index 60bcccf43..d723a9667 100644 --- a/webapp/components/ContentMenu/ContentMenu.vue +++ b/webapp/components/ContentMenu/ContentMenu.vue @@ -80,7 +80,7 @@ export default { }) } - if (this.isAdmin) { + if (this.isAdmin && !this.resource.group) { if (!this.resource.pinnedBy) { routes.push({ label: this.$t(`post.menu.pin`), diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 8863fbc8a..f740e1f05 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -177,6 +177,15 @@ export default { groupName() { return this.group && this.group.name }, + groupCategories() { + return this.group && this.group.categories + }, + }, + watch: { + groupCategories() { + if (!this.formData.categoryIds.length && this.groupCategories) + this.formData.categoryIds = this.groupCategories.map((cat) => cat.id) + }, }, methods: { submit() { diff --git a/webapp/components/Group/GroupForm.vue b/webapp/components/Group/GroupForm.vue index cb407a3d9..52437d644 100644 --- a/webapp/components/Group/GroupForm.vue +++ b/webapp/components/Group/GroupForm.vue @@ -37,8 +37,6 @@ {{ $t('group.type') }} - - - - + { + let wrapper + let mocks + + beforeEach(() => { + mocks = { + $t: jest.fn(), + } + }) + + describe('mount', () => { + const Wrapper = () => { + return shallowMount(ActionRadiusSelect, { propsData, mocks, localVue }) + } + + beforeEach(() => { + wrapper = Wrapper() + }) + it('renders the select', () => { + expect(wrapper.findComponent(ActionRadiusSelect).exists()).toBe(true) + }) + + describe('when an option is selected', () => { + it('emits a change event with the new value', () => { + const select = wrapper.find('select') + select.trigger('change') + expect(wrapper.emitted().change[0]).toEqual(['regional']) + }) + }) + }) +}) diff --git a/webapp/components/Select/ActionRadiusSelect.vue b/webapp/components/Select/ActionRadiusSelect.vue new file mode 100644 index 000000000..0a090e0a5 --- /dev/null +++ b/webapp/components/Select/ActionRadiusSelect.vue @@ -0,0 +1,33 @@ + + + diff --git a/webapp/components/generic/SearchableInput/SearchableInput.spec.js b/webapp/components/generic/SearchableInput/SearchableInput.spec.js index cda9150b8..223ee6186 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.spec.js +++ b/webapp/components/generic/SearchableInput/SearchableInput.spec.js @@ -63,13 +63,6 @@ describe('SearchableInput.vue', () => { expect(select.element.value).toBe('abcd') }) - it('calls onDelete when the delete key is pressed', () => { - const spy = jest.spyOn(wrapper.vm, 'onDelete') - select.trigger('input') - select.trigger('keyup.delete') - expect(spy).toHaveBeenCalledTimes(1) - }) - describe('navigating to resource', () => { beforeEach(() => { propsData = { options: searchResults } diff --git a/webapp/components/generic/SearchableInput/SearchableInput.vue b/webapp/components/generic/SearchableInput/SearchableInput.vue index 2149732c5..b0e813b45 100644 --- a/webapp/components/generic/SearchableInput/SearchableInput.vue +++ b/webapp/components/generic/SearchableInput/SearchableInput.vue @@ -1,9 +1,10 @@