From d04fcc928024cd5274843c26f2be1ff81e4de436 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 25 Nov 2021 10:57:46 +0100 Subject: [PATCH 1/7] Document release --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index ead54701c..a5060ffef 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,21 @@ We are currently restructuring the service to reduce dependencies and unify busi Once you have `docker-compose` up and running, you can open [http://localhost/vue](http://localhost/vue) and create yourself a new wallet account. +## How to release + +A release is tagged on Github by its version number and published as github release. This is done automatically when a new version is defined in the [package.json](./package.json) and merged into master - furthermore we set all our sub-package-versions to the same version as the main package.json version to make version management as simple as possible. +Each release is accompanied with release notes automatically generated from the git log which is available as [CHANGELOG.md](./CHANGELOG.md). + +To generate the Changelog and set a new Version you should use the following commands in the main folder +```bash +git fetch --all +yarn release +``` + +The first command `git fetch --all` will make sure you have all tags previously defined which is required to generate a correct changelog. The second command `yarn release` will execute the changelog tool and set version numbers in the main package and sub-packages. It is required to do `yarn install` before you can use this command. +After generating a new version you should commit the changes. This will be the CHANGELOG.md and several package.json files. This commit will be omitted in the changelog. + +Note: The Changelog will be regenerated with all tags on release on the external builder tool, but will not be checked in there. The Changelog on the github release will therefore always be correct, on the repo it might be incorrect due to missing tags when executing the `yarn release` command. ## Troubleshooting | Problem | Issue | Solution | Description | From 995abc53be46aaaa8e281a213d69090a0cbbe0f3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 25 Nov 2021 11:00:03 +0100 Subject: [PATCH 2/7] missing newline --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a5060ffef..ce8e84df0 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ The first command `git fetch --all` will make sure you have all tags previously After generating a new version you should commit the changes. This will be the CHANGELOG.md and several package.json files. This commit will be omitted in the changelog. Note: The Changelog will be regenerated with all tags on release on the external builder tool, but will not be checked in there. The Changelog on the github release will therefore always be correct, on the repo it might be incorrect due to missing tags when executing the `yarn release` command. + ## Troubleshooting | Problem | Issue | Solution | Description | From 030c94acedd9db1054d534b646ce3d3cff9f5ac3 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 25 Nov 2021 11:03:25 +0100 Subject: [PATCH 3/7] add admin to the release script --- scripts/release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index d18c4948c..0b70e76ad 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -6,6 +6,7 @@ PROJECT_DIR="${SCRIPT_DIR}/../" FRONTEND_DIR="${PROJECT_DIR}/frontend/" BACKEND_DIR="${PROJECT_DIR}/backend/" DATABASE_DIR="${PROJECT_DIR}/database/" +ADMIN_DIR="${PROJECT_DIR}/admin/" # navigate to project directory cd ${PROJECT_DIR} @@ -23,6 +24,8 @@ cd ${BACKEND_DIR} yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version ${VERSION} cd ${DATABASE_DIR} yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version ${VERSION} +cd ${ADMIN_DIR} +yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version ${VERSION} # generate changelog cd ${PROJECT_DIR} From f9db04ef9678eaaf7e5d3fffe6ba62ad16176c3d Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 2 Dec 2021 13:17:42 +0100 Subject: [PATCH 4/7] fix: Catch Expired Session when Coming from Admin Interface --- frontend/src/routes/guards.js | 19 +++++++---- frontend/src/routes/guards.test.js | 55 +++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/guards.js b/frontend/src/routes/guards.js index 0788cb9d8..1838fa0fc 100644 --- a/frontend/src/routes/guards.js +++ b/frontend/src/routes/guards.js @@ -15,12 +15,19 @@ const addNavigationGuards = (router, store, apollo) => { router.beforeEach(async (to, from, next) => { if (to.path === '/authenticate' && to.query.token) { store.commit('token', to.query.token) - const result = await apollo.query({ - query: verifyLogin, - fetchPolicy: 'network-only', - }) - store.dispatch('login', result.data.verifyLogin) - next({ path: '/overview' }) + await apollo + .query({ + query: verifyLogin, + fetchPolicy: 'network-only', + }) + .then((result) => { + store.dispatch('login', result.data.verifyLogin) + next({ path: '/overview' }) + }) + .catch(() => { + store.dispatch('logout') + next() + }) } else { next() } diff --git a/frontend/src/routes/guards.test.js b/frontend/src/routes/guards.test.js index f271c5427..fa9f60f56 100644 --- a/frontend/src/routes/guards.test.js +++ b/frontend/src/routes/guards.test.js @@ -2,15 +2,28 @@ import addNavigationGuards from './guards' import router from './router' const storeCommitMock = jest.fn() +const storeDispatchMock = jest.fn() +const apolloQueryMock = jest.fn().mockResolvedValue({ + data: { + verifyLogin: { + firstName: 'Peter', + }, + }, +}) const store = { commit: storeCommitMock, state: { token: null, }, + dispatch: storeDispatchMock, } -addNavigationGuards(router, store) +const apollo = { + query: apolloQueryMock, +} + +addNavigationGuards(router, store, apollo) describe('navigation guards', () => { beforeEach(() => { @@ -29,6 +42,46 @@ describe('navigation guards', () => { }) }) + describe('authenticate', () => { + const navGuard = router.beforeHooks[1] + const next = jest.fn() + + describe('with valid token', () => { + beforeEach(() => { + navGuard({ path: '/authenticate', query: { token: 'valid-token' } }, {}, next) + }) + + it('commts the token to the store', () => { + expect(storeCommitMock).toBeCalledWith('token', 'valid-token') + }) + + it('calls verifyLogin', () => { + expect(apolloQueryMock).toBeCalled() + }) + + it('commits login to the store', () => { + expect(storeDispatchMock).toBeCalledWith('login', { firstName: 'Peter' }) + }) + }) + + describe('with valid token and server error', () => { + beforeEach(() => { + apolloQueryMock.mockRejectedValue({ + message: 'Ouch!', + }) + navGuard({ path: '/authenticate', query: { token: 'valid-token' } }, {}, next) + }) + + it('dispatches logout to store', () => { + expect(storeDispatchMock).toBeCalledWith('logout') + }) + + it('calls next', () => { + expect(next).toBeCalledWith() + }) + }) + }) + describe('authorization', () => { const navGuard = router.beforeHooks[2] const next = jest.fn() From 56079104b7ceb3bfe3b99ef51dc9b17206c9ddba Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 2 Dec 2021 13:18:26 +0100 Subject: [PATCH 5/7] frontend coverage to 87% --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index acff97d0e..cc273e991 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -399,7 +399,7 @@ jobs: report_name: Coverage Frontend type: lcov result_path: ./coverage/lcov.info - min_coverage: 86 + min_coverage: 87 token: ${{ github.token }} ############################################################################## From 3de0e67ea26f758edd43012cb36204470e490435 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 6 Dec 2021 15:26:12 +0100 Subject: [PATCH 6/7] fix and finish test for creation confirm delete --- admin/src/pages/CreationConfirm.spec.js | 82 +++++++++++++++++++++---- admin/src/pages/CreationConfirm.vue | 7 +-- 2 files changed, 71 insertions(+), 18 deletions(-) diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 86f90231b..90db3a93f 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -1,14 +1,17 @@ import { mount } from '@vue/test-utils' import CreationConfirm from './CreationConfirm.vue' +import { deletePendingCreation } from '../graphql/deletePendingCreation' const localVue = global.localVue const storeCommitMock = jest.fn() const toastedErrorMock = jest.fn() +const toastedSuccessMock = jest.fn() const apolloQueryMock = jest.fn().mockResolvedValue({ data: { getPendingCreations: [ { + id: 1, firstName: 'Bibi', lastName: 'Bloxberg', email: 'bibi@bloxberg.de', @@ -18,6 +21,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ moderator: 0, }, { + id: 2, firstName: 'Räuber', lastName: 'Hotzenplotz', email: 'raeuber@hotzenplotz.de', @@ -30,15 +34,19 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ }, }) +const apolloMutateMock = jest.fn().mockResolvedValue({}) + const mocks = { $store: { commit: storeCommitMock, }, $apollo: { query: apolloQueryMock, + mutate: apolloMutateMock, }, $toasted: { error: toastedErrorMock, + success: toastedSuccessMock, }, $moment: jest.fn((value) => { return { @@ -73,6 +81,68 @@ describe('CreationConfirm', () => { }) }) + describe('confirm creation delete with success', () => { + beforeEach(async () => { + apolloQueryMock.mockResolvedValue({ + data: { + getPendingCreations: [ + { + id: 1, + firstName: 'Bibi', + lastName: 'Bloxberg', + email: 'bibi@bloxberg.de', + amount: 500, + memo: 'Danke für alles', + date: new Date(), + moderator: 0, + }, + { + id: 2, + firstName: 'Räuber', + lastName: 'Hotzenplotz', + email: 'raeuber@hotzenplotz.de', + amount: 1000000, + memo: 'Gut Ergatert', + date: new Date(), + moderator: 0, + }, + ], + }, + }) + await wrapper + .findComponent({ name: 'UserTable' }) + .vm.$emit('remove-confirm-result', { id: 1 }, 'remove') + }) + + it('calls the deletePendingCreation mutation', () => { + expect(apolloMutateMock).toBeCalledWith({ + mutation: deletePendingCreation, + variables: { id: 1 }, + }) + }) + + it('commits openCreationsMinus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) + }) + + it('toasts a success message', () => { + expect(toastedSuccessMock).toBeCalledWith('Pending Creation has been deleted') + }) + }) + + describe('confirm creation delete with error', () => { + beforeEach(async () => { + apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' }) + await wrapper + .findComponent({ name: 'UserTable' }) + .vm.$emit('remove-confirm-result', { id: 1 }, 'remove') + }) + + it('toasts an error message', () => { + expect(toastedErrorMock).toBeCalledWith('Ouchhh!') + }) + }) + describe('server response is error', () => { beforeEach(() => { jest.clearAllMocks() @@ -86,17 +156,5 @@ describe('CreationConfirm', () => { expect(toastedErrorMock).toBeCalledWith('Ouch!') }) }) - - describe('confirm creation', () => { - beforeEach(async () => { - await wrapper - .findComponent({ name: 'UserTable' }) - .vm.$emit('remove-confirm-result', 1, 'remove') - }) - - it('commits openCreationsMinus to store', () => { - expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) - }) - }) }) }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index d8094ca69..42ff6da50 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -49,16 +49,11 @@ export default { confirmResult: [], } }, - methods: { removeConfirmResult(e, event) { if (event === 'remove') { let index = 0 - let findArr = {} - - findArr = this.confirmResult.find((arr) => arr.id === e.id) - - // console.log('findArr', findArr) + const findArr = this.confirmResult.find((arr) => arr.id === e.id) this.$apollo .mutate({ mutation: deletePendingCreation, From 009fc78c2989622a00941a5babe5966c666b34db Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 6 Dec 2021 15:27:10 +0100 Subject: [PATCH 7/7] coverage tests admin interface to 55% --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a28680279..602732797 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -441,7 +441,7 @@ jobs: report_name: Coverage Admin Interface type: lcov result_path: ./coverage/lcov.info - min_coverage: 53 + min_coverage: 55 token: ${{ github.token }} ##############################################################################