diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e55ba47e..b3c15ddea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -373,8 +373,8 @@ jobs: with: report_name: Coverage Admin Interface type: lcov - result_path: ./admin/coverage/lcov.info - min_coverage: 96 + result_path: ./coverage/lcov.info + min_coverage: 97 token: ${{ github.token }} ############################################################################## @@ -454,7 +454,7 @@ jobs: end-to-end-tests: name: End-to-End Tests runs-on: ubuntu-latest - needs: [build_test_mariadb, build_test_database_up, build_test_backend, build_test_admin, build_test_frontend, build_test_nginx] + needs: [build_test_mariadb, build_test_database_up, build_test_admin, build_test_frontend, build_test_nginx] steps: ########################################################################## # CHECKOUT CODE ########################################################## @@ -478,13 +478,6 @@ jobs: path: /tmp - name: Load Docker Image (Database Up) run: docker load < /tmp/database_up.tar - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image (Backend) - run: docker load < /tmp/backend.tar - name: Download Docker Image (Frontend) uses: actions/download-artifact@v3 with: @@ -517,7 +510,11 @@ jobs: run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database - name: Boot up test system | docker-compose backend - run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps backend + run: | + cd backend + cp .env.test_e2e .env + cd .. + docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps backend - name: Sleep for 10 seconds run: sleep 10s @@ -534,6 +531,9 @@ jobs: - name: Boot up test system | docker-compose frontends run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps frontend admin nginx + - name: Boot up test system | docker-compose mailserver + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mailserver + - name: Sleep for 15 seconds run: sleep 15s @@ -543,12 +543,12 @@ jobs: - name: End-to-end tests | run tests id: e2e-tests run: | - cd e2e-tests/cypress/tests/ + cd e2e-tests/ yarn - yarn run cypress run --spec cypress/e2e/User.Authentication.feature + yarn run cypress run --spec cypress/e2e/User.Authentication.feature,cypress/e2e/User.Authentication.ResetPassword.feature - name: End-to-end tests | if tests failed, upload screenshots - if: steps.e2e-tests.outcome == 'failure' + if: ${{ failure() && steps.e2e-tests.conclusion == 'failure' }} uses: actions/upload-artifact@v3 with: name: cypress-screenshots - path: /home/runner/work/gradido/gradido/e2e-tests/cypress/tests/cypress/screenshots/ + path: /home/runner/work/gradido/gradido/e2e-tests/cypress/screenshots/ diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml new file mode 100644 index 000000000..2da78758e --- /dev/null +++ b/.github/workflows/test_federation.yml @@ -0,0 +1,98 @@ +name: gradido test_federation CI + +on: push + +jobs: + ############################################################################## + # JOB: DOCKER BUILD TEST ##################################################### + ############################################################################## + build: + name: Docker Build Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build `test` image + run: | + docker build --target test -t "gradido/federation:test" -f federation/Dockerfile . + docker save "gradido/federation:test" > /tmp/federation.tar + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: docker-federation-test + path: /tmp/federation.tar + + ############################################################################## + # JOB: LINT ################################################################## + ############################################################################## + lint: + name: Lint + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Docker Image + uses: actions/download-artifact@v3 + with: + name: docker-federation-test + path: /tmp + - name: Load Docker Image + run: docker load < /tmp/federation.tar + + - name: Lint + run: docker run --rm gradido/federation:test yarn run lint + + ############################################################################## + # JOB: UNIT TEST ############################################################# + ############################################################################## + unit_test: + name: Unit tests + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download Docker Image + uses: actions/download-artifact@v3 + with: + name: docker-federation-test + path: /tmp + + - name: Load Docker Image + run: docker load < /tmp/federation.tar + + - name: 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: docker-compose database + run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database + + - name: Sleep for 30 seconds + run: sleep 30s + shell: bash + + #- name: Unit tests + # run: cd database && yarn && yarn build && cd ../dht-node && yarn && yarn test + - name: Unit tests + run: | + docker run --env NODE_ENV=test --env DB_HOST=mariadb --network gradido_internal-net -v ~/coverage:/app/coverage --rm gradido/federation:test yarn run test + cp -r ~/coverage ./coverage + + - name: Coverage check + uses: webcraftmedia/coverage-check-action@master + with: + report_name: Coverage federation + type: lcov + #result_path: ./federation/coverage/lcov.info + result_path: ./coverage/lcov.info + min_coverage: 72 + token: ${{ github.token }} diff --git a/admin/src/components/ContributionLink/ContributionLink.spec.js b/admin/src/components/ContributionLink/ContributionLink.spec.js index e0f09f9fd..461027e64 100644 --- a/admin/src/components/ContributionLink/ContributionLink.spec.js +++ b/admin/src/components/ContributionLink/ContributionLink.spec.js @@ -42,29 +42,72 @@ describe('ContributionLink', () => { expect(wrapper.find('div.contribution-link').exists()).toBe(true) }) - describe('function editContributionLinkData', () => { - beforeEach(() => { - wrapper.vm.editContributionLinkData() + it('has one contribution link in table', () => { + expect(wrapper.find('div.contribution-link-list').find('tbody').findAll('tr')).toHaveLength(1) + }) + + it('has contribution form not visible by default', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(false) + }) + + describe('click on create new contribution', () => { + beforeEach(async () => { + await wrapper.find('[data-test="new-contribution-link-button"]').trigger('click') }) - it('emits toggle::collapse new Contribution', async () => { - await expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + + it('shows the contribution form', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(true) + }) + + describe('click on create new contribution again', () => { + beforeEach(async () => { + await wrapper.find('[data-test="new-contribution-link-button"]').trigger('click') + }) + + it('closes the contribution form', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(false) + }) + }) + + describe('click on close button', () => { + beforeEach(async () => { + await wrapper.find('button.btn-secondary').trigger('click') + }) + + it('closes the contribution form', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(false) + }) }) }) - describe('function closeContributionForm', () => { + describe('edit contribution link', () => { beforeEach(async () => { - await wrapper.setData({ visible: true }) - wrapper.vm.closeContributionForm() + await wrapper + .find('div.contribution-link-list') + .find('tbody') + .findAll('tr') + .at(0) + .findAll('button') + .at(1) + .trigger('click') }) - it('emits toggle::collapse close Contribution-Form ', async () => { - await expect(wrapper.vm.$root.$emit('bv::toggle::collapse', 'newContribution')).toBeTruthy() + it('shows the contribution form', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(true) }) - it('editContributionLink is false', async () => { - await expect(wrapper.vm.editContributionLink).toBe(false) + + it('does not show the new contribution button', () => { + expect(wrapper.find('[data-test="new-contribution-link-button"]').exists()).toBe(false) }) - it('contributionLinkData is empty', async () => { - await expect(wrapper.vm.contributionLinkData).toEqual({}) + + describe('click on close button', () => { + beforeEach(async () => { + await wrapper.find('button.btn-secondary').trigger('click') + }) + + it('closes the contribution form', () => { + expect(wrapper.find('#newContribution').isVisible()).toBe(false) + }) }) }) }) diff --git a/admin/src/components/ContributionLink/ContributionLink.vue b/admin/src/components/ContributionLink/ContributionLink.vue index ca82fcd42..b369386b1 100644 --- a/admin/src/components/ContributionLink/ContributionLink.vue +++ b/admin/src/components/ContributionLink/ContributionLink.vue @@ -10,8 +10,9 @@ > {{ $t('math.plus') }} {{ $t('contributionLink.newContributionLink') }} diff --git a/admin/src/components/ContributionLink/ContributionLinkList.vue b/admin/src/components/ContributionLink/ContributionLinkList.vue index f67feced2..9d8977d04 100644 --- a/admin/src/components/ContributionLink/ContributionLinkList.vue +++ b/admin/src/components/ContributionLink/ContributionLinkList.vue @@ -70,8 +70,6 @@ export default { formatter: (value, key, item) => { if (value) { return this.$d(new Date(value)) - } else { - return null } }, }, @@ -81,8 +79,6 @@ export default { formatter: (value, key, item) => { if (value) { return this.$d(new Date(value)) - } else { - return null } }, }, diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 96b7cba9c..61f126904 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -68,13 +68,23 @@ describe('NavBar', () => { }) describe('wallet', () => { - const assignLocationSpy = jest.fn() + const windowLocationMock = jest.fn() + const windowLocation = window.location beforeEach(async () => { + delete window.location + window.location = { + assign: windowLocationMock, + } await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) + afterEach(() => { + delete window.location + window.location = windowLocation + }) + it.skip('changes window location to wallet', () => { - expect(assignLocationSpy).toBeCalledWith('valid-token') + expect(windowLocationMock()).toBe('valid-token') }) it('dispatches logout to store', () => { @@ -84,6 +94,7 @@ describe('NavBar', () => { describe('logout', () => { const windowLocationMock = jest.fn() + const windowLocation = window.location beforeEach(async () => { delete window.location window.location = { @@ -92,6 +103,11 @@ describe('NavBar', () => { await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) + afterEach(() => { + delete window.location + window.location = windowLocation + }) + it('redirects to /logout', () => { expect(windowLocationMock).toBeCalledWith('http://localhost/login') }) diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index f8bc2b280..7e2b7d76f 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -10,12 +10,11 @@ {{ $t('navbar.user_search') }} - - {{ $store.state.openCreations }} {{ $t('navbar.open_creation') }} + + {{ $t('creation') }} + + {{ $store.state.openCreations }} + {{ $t('navbar.automaticContributions') }} @@ -55,7 +54,4 @@ export default { height: 2rem; padding-left: 10px; } -.bg-color-creation { - background-color: #cf1010dc; -} diff --git a/admin/src/components/Overlay.vue b/admin/src/components/Overlay.vue index 84271a422..7eb3cf99f 100644 --- a/admin/src/components/Overlay.vue +++ b/admin/src/components/Overlay.vue @@ -13,7 +13,8 @@ {{ $t('creation_for_month') }} - {{ $d(new Date(item.date), 'month') }} {{ $d(new Date(item.date), 'year') }} + {{ $d(new Date(item.contributionDate), 'month') }} + {{ $d(new Date(item.contributionDate), 'year') }} diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index d141fc0a5..faaf3a69d 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -1,6 +1,17 @@