@stamhoofd/backend 2.39.1 → 2.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.mjs +5 -0
- package/index.ts +81 -74
- package/jest.config.cjs +10 -0
- package/migrations.ts +16 -14
- package/package.json +11 -11
- package/src/crons/clear-excel-cache.test.ts +48 -50
- package/src/crons/clear-excel-cache.ts +18 -18
- package/src/crons/setup-steps.ts +2 -2
- package/src/crons.ts +325 -306
- package/src/decoders/StringArrayDecoder.ts +7 -7
- package/src/decoders/StringNullableDecoder.ts +1 -2
- package/src/email-recipient-loaders/members.ts +22 -22
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +8 -9
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +39 -40
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +8 -8
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +44 -45
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +58 -57
- package/src/endpoints/auth/CreateAdminEndpoint.ts +48 -45
- package/src/endpoints/auth/CreateTokenEndpoint.test.ts +31 -31
- package/src/endpoints/auth/CreateTokenEndpoint.ts +146 -147
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +7 -7
- package/src/endpoints/auth/DeleteUserEndpoint.ts +15 -15
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +17 -18
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +9 -10
- package/src/endpoints/auth/GetUserEndpoint.test.ts +32 -35
- package/src/endpoints/auth/GetUserEndpoint.ts +5 -6
- package/src/endpoints/auth/PatchApiUserEndpoint.ts +35 -33
- package/src/endpoints/auth/PatchUserEndpoint.ts +55 -52
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +9 -9
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +8 -8
- package/src/endpoints/auth/SignupEndpoint.ts +37 -36
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +29 -28
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +33 -33
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +7 -7
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +37 -37
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +30 -30
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +13 -13
- package/src/endpoints/global/email/GetEmailEndpoint.ts +13 -13
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +16 -16
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +25 -25
- package/src/endpoints/global/events/GetEventsEndpoint.ts +43 -44
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +127 -172
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +49 -50
- package/src/endpoints/global/files/GetFileCache.ts +13 -13
- package/src/endpoints/global/files/UploadFile.ts +51 -54
- package/src/endpoints/global/files/UploadImage.ts +53 -53
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +25 -25
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +24 -23
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +8 -8
- package/src/endpoints/global/members/GetMembersEndpoint.ts +105 -102
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +240 -239
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +12 -14
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +32 -33
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +48 -57
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +21 -22
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +28 -28
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +18 -18
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +20 -20
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +17 -17
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +81 -75
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +14 -14
- package/src/endpoints/global/platform/GetPlatformEnpoint.ts +11 -11
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +71 -68
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +27 -27
- package/src/endpoints/global/registration/GetUserBillingStatusEndpoint.ts +30 -30
- package/src/endpoints/global/registration/GetUserDetailedBillingStatusEndpoint.ts +34 -34
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +26 -26
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +12 -12
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +90 -90
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +118 -121
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +362 -350
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +8 -9
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +21 -21
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +65 -65
- package/src/endpoints/organization/dashboard/billing/GetOrganizationBillingStatusEndpoint.ts +9 -9
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedBillingStatusEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +17 -17
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +21 -21
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +52 -52
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplateEndpoint.ts +37 -37
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/email/EmailEndpoint.ts +113 -112
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +29 -29
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +48 -47
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +22 -21
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +13 -14
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +12 -13
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +10 -12
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +14 -14
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +13 -13
- package/src/endpoints/organization/dashboard/organization/GetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +120 -124
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +172 -173
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +88 -89
- package/src/endpoints/organization/dashboard/organization/SetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +17 -17
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +8 -8
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +66 -67
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +47 -47
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +93 -91
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +16 -17
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +170 -167
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +25 -24
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +22 -23
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +22 -22
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +8 -9
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +14 -15
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +103 -100
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +11 -12
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +23 -23
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +54 -52
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +84 -81
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +120 -111
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +141 -130
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +25 -25
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +36 -37
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +9 -9
- package/src/endpoints/organization/shared/auth/OpenIDConnectCallbackEndpoint.ts +11 -11
- package/src/endpoints/organization/shared/auth/OpenIDConnectStartEndpoint.ts +28 -27
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +20 -20
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +22 -22
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +14 -14
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +57 -56
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +65 -66
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +18 -17
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +124 -128
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +154 -145
- package/src/excel-loaders/members.ts +275 -273
- package/src/excel-loaders/payments.ts +155 -156
- package/src/helpers/AddressValidator.test.ts +32 -32
- package/src/helpers/AddressValidator.ts +128 -122
- package/src/helpers/AdminPermissionChecker.ts +339 -236
- package/src/helpers/AuthenticatedStructures.ts +233 -134
- package/src/helpers/BuckarooHelper.ts +134 -134
- package/src/helpers/CheckSettlements.ts +94 -88
- package/src/helpers/Context.ts +87 -86
- package/src/helpers/CookieHelper.ts +23 -22
- package/src/helpers/EmailResumer.ts +10 -10
- package/src/helpers/FileCache.ts +62 -62
- package/src/helpers/ForwardHandler.test.ts +122 -124
- package/src/helpers/ForwardHandler.ts +76 -70
- package/src/helpers/MemberUserSyncer.ts +101 -96
- package/src/helpers/MembershipCharger.ts +69 -69
- package/src/helpers/MembershipHelper.ts +11 -12
- package/src/helpers/OpenIDConnectHelper.ts +85 -82
- package/src/helpers/PeriodHelper.ts +65 -70
- package/src/helpers/StripeHelper.ts +146 -137
- package/src/helpers/StripePayoutChecker.ts +51 -52
- package/src/helpers/ViesHelper.ts +46 -44
- package/src/helpers/fetchToAsyncIterator.ts +14 -14
- package/src/helpers/xlsxAddressTransformerColumnFactory.ts +58 -60
- package/src/middleware/ContextMiddleware.ts +5 -5
- package/src/migrations/1646578856-validate-addresses.ts +6 -9
- package/src/seeds/0000000000-example.ts +3 -5
- package/src/seeds/1715028563-user-permissions.ts +16 -18
- package/src/seeds/1722256498-group-update-occupancy.ts +12 -12
- package/src/seeds/1722344162-sync-member-users.ts +14 -15
- package/src/seeds/1722344162-update-membership.ts +6 -6
- package/src/seeds/1726055544-balance-item-paid.ts +4 -4
- package/src/seeds/1726055545-balance-item-pending.ts +4 -4
- package/src/seeds/1726494419-update-cached-outstanding-balance.ts +16 -16
- package/src/seeds/1726494420-update-cached-outstanding-balance-from-items.ts +12 -12
- package/src/seeds/1726572303-schedule-stock-updates.ts +12 -12
- package/src/seeds/1726847064-setup-steps.ts +16 -0
- package/src/sql-filters/balance-item-payments.ts +7 -7
- package/src/sql-filters/events.ts +14 -14
- package/src/sql-filters/members.ts +96 -96
- package/src/sql-filters/organizations.ts +139 -75
- package/src/sql-filters/payments.ts +28 -28
- package/src/sql-filters/registrations.ts +14 -14
- package/src/sql-sorters/events.ts +25 -25
- package/src/sql-sorters/members.ts +26 -26
- package/src/sql-sorters/organizations.ts +36 -36
- package/src/sql-sorters/payments.ts +26 -26
- package/tests/e2e/stock.test.ts +616 -621
- package/tests/e2e/tickets.test.ts +255 -260
- package/tests/helpers/StripeMocker.ts +177 -179
- package/tests/helpers/TestServer.ts +9 -9
- package/tests/jest.global.setup.ts +14 -13
- package/tests/jest.setup.ts +33 -32
- package/.eslintrc.js +0 -61
- package/jest.config.js +0 -11
- package/src/helpers/SetupStepsUpdater.ts +0 -359
- package/src/seeds/1724076679-setup-steps.ts +0 -16
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Request } from
|
|
2
|
-
import { Group, GroupFactory, MemberFactory, MemberWithRegistrations, Organization, OrganizationFactory, RegistrationFactory, RegistrationPeriod, RegistrationPeriodFactory, Token, User, UserFactory } from
|
|
3
|
-
import { GroupPrice, IDRegisterCart, IDRegisterCheckout, IDRegisterItem, PayconiqAccount, PaymentMethod, PermissionLevel, Permissions, Version } from
|
|
4
|
-
import nock from
|
|
5
|
-
import { v4 as uuidv4 } from
|
|
6
|
-
import { testServer } from
|
|
7
|
-
import { RegisterMembersEndpoint } from
|
|
8
|
-
|
|
9
|
-
const baseUrl = `/v${Version}/members/register
|
|
10
|
-
|
|
11
|
-
describe(
|
|
12
|
-
|
|
1
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Group, GroupFactory, MemberFactory, MemberWithRegistrations, Organization, OrganizationFactory, RegistrationFactory, RegistrationPeriod, RegistrationPeriodFactory, Token, User, UserFactory } from '@stamhoofd/models';
|
|
3
|
+
import { GroupPrice, IDRegisterCart, IDRegisterCheckout, IDRegisterItem, PayconiqAccount, PaymentMethod, PermissionLevel, Permissions, Version } from '@stamhoofd/structures';
|
|
4
|
+
import nock from 'nock';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import { testServer } from '../../../../tests/helpers/TestServer';
|
|
7
|
+
import { RegisterMembersEndpoint } from './RegisterMembersEndpoint';
|
|
8
|
+
|
|
9
|
+
const baseUrl = `/v${Version}/members/register`;
|
|
10
|
+
|
|
11
|
+
describe('Endpoint.RegisterMembers', () => {
|
|
12
|
+
// #region global
|
|
13
13
|
const endpoint = new RegisterMembersEndpoint();
|
|
14
14
|
let period: RegistrationPeriod;
|
|
15
15
|
let organization: Organization;
|
|
@@ -21,21 +21,21 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
21
21
|
let group2: Group;
|
|
22
22
|
let groupPrice2: GroupPrice;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// #region helpers
|
|
25
25
|
const post = async (body: IDRegisterCheckout) => {
|
|
26
|
-
const request = Request.buildJson(
|
|
27
|
-
request.headers.authorization =
|
|
26
|
+
const request = Request.buildJson('POST', baseUrl, organization.getApiHost(), body);
|
|
27
|
+
request.headers.authorization = 'Bearer ' + token.accessToken;
|
|
28
28
|
return await testServer.test(endpoint, request);
|
|
29
|
-
}
|
|
30
|
-
|
|
29
|
+
};
|
|
30
|
+
// #endregion
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// #endregion
|
|
33
33
|
|
|
34
34
|
beforeAll(async () => {
|
|
35
35
|
period = await new RegistrationPeriodFactory({}).create();
|
|
36
36
|
organization = await new OrganizationFactory({ period }).create();
|
|
37
37
|
organization.meta.registrationPaymentConfiguration.paymentMethods = [PaymentMethod.PointOfSale, PaymentMethod.Payconiq];
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
organization.privateMeta.payconiqAccounts = [PayconiqAccount.create({
|
|
40
40
|
id: uuidv4(),
|
|
41
41
|
apiKey: 'test',
|
|
@@ -43,25 +43,25 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
43
43
|
profileId: 'test',
|
|
44
44
|
name: 'test',
|
|
45
45
|
iban: 'BE56587127952688', // = random IBAN
|
|
46
|
-
callbackUrl: 'https://example.com'
|
|
47
|
-
})]
|
|
46
|
+
callbackUrl: 'https://example.com',
|
|
47
|
+
})];
|
|
48
48
|
|
|
49
49
|
user = await new UserFactory({
|
|
50
50
|
organization,
|
|
51
51
|
permissions: Permissions.create({
|
|
52
|
-
level: PermissionLevel.Full
|
|
53
|
-
})
|
|
52
|
+
level: PermissionLevel.Full,
|
|
53
|
+
}),
|
|
54
54
|
}).create();
|
|
55
55
|
token = await Token.createToken(user);
|
|
56
56
|
member = await new MemberFactory({ organization, user }).create();
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
beforeEach(async () => {
|
|
60
|
-
|
|
60
|
+
// #region groups
|
|
61
61
|
group1 = await new GroupFactory({
|
|
62
62
|
organization,
|
|
63
63
|
price: 25,
|
|
64
|
-
stock: 5
|
|
64
|
+
stock: 5,
|
|
65
65
|
}).create();
|
|
66
66
|
|
|
67
67
|
groupPrice1 = group1.settings.prices[0];
|
|
@@ -70,17 +70,16 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
70
70
|
organization,
|
|
71
71
|
price: 15,
|
|
72
72
|
stock: 4,
|
|
73
|
-
maxMembers: 1
|
|
73
|
+
maxMembers: 1,
|
|
74
74
|
}).create();
|
|
75
75
|
|
|
76
76
|
groupPrice2 = group2.settings.prices[0];
|
|
77
|
-
|
|
77
|
+
// #endregion
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
describe('Register member', () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//#region arrange
|
|
81
|
+
test('Should update registered mmebers', async () => {
|
|
82
|
+
// #region arrange
|
|
84
83
|
const body = IDRegisterCheckout.create({
|
|
85
84
|
cart: IDRegisterCart.create({
|
|
86
85
|
items: [
|
|
@@ -91,11 +90,11 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
91
90
|
groupPrice: groupPrice1,
|
|
92
91
|
organizationId: organization.id,
|
|
93
92
|
groupId: group1.id,
|
|
94
|
-
memberId: member.id
|
|
95
|
-
})
|
|
93
|
+
memberId: member.id,
|
|
94
|
+
}),
|
|
96
95
|
],
|
|
97
96
|
balanceItems: [],
|
|
98
|
-
deleteRegistrationIds: []
|
|
97
|
+
deleteRegistrationIds: [],
|
|
99
98
|
}),
|
|
100
99
|
administrationFee: 0,
|
|
101
100
|
freeContribution: 0,
|
|
@@ -104,7 +103,7 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
104
103
|
asOrganizationId: organization.id,
|
|
105
104
|
customer: null,
|
|
106
105
|
});
|
|
107
|
-
|
|
106
|
+
// #endregion
|
|
108
107
|
|
|
109
108
|
// act
|
|
110
109
|
const response = await post(body);
|
|
@@ -116,10 +115,10 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
116
115
|
const updatedGroup = await Group.getByID(group1.id);
|
|
117
116
|
expect(updatedGroup!.settings.registeredMembers).toBe(1);
|
|
118
117
|
expect(updatedGroup!.settings.reservedMembers).toBe(0);
|
|
119
|
-
})
|
|
118
|
+
});
|
|
120
119
|
|
|
121
|
-
test(
|
|
122
|
-
|
|
120
|
+
test('Should update reserved members', async () => {
|
|
121
|
+
// #region arrange
|
|
123
122
|
const body = IDRegisterCheckout.create({
|
|
124
123
|
cart: IDRegisterCart.create({
|
|
125
124
|
items: [
|
|
@@ -130,32 +129,32 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
130
129
|
groupPrice: groupPrice2,
|
|
131
130
|
organizationId: organization.id,
|
|
132
131
|
groupId: group2.id,
|
|
133
|
-
memberId: member.id
|
|
134
|
-
})
|
|
132
|
+
memberId: member.id,
|
|
133
|
+
}),
|
|
135
134
|
],
|
|
136
135
|
balanceItems: [],
|
|
137
|
-
deleteRegistrationIds: []
|
|
136
|
+
deleteRegistrationIds: [],
|
|
138
137
|
}),
|
|
139
138
|
administrationFee: 0,
|
|
140
139
|
freeContribution: 0,
|
|
141
140
|
paymentMethod: PaymentMethod.Payconiq,
|
|
142
|
-
redirectUrl: new URL(
|
|
143
|
-
cancelUrl: new URL(
|
|
141
|
+
redirectUrl: new URL('https://www.example.com'),
|
|
142
|
+
cancelUrl: new URL('https://www.example.com'),
|
|
144
143
|
totalPrice: 15,
|
|
145
144
|
customer: null,
|
|
146
145
|
});
|
|
147
|
-
|
|
146
|
+
|
|
148
147
|
nock('https://api.ext.payconiq.com')
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
.post('/v3/payments')
|
|
149
|
+
.reply(200, {
|
|
150
|
+
paymentId: 'testPaymentId',
|
|
151
|
+
_links: {
|
|
152
|
+
checkout: {
|
|
153
|
+
href: 'https://www.example.com',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
// #endregion
|
|
159
158
|
|
|
160
159
|
// act
|
|
161
160
|
const response = await post(body);
|
|
@@ -167,24 +166,23 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
167
166
|
const updatedGroup = await Group.getByID(group2.id);
|
|
168
167
|
expect(updatedGroup!.settings.registeredMembers).toBe(0);
|
|
169
168
|
expect(updatedGroup!.settings.reservedMembers).toBe(1);
|
|
170
|
-
})
|
|
171
|
-
})
|
|
169
|
+
});
|
|
170
|
+
});
|
|
172
171
|
|
|
173
172
|
describe('Register member with replace registration', () => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//#region arrange
|
|
173
|
+
test('Should update registered members', async () => {
|
|
174
|
+
// #region arrange
|
|
177
175
|
const registration = await new RegistrationFactory({
|
|
178
176
|
member,
|
|
179
177
|
group: group1,
|
|
180
|
-
groupPrice: groupPrice1
|
|
178
|
+
groupPrice: groupPrice1,
|
|
181
179
|
})
|
|
182
|
-
|
|
180
|
+
.create();
|
|
183
181
|
|
|
184
182
|
const group = await new GroupFactory({
|
|
185
183
|
organization,
|
|
186
184
|
price: 30,
|
|
187
|
-
stock: 5
|
|
185
|
+
stock: 5,
|
|
188
186
|
}).create();
|
|
189
187
|
|
|
190
188
|
const groupPrice = group.settings.prices[0];
|
|
@@ -199,11 +197,11 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
199
197
|
groupPrice,
|
|
200
198
|
organizationId: organization.id,
|
|
201
199
|
groupId: group.id,
|
|
202
|
-
memberId: member.id
|
|
203
|
-
})
|
|
200
|
+
memberId: member.id,
|
|
201
|
+
}),
|
|
204
202
|
],
|
|
205
203
|
balanceItems: [],
|
|
206
|
-
deleteRegistrationIds: []
|
|
204
|
+
deleteRegistrationIds: [],
|
|
207
205
|
}),
|
|
208
206
|
administrationFee: 0,
|
|
209
207
|
freeContribution: 0,
|
|
@@ -212,9 +210,9 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
212
210
|
asOrganizationId: organization.id,
|
|
213
211
|
customer: null,
|
|
214
212
|
});
|
|
215
|
-
|
|
213
|
+
// #endregion
|
|
216
214
|
|
|
217
|
-
|
|
215
|
+
// #region act and assert
|
|
218
216
|
|
|
219
217
|
// update occupancy to be sure occupancy is 1
|
|
220
218
|
await group1.updateOccupancy();
|
|
@@ -234,23 +232,23 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
234
232
|
// occupancy should go from 1 to 0 because the registration should be replaced
|
|
235
233
|
expect(updatedGroup1After!.settings.registeredMembers).toBe(0);
|
|
236
234
|
expect(updatedGroup1After!.settings.reservedMembers).toBe(0);
|
|
237
|
-
|
|
238
|
-
})
|
|
235
|
+
// #endregion
|
|
236
|
+
});
|
|
239
237
|
|
|
240
|
-
test(
|
|
241
|
-
|
|
238
|
+
test('Should throw error if with payment', async () => {
|
|
239
|
+
// #region arrange
|
|
242
240
|
const registration = await new RegistrationFactory({
|
|
243
241
|
member,
|
|
244
242
|
group: group1,
|
|
245
|
-
groupPrice: groupPrice1
|
|
243
|
+
groupPrice: groupPrice1,
|
|
246
244
|
})
|
|
247
|
-
|
|
245
|
+
.create();
|
|
248
246
|
|
|
249
247
|
const group = await new GroupFactory({
|
|
250
248
|
organization,
|
|
251
249
|
price: 30,
|
|
252
250
|
stock: 5,
|
|
253
|
-
maxMembers: 1
|
|
251
|
+
maxMembers: 1,
|
|
254
252
|
}).create();
|
|
255
253
|
|
|
256
254
|
const groupPrice = group.settings.prices[0];
|
|
@@ -265,48 +263,47 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
265
263
|
groupPrice,
|
|
266
264
|
organizationId: organization.id,
|
|
267
265
|
groupId: group.id,
|
|
268
|
-
memberId: member.id
|
|
269
|
-
})
|
|
266
|
+
memberId: member.id,
|
|
267
|
+
}),
|
|
270
268
|
],
|
|
271
269
|
balanceItems: [],
|
|
272
|
-
deleteRegistrationIds: []
|
|
270
|
+
deleteRegistrationIds: [],
|
|
273
271
|
}),
|
|
274
272
|
administrationFee: 0,
|
|
275
273
|
freeContribution: 0,
|
|
276
274
|
paymentMethod: PaymentMethod.Payconiq,
|
|
277
|
-
redirectUrl: new URL(
|
|
278
|
-
cancelUrl: new URL(
|
|
275
|
+
redirectUrl: new URL('https://www.example.com'),
|
|
276
|
+
cancelUrl: new URL('https://www.example.com'),
|
|
279
277
|
totalPrice: 5,
|
|
280
278
|
customer: null,
|
|
281
279
|
});
|
|
282
|
-
|
|
280
|
+
// #endregion
|
|
283
281
|
|
|
284
|
-
|
|
282
|
+
// #region act and assert
|
|
285
283
|
|
|
286
284
|
// update occupancy to be sure occupancy is 1
|
|
287
285
|
await group1.updateOccupancy();
|
|
288
286
|
expect(group1.settings.registeredMembers).toBe(1);
|
|
289
287
|
|
|
290
|
-
await expect(async () => await post(body)).rejects.toThrow(
|
|
291
|
-
|
|
292
|
-
})
|
|
293
|
-
})
|
|
288
|
+
await expect(async () => await post(body)).rejects.toThrow('Not allowed to move registrations');
|
|
289
|
+
// #endregion
|
|
290
|
+
});
|
|
291
|
+
});
|
|
294
292
|
|
|
295
293
|
describe('Register member with delete registration', () => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
//#region arrange
|
|
294
|
+
test('Should update registered members', async () => {
|
|
295
|
+
// #region arrange
|
|
299
296
|
const registration = await new RegistrationFactory({
|
|
300
297
|
member,
|
|
301
298
|
group: group1,
|
|
302
|
-
groupPrice: groupPrice1
|
|
299
|
+
groupPrice: groupPrice1,
|
|
303
300
|
})
|
|
304
|
-
|
|
301
|
+
.create();
|
|
305
302
|
|
|
306
303
|
const group = await new GroupFactory({
|
|
307
304
|
organization,
|
|
308
305
|
price: 30,
|
|
309
|
-
stock: 5
|
|
306
|
+
stock: 5,
|
|
310
307
|
}).create();
|
|
311
308
|
|
|
312
309
|
const groupPrice = group.settings.prices[0];
|
|
@@ -321,11 +318,11 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
321
318
|
groupPrice,
|
|
322
319
|
organizationId: organization.id,
|
|
323
320
|
groupId: group.id,
|
|
324
|
-
memberId: member.id
|
|
325
|
-
})
|
|
321
|
+
memberId: member.id,
|
|
322
|
+
}),
|
|
326
323
|
],
|
|
327
324
|
balanceItems: [],
|
|
328
|
-
deleteRegistrationIds: [registration.id]
|
|
325
|
+
deleteRegistrationIds: [registration.id],
|
|
329
326
|
}),
|
|
330
327
|
administrationFee: 0,
|
|
331
328
|
freeContribution: 0,
|
|
@@ -334,9 +331,9 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
334
331
|
asOrganizationId: organization.id,
|
|
335
332
|
customer: null,
|
|
336
333
|
});
|
|
337
|
-
|
|
334
|
+
// #endregion
|
|
338
335
|
|
|
339
|
-
|
|
336
|
+
// #region act and assert
|
|
340
337
|
|
|
341
338
|
// update occupancy to be sure occupancy is 1
|
|
342
339
|
await group1.updateOccupancy();
|
|
@@ -356,23 +353,23 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
356
353
|
// occupancy should go from 1 to 0 because the registration should be deleted
|
|
357
354
|
expect(updatedGroup1After!.settings.registeredMembers).toBe(0);
|
|
358
355
|
expect(updatedGroup1After!.settings.reservedMembers).toBe(0);
|
|
359
|
-
|
|
360
|
-
})
|
|
356
|
+
// #endregion
|
|
357
|
+
});
|
|
361
358
|
|
|
362
|
-
test(
|
|
363
|
-
|
|
359
|
+
test('Should throw error if with payment', async () => {
|
|
360
|
+
// #region arrange
|
|
364
361
|
const registration = await new RegistrationFactory({
|
|
365
362
|
member,
|
|
366
363
|
group: group1,
|
|
367
|
-
groupPrice: groupPrice1
|
|
364
|
+
groupPrice: groupPrice1,
|
|
368
365
|
})
|
|
369
|
-
|
|
366
|
+
.create();
|
|
370
367
|
|
|
371
368
|
const group = await new GroupFactory({
|
|
372
369
|
organization,
|
|
373
370
|
price: 30,
|
|
374
371
|
stock: 5,
|
|
375
|
-
maxMembers: 1
|
|
372
|
+
maxMembers: 1,
|
|
376
373
|
}).create();
|
|
377
374
|
|
|
378
375
|
const groupPrice = group.settings.prices[0];
|
|
@@ -387,41 +384,41 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
387
384
|
groupPrice,
|
|
388
385
|
organizationId: organization.id,
|
|
389
386
|
groupId: group.id,
|
|
390
|
-
memberId: member.id
|
|
391
|
-
})
|
|
387
|
+
memberId: member.id,
|
|
388
|
+
}),
|
|
392
389
|
],
|
|
393
390
|
balanceItems: [],
|
|
394
|
-
deleteRegistrationIds: [registration.id]
|
|
391
|
+
deleteRegistrationIds: [registration.id],
|
|
395
392
|
}),
|
|
396
393
|
administrationFee: 0,
|
|
397
394
|
freeContribution: 0,
|
|
398
395
|
paymentMethod: PaymentMethod.Payconiq,
|
|
399
|
-
redirectUrl: new URL(
|
|
400
|
-
cancelUrl: new URL(
|
|
396
|
+
redirectUrl: new URL('https://www.example.com'),
|
|
397
|
+
cancelUrl: new URL('https://www.example.com'),
|
|
401
398
|
totalPrice: 5,
|
|
402
399
|
customer: null,
|
|
403
400
|
});
|
|
404
|
-
|
|
401
|
+
// #endregion
|
|
405
402
|
|
|
406
|
-
|
|
403
|
+
// #region act and assert
|
|
407
404
|
|
|
408
405
|
// update occupancy to be sure occupancy is 1
|
|
409
406
|
await group1.updateOccupancy();
|
|
410
407
|
expect(group1.settings.registeredMembers).toBe(1);
|
|
411
408
|
|
|
412
|
-
await expect(async () => await post(body)).rejects.toThrow(
|
|
413
|
-
|
|
414
|
-
})
|
|
415
|
-
})
|
|
409
|
+
await expect(async () => await post(body)).rejects.toThrow('Permission denied: you are not allowed to delete registrations');
|
|
410
|
+
// #endregion
|
|
411
|
+
});
|
|
412
|
+
});
|
|
416
413
|
|
|
417
414
|
it('Register member that is already registered should throw error', async () => {
|
|
418
415
|
// create existing registration
|
|
419
416
|
await new RegistrationFactory({
|
|
420
417
|
member,
|
|
421
418
|
group: group1,
|
|
422
|
-
groupPrice: groupPrice1
|
|
419
|
+
groupPrice: groupPrice1,
|
|
423
420
|
})
|
|
424
|
-
|
|
421
|
+
.create();
|
|
425
422
|
|
|
426
423
|
// register again
|
|
427
424
|
const body = IDRegisterCheckout.create({
|
|
@@ -434,11 +431,11 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
434
431
|
groupPrice: groupPrice1,
|
|
435
432
|
organizationId: organization.id,
|
|
436
433
|
groupId: group1.id,
|
|
437
|
-
memberId: member.id
|
|
438
|
-
})
|
|
434
|
+
memberId: member.id,
|
|
435
|
+
}),
|
|
439
436
|
],
|
|
440
437
|
balanceItems: [],
|
|
441
|
-
deleteRegistrationIds: []
|
|
438
|
+
deleteRegistrationIds: [],
|
|
442
439
|
}),
|
|
443
440
|
administrationFee: 0,
|
|
444
441
|
freeContribution: 0,
|
|
@@ -448,6 +445,6 @@ describe("Endpoint.RegisterMembers", () => {
|
|
|
448
445
|
customer: null,
|
|
449
446
|
});
|
|
450
447
|
|
|
451
|
-
await expect(async () => await post(body)).rejects.toThrow(
|
|
452
|
-
})
|
|
453
|
-
})
|
|
448
|
+
await expect(async () => await post(body)).rejects.toThrow('Already registered');
|
|
449
|
+
});
|
|
450
|
+
});
|