diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 80b7482d9..f0d38b75b 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -30,10 +30,13 @@ admin: &admin - 'admin/**/*' +backend: &backend + - 'backend/**/*' + dht_node: &dht_node - 'dht-node/**/*' -docker: &docker +docker-compose: &docker-compose - 'docker-compose.*' federation: &federation @@ -42,5 +45,8 @@ federation: &federation frontend: &frontend - 'frontend/**/*' +mariadb: &mariadb + - 'mariadb/**/*' + nginx: &nginx - 'nginx/**/*' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 0fcedb4ce..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,195 +0,0 @@ -name: gradido test CI - -on: push - -jobs: - ############################################################################## - # JOB: DOCKER BUILD TEST BACKEND ############################################# - ############################################################################## - build_test_backend: - name: Docker Build Test - Backend - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BACKEND ################################################################ - ########################################################################## - - name: Backend | Build `test` image - run: | - docker build -f ./backend/Dockerfile --target test -t "gradido/backend:test" . - docker save "gradido/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 DATABASE UP ######################################### - ############################################################################## - build_test_database_up: - name: Docker Build Test - Database up - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DATABASE UP ############################################################ - ########################################################################## - - name: Database | Build `test_up` image - run: | - docker build --target test_up -t "gradido/database:test_up" database/ - docker save "gradido/database:test_up" > /tmp/database_up.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-database-test_up - path: /tmp/database_up.tar - - ############################################################################## - # JOB: DOCKER BUILD TEST MARIADB ############################################# - ############################################################################## - build_test_mariadb: - name: Docker Build Test - MariaDB - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BUILD MARIADB DOCKER IMAGE ############################################# - ########################################################################## - - name: mariadb | Build `test` image - run: | - docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ - docker save "gradido/mariadb:test" > /tmp/mariadb.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-mariadb-test - path: /tmp/mariadb.tar - - ############################################################################## - # JOB: LINT BACKEND ########################################################## - ############################################################################## - lint_backend: - name: Lint - Backend - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LINT BACKEND ########################################################### - ########################################################################## - - name: backend | Lint - run: cd database && yarn && cd ../backend && yarn && yarn run lint - - ############################################################################## - # JOB: LOCALES BACKEND ####################################################### - ############################################################################## - locales_backend: - name: Locales - Backend - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LOCALES BACKEND ##################################################### - ########################################################################## - - name: Backend | Locales - run: cd backend && yarn && yarn locales - - ############################################################################## - # JOB: LINT DATABASE UP ###################################################### - ############################################################################## - lint_database_up: - name: Lint - Database Up - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # LINT DATABASE ########################################################## - ########################################################################## - - name: Database | Lint - run: cd database && yarn && yarn run lint - - ############################################################################## - # JOB: UNIT TEST BACKEND #################################################### - ############################################################################## - unit_test_backend: - name: Unit tests - Backend - runs-on: ubuntu-latest - needs: [build_test_mariadb] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOWNLOAD DOCKER IMAGES ################################################# - ########################################################################## - - name: Download Docker Image (Mariadb) - uses: actions/download-artifact@v3 - with: - name: docker-mariadb-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/mariadb.tar - ########################################################################## - # UNIT TESTS BACKEND ##################################################### - ########################################################################## - - name: backend | docker-compose mariadb - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb - - name: Sleep for 30 seconds - run: sleep 30s - shell: bash - - name: backend | docker-compose database - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database - - name: backend Unit tests | test - run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test - - ########################################################################## - # DATABASE MIGRATION TEST UP + RESET ##################################### - ########################################################################## - database_migration_test: - name: Database Migration Test - Up + Reset - runs-on: ubuntu-latest - #needs: [nothing] - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # DOCKER COMPOSE DATABASE UP + RESET ##################################### - ########################################################################## - - name: database | docker-compose - run: docker-compose -f docker-compose.yml up --detach mariadb - - name: database | up - run: docker-compose -f docker-compose.yml run -T database yarn up - - name: database | reset - run: docker-compose -f docker-compose.yml run -T database yarn reset diff --git a/.github/workflows/test-admin-interface.yml b/.github/workflows/test_admin_interface.yml similarity index 100% rename from .github/workflows/test-admin-interface.yml rename to .github/workflows/test_admin_interface.yml diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml new file mode 100644 index 000000000..b517c5186 --- /dev/null +++ b/.github/workflows/test_backend.yml @@ -0,0 +1,81 @@ +name: Gradido Backend Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - Backend + runs-on: ubuntu-latest + outputs: + backend: ${{ steps.changes.outputs.backend }} + database: ${{ steps.changes.outputs.database }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} + mariadb: ${{ steps.changes.outputs.mariadb }} + 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: + if: needs.files-changed.outputs.backend == 'true' + name: Docker Build Test - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Build 'test' image + run: docker build -f ./backend/Dockerfile --target test -t "gradido/backend:test" . + + unit_test: + if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' + name: Unit tests - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | docker-compose mariadb + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb + + - name: Sleep for 30 seconds + run: sleep 30s + shell: bash + + - name: Backend | docker-compose database + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database + + - name: Backend | Unit tests + run: cd database && yarn && yarn build && cd ../backend && yarn && yarn test + + lint: + if: needs.files-changed.outputs.backend == 'true' + name: Lint - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Lint + run: cd database && yarn && cd ../backend && yarn && yarn run lint + + locales: + if: needs.files-changed.outputs.backend == 'true' + name: Locales - Backend + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Backend | Locales + run: cd backend && yarn && yarn locales \ No newline at end of file diff --git a/.github/workflows/test_database.yml b/.github/workflows/test_database.yml new file mode 100644 index 000000000..0444a0538 --- /dev/null +++ b/.github/workflows/test_database.yml @@ -0,0 +1,64 @@ +name: Gradido Database Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - Database + runs-on: ubuntu-latest + outputs: + database: ${{ steps.changes.outputs.database }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} + mariadb: ${{ steps.changes.outputs.mariadb }} + 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: + if: needs.files-changed.outputs.database == 'true' + name: Docker Build Test - Database up + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | Build 'test_up' image + run: docker build --target test_up -t "gradido/database:test_up" database/ + + database_migration_test: + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' + name: Database Migration Test - Up + Reset + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | docker-compose + run: docker-compose -f docker-compose.yml up --detach mariadb + + - name: Database | up + run: docker-compose -f docker-compose.yml run -T database yarn up + + - name: Database | reset + run: docker-compose -f docker-compose.yml run -T database yarn reset + + lint: + if: needs.files-changed.outputs.database == 'true' + name: Lint - Database Up + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Database | Lint + run: cd database && yarn && yarn run lint \ No newline at end of file diff --git a/.github/workflows/test_dht-node.yml b/.github/workflows/test_dht_node.yml similarity index 68% rename from .github/workflows/test_dht-node.yml rename to .github/workflows/test_dht_node.yml index a57f09399..b63d1fc0d 100644 --- a/.github/workflows/test_dht-node.yml +++ b/.github/workflows/test_dht_node.yml @@ -3,14 +3,13 @@ name: Gradido DHT Node Test CI on: push jobs: - # only (but most important) job from this workflow required for pull requests - # check results serve as run conditions for all other jobs here files-changed: name: Detect File Changes - DHT Node runs-on: ubuntu-latest outputs: + database: ${{ steps.changes.outputs.database }} dht_node: ${{ steps.changes.outputs.dht_node }} - docker: ${{ steps.changes.outputs.docker }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} steps: - uses: actions/checkout@v3.3.0 @@ -22,12 +21,9 @@ jobs: filters: .github/file-filters.yml list-files: shell - ############################################################################## - # JOB: DOCKER BUILD TEST ##################################################### - ############################################################################## build: name: Docker Build Test - DHT Node - if: needs.files-changed.outputs.dht_node == 'true' || needs.files-changed.outputs.docker == 'true' + if: needs.files-changed.outputs.dht_node == 'true' needs: files-changed runs-on: ubuntu-latest steps: @@ -45,9 +41,6 @@ jobs: name: docker-dht-node-test path: /tmp/dht-node.tar - ############################################################################## - # JOB: LINT ################################################################## - ############################################################################## lint: name: Lint - DHT Node if: needs.files-changed.outputs.dht_node == 'true' @@ -60,12 +53,9 @@ jobs: - name: Lint run: cd dht-node && yarn && yarn run lint - ############################################################################## - # JOB: UNIT TEST ############################################################# - ############################################################################## unit_test: name: Unit Tests - DHT Node - if: needs.files-changed.outputs.dht_node == 'true' || needs.files-changed.outputs.docker == 'true' + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.dht_node == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.mariadb == 'true' needs: [files-changed, build] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/test_e2e.yml similarity index 100% rename from .github/workflows/e2e-test.yml rename to .github/workflows/test_e2e.yml diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml index fc29a1bf8..92ccd95d2 100644 --- a/.github/workflows/test_federation.yml +++ b/.github/workflows/test_federation.yml @@ -3,13 +3,11 @@ name: Gradido Federation Test CI on: push jobs: - # only (but most important) job from this workflow required for pull requests - # check results serve as run conditions for all other jobs here files-changed: name: Detect File Changes - Federation runs-on: ubuntu-latest outputs: - docker: ${{ steps.changes.outputs.docker }} + docker-compose: ${{ steps.changes.outputs.docker-compose }} federation: ${{ steps.changes.outputs.federation }} steps: - uses: actions/checkout@v3.3.0 @@ -22,12 +20,9 @@ jobs: filters: .github/file-filters.yml list-files: shell - ############################################################################## - # JOB: DOCKER BUILD TEST ##################################################### - ############################################################################## build: name: Docker Build Test - Federation - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.federation == 'true' + if: needs.files-changed.outputs.federation == 'true' needs: files-changed runs-on: ubuntu-latest steps: @@ -45,9 +40,6 @@ jobs: name: docker-federation-test path: /tmp/federation.tar - ############################################################################## - # JOB: LINT ################################################################## - ############################################################################## lint: name: Lint - Federation if: needs.files-changed.outputs.federation == 'true' @@ -60,12 +52,9 @@ jobs: - name: Lint run: cd federation && yarn && yarn run lint - ############################################################################## - # JOB: UNIT TEST ############################################################# - ############################################################################## unit_test: name: Unit Tests - Federation - if: needs.files-changed.outputs.docker == 'true' || needs.files-changed.outputs.federation == 'true' + if: needs.files-changed.outputs.database == 'true' || needs.files-changed.outputs.docker-compose == 'true' || needs.files-changed.outputs.federation == 'true' || needs.files-changed.outputs.mariadb == 'true' needs: [files-changed, build] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test_mariadb.yml b/.github/workflows/test_mariadb.yml new file mode 100644 index 000000000..fe101bc48 --- /dev/null +++ b/.github/workflows/test_mariadb.yml @@ -0,0 +1,32 @@ +name: Gradido MariaDB Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - MariaDB + runs-on: ubuntu-latest + outputs: + mariadb: ${{ steps.changes.outputs.mariadb }} + 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: + if: needs.files-changed.outputs.mariadb == 'true' + name: Docker Build Test - MariaDB + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: MariaDB | Build 'test' image + run: docker build --target mariadb_server -t "gradido/mariadb:test" -f ./mariadb/Dockerfile ./ diff --git a/.github/workflows/test-nginx.yml b/.github/workflows/test_nginx.yml similarity index 100% rename from .github/workflows/test-nginx.yml rename to .github/workflows/test_nginx.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc91f2fa..d52ba760c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,72 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.20.0](https://github.com/gradido/gradido/compare/1.19.1...1.20.0) + +- fix(backend): no await for emails [`#2918`](https://github.com/gradido/gradido/pull/2918) +- fix(frontend): no receiver on send by link [`#2933`](https://github.com/gradido/gradido/pull/2933) +- fix(admin): pagination set currentPage by switch tabs [`#2902`](https://github.com/gradido/gradido/pull/2902) +- fix(federation): correct export of the community url [`#2931`](https://github.com/gradido/gradido/pull/2931) +- fix(frontend): displayed decay duration [`#2927`](https://github.com/gradido/gradido/pull/2927) +- fix(frontend): community tab navigation [`#2928`](https://github.com/gradido/gradido/pull/2928) +- fix(frontend): moderator id missing [`#2925`](https://github.com/gradido/gradido/pull/2925) +- fix(frontend): reset button send coins [`#2924`](https://github.com/gradido/gradido/pull/2924) +- refactor(backend): eslint plugin import export style [`#2908`](https://github.com/gradido/gradido/pull/2908) +- fix(backend): vscode intellisense fixes [`#2919`](https://github.com/gradido/gradido/pull/2919) +- refactor(backend): eslint import-no-cycle enabled [`#2905`](https://github.com/gradido/gradido/pull/2905) +- docs(backend): alias rules and conventions [`#2881`](https://github.com/gradido/gradido/pull/2881) +- refactor(backend): get transaction list [`#2923`](https://github.com/gradido/gradido/pull/2923) +- feat(backend): previous balance in transaction [`#2914`](https://github.com/gradido/gradido/pull/2914) +- refactor(backend): eslint update packages [`#2829`](https://github.com/gradido/gradido/pull/2829) +- feat(frontend): send coins via gradido ID [`#2837`](https://github.com/gradido/gradido/pull/2837) +- refactor(database): cleanup database [`#2808`](https://github.com/gradido/gradido/pull/2808) +- refactor(backend): eslint plugin n + fixes [`#2828`](https://github.com/gradido/gradido/pull/2828) +- feat(frontend): add link to download QR-Code [`#2889`](https://github.com/gradido/gradido/pull/2889) +- fix(other): delete node_modules and /tmp/yarn--* on start.sh [`#2904`](https://github.com/gradido/gradido/pull/2904) +- fix(admin): add confirmation modal for user role change and user (un)deletion [`#2880`](https://github.com/gradido/gradido/pull/2880) +- fix(admin): admin open contribution edit button [`#2811`](https://github.com/gradido/gradido/pull/2811) +- fix(backend): import order [`#2911`](https://github.com/gradido/gradido/pull/2911) +- fix(other): use default values for undefined .env database values [`#2910`](https://github.com/gradido/gradido/pull/2910) +- refactor(backend): eslint plugin import + fixes [`#2827`](https://github.com/gradido/gradido/pull/2827) +- refactor(backend): missing event tests [`#2900`](https://github.com/gradido/gradido/pull/2900) +- refactor(backend): unify event names [`#2799`](https://github.com/gradido/gradido/pull/2799) +- feat(backend): events for users [`#2797`](https://github.com/gradido/gradido/pull/2797) +- fix(backend): subscription get's email and languages from user [`#2885`](https://github.com/gradido/gradido/pull/2885) +- refactor(backend): eslint-plugin-jest + fixes [`#2816`](https://github.com/gradido/gradido/pull/2816) +- fix(frontend): fr change ` and ´ to ' [`#2888`](https://github.com/gradido/gradido/pull/2888) +- feat(backend): events for transaction links [`#2792`](https://github.com/gradido/gradido/pull/2792) +- feat(backend): events for contributions [`#2784`](https://github.com/gradido/gradido/pull/2784) +- feat(backend): events for contribution messages [`#2783`](https://github.com/gradido/gradido/pull/2783) +- refactor(backend): upgrade coverage to 85% [`#2884`](https://github.com/gradido/gradido/pull/2884) +- refactor(backend): add klicktipp-api library [`#2883`](https://github.com/gradido/gradido/pull/2883) +- feat(backend): events for contribution links [`#2780`](https://github.com/gradido/gradido/pull/2780) +- refactor(backend): separate events in own files [`#2777`](https://github.com/gradido/gradido/pull/2777) +- refactor(backend): rename `evenProtocolType` to `eventType` [`#2776`](https://github.com/gradido/gradido/pull/2776) +- refactor(other): add yarn installAll on gradido folder [`#2703`](https://github.com/gradido/gradido/pull/2703) +- docs(federation): describe the technical federation architecture [`#2716`](https://github.com/gradido/gradido/pull/2716) +- refactor(admin): admin list contributions for creation transaction list query [`#2791`](https://github.com/gradido/gradido/pull/2791) +- refactor(workflow): separate workflow with file filter for nginx testing [`#2871`](https://github.com/gradido/gradido/pull/2871) +- feat(backend): read communities data from database [`#2807`](https://github.com/gradido/gradido/pull/2807) +- feat(federation): implement a graphql endpoint to answer getpublickey-request [`#2651`](https://github.com/gradido/gradido/pull/2651) +- refactor(workflow): add file filters to dht node and federation workflows [`#2838`](https://github.com/gradido/gradido/pull/2838) +- refactor(workflow): separate test workflow for end-to-end tests [`#2836`](https://github.com/gradido/gradido/pull/2836) +- refactor(workflow): separate test workflow for frontend [`#2835`](https://github.com/gradido/gradido/pull/2835) +- feat(federation): add federation modul to deployment scripts [`#2733`](https://github.com/gradido/gradido/pull/2733) +- refactor(database): event table [`#2720`](https://github.com/gradido/gradido/pull/2720) +- refactor(workflow): separate test workflow with file change filters for admin interface [`#2734`](https://github.com/gradido/gradido/pull/2734) +- fix(admin): fix translation in menu (english) [`#2814`](https://github.com/gradido/gradido/pull/2814) +- refactor(workflow): configure jest to directly check coverage to schlanken the test workflows [`#2790`](https://github.com/gradido/gradido/pull/2790) +- fix(database): removed commands from package.json not working [`#2805`](https://github.com/gradido/gradido/pull/2805) +- fix(other): repair UserProfile.ChangePassword.feature scenario [`#2782`](https://github.com/gradido/gradido/pull/2782) +- feat(backend): test double redeem transaction links [`#2788`](https://github.com/gradido/gradido/pull/2788) +- feat(backend): admin open creations query [`#2813`](https://github.com/gradido/gradido/pull/2813) +- refactor(backend): eslint-plugin-type-graphql + fixes [`#2745`](https://github.com/gradido/gradido/pull/2745) + #### [1.19.1](https://github.com/gradido/gradido/compare/1.19.0...1.19.1) +> 10 March 2023 + +- chore(other): upgrade version to 1.19.1 [`#2812`](https://github.com/gradido/gradido/pull/2812) - fix(frontend): admin question clickable [`#2810`](https://github.com/gradido/gradido/pull/2810) - refactor(frontend): change b-img to b-icon send [`#2809`](https://github.com/gradido/gradido/pull/2809) - fix(admin): update openCreation in case of tab open. [`#2806`](https://github.com/gradido/gradido/pull/2806) diff --git a/admin/package.json b/admin/package.json index 3406c326a..04c9a60e8 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.19.1", + "version": "1.20.0", "license": "Apache-2.0", "private": false, "scripts": { @@ -33,6 +33,7 @@ "bootstrap": "4.3.1", "bootstrap-vue": "^2.21.2", "core-js": "^3.6.5", + "date-fns": "^2.29.3", "dotenv-webpack": "^7.0.3", "express": "^4.17.1", "graphql": "^15.6.1", diff --git a/admin/src/components/Fedaration/FederationVisualizeItem.spec.js b/admin/src/components/Fedaration/FederationVisualizeItem.spec.js new file mode 100644 index 000000000..6058cc6f4 --- /dev/null +++ b/admin/src/components/Fedaration/FederationVisualizeItem.spec.js @@ -0,0 +1,183 @@ +import { mount } from '@vue/test-utils' +import FederationVisualizeItem from './FederationVisualizeItem.vue' + +const localVue = global.localVue +const today = new Date() +const createdDate = new Date() +createdDate.setDate(createdDate.getDate() - 3) + +let propsData = { + item: { + id: 7590, + foreign: false, + publicKey: 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7', + url: 'http://localhost/api/2_0', + lastAnnouncedAt: createdDate, + verifiedAt: today, + lastErrorAt: null, + createdAt: createdDate, + updatedAt: null, + }, +} + +const mocks = { + $i18n: { + locale: 'en', + }, +} + +describe('FederationVisualizeItem', () => { + let wrapper + + const Wrapper = () => { + return mount(FederationVisualizeItem, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component', () => { + expect(wrapper.find('div.federation-visualize-item').exists()).toBe(true) + }) + + describe('rendering item properties', () => { + it('has the url', () => { + expect(wrapper.find('.row > div:nth-child(2) > div').text()).toBe( + 'http://localhost/api/2_0', + ) + }) + + it('has the public key', () => { + expect(wrapper.find('.row > div:nth-child(2) > small').text()).toContain( + 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7'.substring(0, 26), + ) + }) + + describe('verified item', () => { + it('has the check icon', () => { + expect(wrapper.find('svg.bi-check').exists()).toBe(true) + }) + + it('has the text variant "success"', () => { + expect(wrapper.find('.text-success').exists()).toBe(true) + }) + }) + + describe('not verified item', () => { + beforeEach(() => { + propsData = { + item: { + id: 7590, + foreign: false, + publicKey: 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7', + url: 'http://localhost/api/2_0', + lastAnnouncedAt: createdDate, + verifiedAt: null, + lastErrorAt: null, + createdAt: createdDate, + updatedAt: null, + }, + } + wrapper = Wrapper() + }) + + it('has the x-circle icon', () => { + expect(wrapper.find('svg.bi-x-circle').exists()).toBe(true) + }) + + it('has the text variant "danger"', () => { + expect(wrapper.find('.text-danger').exists()).toBe(true) + }) + }) + + // describe('with different locales (de, en, fr, es, nl)', () => { + describe('lastAnnouncedAt', () => { + it('computes the time string for different locales (de, en, fr, es, nl)', () => { + wrapper.vm.$i18n.locale = 'de' + wrapper = Wrapper() + expect(wrapper.vm.lastAnnouncedAt).toBe('vor 3 Tagen') + + wrapper.vm.$i18n.locale = 'fr' + wrapper = Wrapper() + expect(wrapper.vm.lastAnnouncedAt).toBe('il y a 3 jours') + + wrapper.vm.$i18n.locale = 'es' + wrapper = Wrapper() + expect(wrapper.vm.lastAnnouncedAt).toBe('hace 3 días') + + wrapper.vm.$i18n.locale = 'nl' + wrapper = Wrapper() + expect(wrapper.vm.lastAnnouncedAt).toBe('3 dagen geleden') + }) + + describe('lastAnnouncedAt == null', () => { + beforeEach(() => { + propsData = { + item: { + id: 7590, + foreign: false, + publicKey: 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7', + url: 'http://localhost/api/2_0', + lastAnnouncedAt: null, + verifiedAt: null, + lastErrorAt: null, + createdAt: createdDate, + updatedAt: null, + }, + } + wrapper = Wrapper() + }) + + it('computes empty string', async () => { + expect(wrapper.vm.lastAnnouncedAt).toBe('') + }) + }) + }) + + describe('createdAt', () => { + it('computes the time string for different locales (de, en, fr, es, nl)', () => { + wrapper.vm.$i18n.locale = 'de' + wrapper = Wrapper() + expect(wrapper.vm.createdAt).toBe('vor 3 Tagen') + + wrapper.vm.$i18n.locale = 'fr' + wrapper = Wrapper() + expect(wrapper.vm.createdAt).toBe('il y a 3 jours') + + wrapper.vm.$i18n.locale = 'es' + wrapper = Wrapper() + expect(wrapper.vm.createdAt).toBe('hace 3 días') + + wrapper.vm.$i18n.locale = 'nl' + wrapper = Wrapper() + expect(wrapper.vm.createdAt).toBe('3 dagen geleden') + }) + + describe('createdAt == null', () => { + beforeEach(() => { + propsData = { + item: { + id: 7590, + foreign: false, + publicKey: 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7', + url: 'http://localhost/api/2_0', + lastAnnouncedAt: createdDate, + verifiedAt: null, + lastErrorAt: null, + createdAt: null, + updatedAt: null, + }, + } + wrapper = Wrapper() + }) + + it('computes empty string', async () => { + expect(wrapper.vm.createdAt).toBe('') + }) + }) + }) + }) + }) +}) diff --git a/admin/src/components/Fedaration/FederationVisualizeItem.vue b/admin/src/components/Fedaration/FederationVisualizeItem.vue new file mode 100644 index 000000000..faace7da1 --- /dev/null +++ b/admin/src/components/Fedaration/FederationVisualizeItem.vue @@ -0,0 +1,63 @@ + + diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 1927f258c..6a4a69959 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -62,8 +62,12 @@ describe('NavBar', () => { ) }) + it('has a link to /federation', () => { + expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe('/federation') + }) + it('has a link to /statistic', () => { - expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe('/statistic') + expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe('/statistic') }) }) @@ -72,7 +76,7 @@ describe('NavBar', () => { beforeEach(async () => { delete window.location window.location = '' - await wrapper.findAll('.nav-item').at(4).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) afterEach(() => { @@ -97,7 +101,7 @@ describe('NavBar', () => { window.location = { assign: windowLocationMock, } - await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(6).find('a').trigger('click') }) afterEach(() => { diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index dae4bba91..2efeda048 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -1,6 +1,6 @@