-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persisting created new campaignApplication to db (#657)
* finish create functionality and testing on it update CampaignApplication model - organizerEmail now is not unique update create method testing now created campaig-application data is persisted to db * finish create functionality and testing on it update CampaignApplication model - organizerEmail now is not unique update create method testing now created campaig-application data is persisted to db * restructured mocking of data in service.spec and controller.spec * finish mocking data changes * updated controller,spec mockis * fix module providers * hardcoded testing values * delete unused imports & recover unit test * remove campaingApplication data sanitization * importing moduls instead of providing services delete PersonService and OrganizerService and add PersonModule and OrganizersModule to campaign-application module
- Loading branch information
Showing
12 changed files
with
373 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { KeycloakTokenParsed } from './keycloak' | ||
|
||
export const mockUser = { | ||
exp: 1719866987, | ||
iat: 1719866687, | ||
jti: '607c488f-6e18-4455-8384-161cec4f1940', | ||
iss: 'http://localhost:8180/auth/realms/webapp', | ||
aud: 'account', | ||
sub: '5795ea9e-ac11-436b-b97d-7b03dbd863f2', | ||
typ: 'Bearer', | ||
azp: 'jwt-headless', | ||
session_state: 'def317ff-0043-4509-ade3-926dd155085e', | ||
'allowed-origins': ['*'], | ||
realm_access: { roles: ['default-roles-webapp', 'offline_access', 'uma_authorization'] }, | ||
resource_access: { | ||
account: { roles: ['manage-account', 'manage-account-links', 'view-profile'] }, | ||
}, | ||
scope: 'openid profile email', | ||
sid: 'def317ff-0043-4509-ade3-926dd155085e', | ||
email_verified: 'true', | ||
name: 'asdasd sdfsdfsdfs', | ||
preferred_username: '[email protected]', | ||
given_name: 'asdasd', | ||
family_name: 'sdfsdfsdfs', | ||
email: '[email protected]', | ||
} as KeycloakTokenParsed | ||
|
||
export const mockUserAdmin = { | ||
exp: 1719866987, | ||
iat: 1719866687, | ||
jti: '607c488f-6e18-4455-8384-161cec4f1940', | ||
iss: 'http://localhost:8180/auth/realms/webapp', | ||
aud: 'account', | ||
sub: '5795ea9e-ac11-436b-b97d-7b03dbd863f2', | ||
typ: 'Bearer', | ||
azp: 'jwt-headless', | ||
session_state: 'def317ff-0043-4509-ade3-926dd155085e', | ||
'allowed-origins': ['*'], | ||
realm_access: { roles: ['default-roles-webapp', 'offline_access', 'uma_authorization'] }, | ||
resource_access: { account: { roles: ['manage-account', 'account-view-supporters'] } }, | ||
scope: 'openid profile email', | ||
sid: 'def317ff-0043-4509-ade3-926dd155085e', | ||
email_verified: 'true', | ||
name: 'asdasd sdfsdfsdfs', | ||
preferred_username: '[email protected]', | ||
given_name: 'asdasd', | ||
family_name: 'sdfsdfsdfs', | ||
email: '[email protected]', | ||
} as KeycloakTokenParsed |
87 changes: 87 additions & 0 deletions
87
apps/api/src/campaign-application/__mocks__/campaign-application-mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { CampaignApplicationState, CampaignTypeCategory } from '@prisma/client' | ||
import { CreateCampaignApplicationDto } from '../dto/create-campaign-application.dto' | ||
|
||
export const mockNewCampaignApplication = { | ||
campaignName: 'Test Campaign', | ||
organizerName: 'Test Organizer', | ||
organizerEmail: '[email protected]', | ||
organizerPhone: '123456789', | ||
beneficiary: 'Test beneficary', | ||
organizerBeneficiaryRel: 'Test organizerBeneficiaryRel', | ||
goal: 'Test goal', | ||
history: 'Test history', | ||
amount: '1000', | ||
description: 'Test description', | ||
campaignGuarantee: 'Test guarantee', | ||
otherFinanceSources: 'Test otherFinanceSources', | ||
otherNotes: 'Test otherNotes', | ||
category: CampaignTypeCategory.medical, | ||
} | ||
|
||
const dto: CreateCampaignApplicationDto = { | ||
...mockNewCampaignApplication, | ||
acceptTermsAndConditions: true, | ||
transparencyTermsAccepted: true, | ||
personalInformationProcessingAccepted: true, | ||
toEntity: new CreateCampaignApplicationDto().toEntity, | ||
} | ||
|
||
export const mockCampaigns = [ | ||
{ | ||
id: '1', | ||
createdAt: new Date('2022-04-08T06:36:33.661Z'), | ||
updatedAt: new Date('2022-04-08T06:36:33.662Z'), | ||
description: 'Test description1', | ||
organizerId: 'testOrganizerId1', | ||
organizerName: 'Test Organizer1', | ||
organizerEmail: '[email protected]', | ||
beneficiary: 'test beneficary1', | ||
organizerPhone: '123456789', | ||
organizerBeneficiaryRel: 'Test Relation1', | ||
campaignName: 'Test Campaign1', | ||
goal: 'Test Goal1', | ||
history: 'test history1', | ||
amount: '1000', | ||
campaignGuarantee: 'test campaignGuarantee1', | ||
otherFinanceSources: 'test otherFinanceSources1', | ||
otherNotes: 'test otherNotes1', | ||
state: CampaignApplicationState.review, | ||
category: CampaignTypeCategory.medical, | ||
ticketURL: 'testsodifhso1', | ||
archived: false, | ||
}, | ||
{ | ||
id: '2', | ||
createdAt: new Date('2022-04-08T06:36:33.661Z'), | ||
updatedAt: new Date('2022-04-08T06:36:33.662Z'), | ||
description: 'Test description2', | ||
organizerId: 'testOrganizerId2', | ||
organizerName: 'Test Organizer2', | ||
organizerEmail: '[email protected]', | ||
beneficiary: 'test beneficary2', | ||
organizerPhone: '123456789', | ||
organizerBeneficiaryRel: 'Test Relation2', | ||
campaignName: 'Test Campaign2', | ||
goal: 'Test Goal2', | ||
history: 'test history2', | ||
amount: '1000', | ||
campaignGuarantee: 'test campaignGuarantee2', | ||
otherFinanceSources: 'test otherFinanceSources2', | ||
otherNotes: 'test otherNotes2', | ||
state: CampaignApplicationState.review, | ||
category: CampaignTypeCategory.medical, | ||
ticketURL: 'testsodifhso2', | ||
archived: false, | ||
}, | ||
] | ||
|
||
export const mockCreatedCampaignApplication = { | ||
id: 'mockCampaignApplicationId', | ||
createdAt: new Date('2022-04-08T06:36:33.661Z'), | ||
updatedAt: new Date('2022-04-08T06:36:33.662Z'), | ||
...mockNewCampaignApplication, | ||
organizerId: 'mockOrganizerId', | ||
state: CampaignApplicationState.review, | ||
ticketURL: null, | ||
archived: false, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 29 additions & 6 deletions
35
apps/api/src/campaign-application/campaign-application.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.