diff --git a/.github/file-filters.yml b/.github/file-filters.yml index 2ae1bf9b4..80b7482d9 100644 --- a/.github/file-filters.yml +++ b/.github/file-filters.yml @@ -40,4 +40,7 @@ federation: &federation - 'federation/**/*' frontend: &frontend - - 'frontend/**/*' \ No newline at end of file + - 'frontend/**/*' + +nginx: &nginx + - 'nginx/**/*' \ No newline at end of file diff --git a/.github/workflows/test-nginx.yml b/.github/workflows/test-nginx.yml new file mode 100644 index 000000000..146e7a117 --- /dev/null +++ b/.github/workflows/test-nginx.yml @@ -0,0 +1,32 @@ +name: Gradido Nginx Test CI + +on: push + +jobs: + files-changed: + name: Detect File Changes - Nginx + runs-on: ubuntu-latest + outputs: + nginx: ${{ steps.changes.outputs.nginx }} + steps: + - uses: actions/checkout@v3.3.0 + + - name: Check for nginx 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_nginx: + name: Docker Build Test - Nginx + if: needs.files-changed.outputs.nginx == 'true' + needs: files-changed + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: nginx | Build 'test' image + run: docker build -t "gradido/nginx:test" nginx/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e5f0db02..0fcedb4ce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,31 +81,6 @@ jobs: name: docker-mariadb-test path: /tmp/mariadb.tar - ############################################################################## - # JOB: DOCKER BUILD TEST NGINX ############################################### - ############################################################################## - build_test_nginx: - name: Docker Build Test - Nginx - runs-on: ubuntu-latest - steps: - ########################################################################## - # CHECKOUT CODE ########################################################## - ########################################################################## - - name: Checkout code - uses: actions/checkout@v3 - ########################################################################## - # BUILD NGINX DOCKER IMAGE ############################################### - ########################################################################## - - name: nginx | Build `test` image - run: | - docker build -t "gradido/nginx:test" nginx/ - docker save "gradido/nginx:test" > /tmp/nginx.tar - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: docker-nginx-test - path: /tmp/nginx.tar - ############################################################################## # JOB: LINT BACKEND ########################################################## ############################################################################## diff --git a/README.md b/README.md index 3d086018e..87b4f44e5 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,11 @@ git clone git@github.com:gradido/gradido.git git submodule update --recursive --init ``` -### 2. Run docker-compose +### 2. Install modules + +You can go in each under folder (admin, frontend, database, backend, ...) and call ``yarn`` in each folder or you can call ``yarn installAll``. + +### 3. Run docker-compose Run docker-compose to bring up the development environment diff --git a/admin/src/components/CreationTransactionList.spec.js b/admin/src/components/CreationTransactionList.spec.js index 5950f7d62..e88d7cc22 100644 --- a/admin/src/components/CreationTransactionList.spec.js +++ b/admin/src/components/CreationTransactionList.spec.js @@ -1,43 +1,75 @@ import { mount } from '@vue/test-utils' import CreationTransactionList from './CreationTransactionList' import { toastErrorSpy } from '../../test/testSetup' +import VueApollo from 'vue-apollo' +import { createMockClient } from 'mock-apollo-client' +import { adminListContributions } from '../graphql/adminListContributions' + +const mockClient = createMockClient() +const apolloProvider = new VueApollo({ + defaultClient: mockClient, +}) const localVue = global.localVue +localVue.use(VueApollo) -const apolloQueryMock = jest.fn().mockResolvedValue({ - data: { - creationTransactionList: { +const defaultData = () => { + return { + adminListContributions: { contributionCount: 2, contributionList: [ { id: 1, - amount: 5.8, - createdAt: '2022-09-21T11:09:51.000Z', - confirmedAt: null, - contributionDate: '2022-08-01T00:00:00.000Z', - memo: 'für deine Hilfe, Fräulein Rottenmeier', + firstName: 'Bibi', + lastName: 'Bloxberg', + userId: 99, + email: 'bibi@bloxberg.de', + amount: 500, + memo: 'Danke für alles', + date: new Date(), + moderator: 1, state: 'PENDING', + creation: [500, 500, 500], + messagesCount: 0, + deniedBy: null, + deniedAt: null, + confirmedBy: null, + confirmedAt: null, + contributionDate: new Date(), + deletedBy: null, + deletedAt: null, + createdAt: new Date(), }, { id: 2, - amount: '47', - createdAt: '2022-09-21T11:09:28.000Z', - confirmedAt: '2022-09-21T11:09:28.000Z', - contributionDate: '2022-08-01T00:00:00.000Z', - memo: 'für deine Hilfe, Frau Holle', - state: 'CONFIRMED', + firstName: 'Räuber', + lastName: 'Hotzenplotz', + userId: 100, + email: 'raeuber@hotzenplotz.de', + amount: 1000000, + memo: 'Gut Ergattert', + date: new Date(), + moderator: 1, + state: 'PENDING', + creation: [500, 500, 500], + messagesCount: 0, + deniedBy: null, + deniedAt: null, + confirmedBy: null, + confirmedAt: new Date(), + contributionDate: new Date(), + deletedBy: null, + deletedAt: null, + createdAt: new Date(), }, ], }, - }, -}) + } +} const mocks = { $d: jest.fn((t) => t), $t: jest.fn((t) => t), - $apollo: { - query: apolloQueryMock, - }, } const propsData = { @@ -48,55 +80,53 @@ const propsData = { describe('CreationTransactionList', () => { let wrapper + const adminListContributionsMock = jest.fn() + mockClient.setRequestHandler( + adminListContributions, + adminListContributionsMock + .mockRejectedValueOnce({ message: 'Ouch!' }) + .mockResolvedValue({ data: defaultData() }), + ) + const Wrapper = () => { - return mount(CreationTransactionList, { localVue, mocks, propsData }) + return mount(CreationTransactionList, { localVue, mocks, propsData, apolloProvider }) } describe('mount', () => { beforeEach(() => { + jest.clearAllMocks() wrapper = Wrapper() }) - it('sends query to Apollo when created', () => { - expect(apolloQueryMock).toBeCalledWith( - expect.objectContaining({ - variables: { - currentPage: 1, - pageSize: 10, - order: 'DESC', - userId: 1, - }, - }), - ) - }) - - it('has two values for the transaction', () => { - expect(wrapper.find('tbody').findAll('tr').length).toBe(2) - }) - - describe('query transaction with error', () => { - beforeEach(() => { - apolloQueryMock.mockRejectedValue({ message: 'OUCH!' }) - wrapper = Wrapper() - }) - - it('calls the API', () => { - expect(apolloQueryMock).toBeCalled() - }) - + describe('server error', () => { it('toast error', () => { - expect(toastErrorSpy).toBeCalledWith('OUCH!') + expect(toastErrorSpy).toBeCalledWith('Ouch!') }) }) - describe('watch currentPage', () => { - beforeEach(async () => { - jest.clearAllMocks() - await wrapper.setData({ currentPage: 2 }) + describe('sever success', () => { + it('sends query to Apollo when created', () => { + expect(adminListContributionsMock).toBeCalledWith({ + currentPage: 1, + pageSize: 10, + order: 'DESC', + userId: 1, + }) }) - it('returns the string in normal order if reversed property is not true', () => { - expect(wrapper.vm.currentPage).toBe(2) + it('has two values for the transaction', () => { + expect(wrapper.find('tbody').findAll('tr').length).toBe(2) + }) + + describe('watch currentPage', () => { + beforeEach(async () => { + jest.clearAllMocks() + await wrapper.setData({ currentPage: 2 }) + }) + + it('returns the string in normal order if reversed property is not true', () => { + expect(wrapper.vm.currentPage).toBe(2) + }) }) }) }) diff --git a/admin/src/components/CreationTransactionList.vue b/admin/src/components/CreationTransactionList.vue index 950afcebc..a4849c87e 100644 --- a/admin/src/components/CreationTransactionList.vue +++ b/admin/src/components/CreationTransactionList.vue @@ -42,7 +42,7 @@