From 7e48e4f8509e0e958e0539d35f00e4f461207e08 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 19 Oct 2021 00:08:52 +0200 Subject: [PATCH] full test for communities, another try for docker compose --- .github/workflows/test.yml | 2 +- .../resolver/CommunityResolver.test.ts | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1060eb9d7..c93c75f3a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -383,7 +383,7 @@ jobs: - name: backend | docker-compose run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database backend - name: backend Unit tests | up - run: docker-compose exec -T backend yarn run test + run: docker-compose exec -T backend yarn test ########################################################################## # COVERAGE CHECK BACKEND ################################################# ########################################################################## diff --git a/backend/src/graphql/resolver/CommunityResolver.test.ts b/backend/src/graphql/resolver/CommunityResolver.test.ts index e1556b9fc..9fb062f31 100644 --- a/backend/src/graphql/resolver/CommunityResolver.test.ts +++ b/backend/src/graphql/resolver/CommunityResolver.test.ts @@ -3,6 +3,9 @@ import { createTestClient } from 'apollo-server-testing' import createServer from '../../server/createServer' +import CONFIG from '../../config' + +jest.mock('../../config') let query: any @@ -24,6 +27,18 @@ describe('CommunityResolver', () => { } ` + const communities = ` + query { + communities { + id + name + url + description + registerUrl + } + } + ` + describe('getCommunityInfo', () => { it('returns the default values', async () => { expect(query({ query: getCommunityInfoQuery })).resolves.toMatchObject({ @@ -38,4 +53,64 @@ describe('CommunityResolver', () => { }) }) }) + + describe('communities', () => { + describe('PRODUCTION = false', () => { + beforeEach(() => { + CONFIG.PRODUCTION = false + }) + + it('returns three communities', async () => { + expect(query({ query: communities })).resolves.toMatchObject({ + data: { + communities: [ + { + id: 1, + name: 'Gradido Entwicklung', + description: 'Die lokale Entwicklungsumgebung von Gradido.', + url: 'http://localhost/vue/', + registerUrl: 'http://localhost/vue/register-community', + }, + { + id: 2, + name: 'Gradido Staging', + description: 'Der Testserver der Gradido-Akademie.', + url: 'https://stage1.gradido.net/vue/', + registerUrl: 'https://stage1.gradido.net/vue/register-community', + }, + { + id: 3, + name: 'Gradido-Akademie', + description: 'Freies Institut für Wirtschaftsbionik.', + url: 'https://gradido.net', + registerUrl: 'https://gdd1.gradido.com/vue/register-community', + }, + ], + }, + }) + }) + }) + + describe('PRODUCTION = true', () => { + beforeEach(() => { + CONFIG.PRODUCTION = true + }) + + it('returns one community', async () => { + expect(query({ query: communities })).resolves.toMatchObject({ + data: { + communities: [ + { + id: 3, + name: 'Gradido-Akademie', + description: 'Freies Institut für Wirtschaftsbionik.', + url: 'https://gradido.net', + registerUrl: 'https://gdd1.gradido.com/vue/register-community', + }, + ], + }, + }) + }) + }) + }) })