@stamhoofd/backend 2.39.0 → 2.40.0
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 +102 -103
- 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 +50 -52
- 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,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { Request, Response } from "@simonbackx/simple-endpoints";
|
|
5
|
-
import { Organization, OrganizationFactory, StripeAccount, Token, User,UserFactory, Webshop, WebshopFactory } from "@stamhoofd/models";
|
|
6
|
-
import { Address, Cart, CartItem, CartItemOption, Country, Customer, Option, OptionMenu, OrderData, OrderResponse, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivatePaymentConfiguration, Product, ProductPrice, ProductType, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, WebshopDeliveryMethod, WebshopMetaData, WebshopOnSiteMethod, WebshopPrivateMetaData, WebshopTakeoutMethod, WebshopTimeSlot } from "@stamhoofd/structures";
|
|
1
|
+
import { Request, Response } from '@simonbackx/simple-endpoints';
|
|
2
|
+
import { Organization, OrganizationFactory, StripeAccount, Token, User, UserFactory, Webshop, WebshopFactory } from '@stamhoofd/models';
|
|
3
|
+
import { Address, Cart, CartItem, CartItemOption, Country, Customer, Option, OptionMenu, OrderData, OrderResponse, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivatePaymentConfiguration, Product, ProductPrice, ProductType, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, WebshopDeliveryMethod, WebshopMetaData, WebshopOnSiteMethod, WebshopPrivateMetaData, WebshopTakeoutMethod, WebshopTimeSlot } from '@stamhoofd/structures';
|
|
7
4
|
import sinon from 'sinon';
|
|
8
5
|
|
|
9
|
-
import { StripeMocker } from
|
|
10
|
-
import { testServer } from
|
|
11
|
-
import { PatchWebshopOrdersEndpoint } from
|
|
6
|
+
import { StripeMocker } from '../../../../tests/helpers/StripeMocker';
|
|
7
|
+
import { testServer } from '../../../../tests/helpers/TestServer';
|
|
8
|
+
import { PatchWebshopOrdersEndpoint } from '../dashboard/webshops/PatchWebshopOrdersEndpoint';
|
|
12
9
|
import { PlaceOrderEndpoint } from './PlaceOrderEndpoint';
|
|
13
10
|
|
|
14
11
|
const address = Address.create({
|
|
@@ -16,17 +13,17 @@ const address = Address.create({
|
|
|
16
13
|
number: '15',
|
|
17
14
|
postalCode: '9000',
|
|
18
15
|
city: 'Gent',
|
|
19
|
-
country: Country.Belgium
|
|
20
|
-
})
|
|
16
|
+
country: Country.Belgium,
|
|
17
|
+
});
|
|
21
18
|
|
|
22
19
|
const customer = Customer.create({
|
|
23
20
|
firstName: 'John',
|
|
24
21
|
lastName: 'Doe',
|
|
25
22
|
email: 'john@example.com',
|
|
26
|
-
phone: '+32412345678'
|
|
23
|
+
phone: '+32412345678',
|
|
27
24
|
});
|
|
28
25
|
|
|
29
|
-
describe(
|
|
26
|
+
describe('Endpoint.PlaceOrderEndpoint', () => {
|
|
30
27
|
// Test endpoint
|
|
31
28
|
const endpoint = new PlaceOrderEndpoint();
|
|
32
29
|
const patchWebshopOrdersEndpoint = new PatchWebshopOrdersEndpoint();
|
|
@@ -57,8 +54,8 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
57
54
|
let checkboxOption2: Option;
|
|
58
55
|
let radioOption1: Option;
|
|
59
56
|
let radioOption2: Option;
|
|
60
|
-
let stripeMocker: StripeMocker
|
|
61
|
-
let stripeAccount: StripeAccount
|
|
57
|
+
let stripeMocker: StripeMocker;
|
|
58
|
+
let stripeAccount: StripeAccount;
|
|
62
59
|
let token: Token;
|
|
63
60
|
|
|
64
61
|
async function refreshAll() {
|
|
@@ -91,7 +88,7 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
91
88
|
async function saveChanges() {
|
|
92
89
|
// Set products
|
|
93
90
|
webshop = (await Webshop.getByID(webshop.id))!;
|
|
94
|
-
webshop.products = [product, seatProduct, personProduct]
|
|
91
|
+
webshop.products = [product, seatProduct, personProduct];
|
|
95
92
|
await webshop.save();
|
|
96
93
|
await refreshAll();
|
|
97
94
|
}
|
|
@@ -99,16 +96,16 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
99
96
|
beforeAll(async () => {
|
|
100
97
|
stripeMocker = new StripeMocker();
|
|
101
98
|
stripeMocker.start();
|
|
102
|
-
organization = await new OrganizationFactory({}).create()
|
|
99
|
+
organization = await new OrganizationFactory({}).create();
|
|
103
100
|
stripeAccount = await stripeMocker.createStripeAccount(organization.id);
|
|
104
101
|
|
|
105
102
|
const user = await new UserFactory({
|
|
106
103
|
organization,
|
|
107
104
|
permissions: Permissions.create({
|
|
108
|
-
level: PermissionLevel.Full
|
|
109
|
-
})
|
|
110
|
-
}).create()
|
|
111
|
-
token = await Token.createToken(user)
|
|
105
|
+
level: PermissionLevel.Full,
|
|
106
|
+
}),
|
|
107
|
+
}).create();
|
|
108
|
+
token = await Token.createToken(user);
|
|
112
109
|
});
|
|
113
110
|
|
|
114
111
|
afterAll(() => {
|
|
@@ -126,70 +123,70 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
126
123
|
productPrice1 = ProductPrice.create({
|
|
127
124
|
name: 'productPrice1',
|
|
128
125
|
price: 100,
|
|
129
|
-
stock: 100
|
|
130
|
-
})
|
|
126
|
+
stock: 100,
|
|
127
|
+
});
|
|
131
128
|
|
|
132
129
|
productPrice2 = ProductPrice.create({
|
|
133
130
|
name: 'productPrice2',
|
|
134
131
|
price: 150,
|
|
135
|
-
stock: 100
|
|
136
|
-
})
|
|
132
|
+
stock: 100,
|
|
133
|
+
});
|
|
137
134
|
|
|
138
135
|
freeProductPrice = ProductPrice.create({
|
|
139
136
|
name: 'freeProductPrice',
|
|
140
137
|
price: 0,
|
|
141
|
-
stock: 100
|
|
142
|
-
})
|
|
138
|
+
stock: 100,
|
|
139
|
+
});
|
|
143
140
|
|
|
144
141
|
checkboxOption1 = Option.create({
|
|
145
142
|
name: 'checkboxOption1',
|
|
146
143
|
price: 10,
|
|
147
|
-
stock: 100
|
|
148
|
-
})
|
|
144
|
+
stock: 100,
|
|
145
|
+
});
|
|
149
146
|
|
|
150
147
|
checkboxOption2 = Option.create({
|
|
151
148
|
name: 'checkboxOption2',
|
|
152
149
|
price: 0,
|
|
153
|
-
stock: 100
|
|
154
|
-
})
|
|
150
|
+
stock: 100,
|
|
151
|
+
});
|
|
155
152
|
|
|
156
153
|
radioOption1 = Option.create({
|
|
157
154
|
name: 'radioOption1',
|
|
158
155
|
price: 10,
|
|
159
|
-
stock: 100
|
|
160
|
-
})
|
|
156
|
+
stock: 100,
|
|
157
|
+
});
|
|
161
158
|
|
|
162
159
|
radioOption2 = Option.create({
|
|
163
160
|
name: 'radioOption2',
|
|
164
161
|
price: 0,
|
|
165
|
-
stock: 100
|
|
166
|
-
})
|
|
162
|
+
stock: 100,
|
|
163
|
+
});
|
|
167
164
|
|
|
168
165
|
multipleChoiceOptionMenu = OptionMenu.create({
|
|
169
166
|
name: 'multipleChoiceOptionMenu',
|
|
170
167
|
multipleChoice: true,
|
|
171
|
-
options: [checkboxOption1, checkboxOption2]
|
|
172
|
-
})
|
|
168
|
+
options: [checkboxOption1, checkboxOption2],
|
|
169
|
+
});
|
|
173
170
|
|
|
174
171
|
chooseOneOptionMenu = OptionMenu.create({
|
|
175
172
|
name: 'chooseOneOptionMenu',
|
|
176
173
|
multipleChoice: false,
|
|
177
|
-
options: [radioOption1, radioOption2]
|
|
178
|
-
})
|
|
174
|
+
options: [radioOption1, radioOption2],
|
|
175
|
+
});
|
|
179
176
|
|
|
180
177
|
product = Product.create({
|
|
181
178
|
name: 'product',
|
|
182
179
|
stock: 100,
|
|
183
180
|
prices: [productPrice1, productPrice2, freeProductPrice],
|
|
184
|
-
optionMenus: [multipleChoiceOptionMenu, chooseOneOptionMenu]
|
|
185
|
-
})
|
|
181
|
+
optionMenus: [multipleChoiceOptionMenu, chooseOneOptionMenu],
|
|
182
|
+
});
|
|
186
183
|
|
|
187
184
|
personProduct = Product.create({
|
|
188
185
|
name: 'personProduct',
|
|
189
186
|
type: ProductType.Person,
|
|
190
|
-
stock: 100
|
|
191
|
-
})
|
|
192
|
-
personProductPrice = personProduct.prices[0]
|
|
187
|
+
stock: 100,
|
|
188
|
+
});
|
|
189
|
+
personProductPrice = personProduct.prices[0];
|
|
193
190
|
|
|
194
191
|
seatingPlan = SeatingPlan.create({
|
|
195
192
|
name: 'Testzaal',
|
|
@@ -200,137 +197,136 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
200
197
|
label: 'A',
|
|
201
198
|
seats: [
|
|
202
199
|
SeatingPlanSeat.create({
|
|
203
|
-
label: '1'
|
|
200
|
+
label: '1',
|
|
204
201
|
}),
|
|
205
202
|
SeatingPlanSeat.create({
|
|
206
|
-
label: '2'
|
|
203
|
+
label: '2',
|
|
207
204
|
}),
|
|
208
205
|
SeatingPlanSeat.create({
|
|
209
|
-
label: '3'
|
|
206
|
+
label: '3',
|
|
210
207
|
}),
|
|
211
208
|
SeatingPlanSeat.create({
|
|
212
|
-
label: '4'
|
|
213
|
-
})
|
|
214
|
-
]
|
|
209
|
+
label: '4',
|
|
210
|
+
}),
|
|
211
|
+
],
|
|
215
212
|
}),
|
|
216
213
|
SeatingPlanRow.create({
|
|
217
214
|
label: 'B',
|
|
218
215
|
seats: [
|
|
219
216
|
SeatingPlanSeat.create({
|
|
220
|
-
label: '1'
|
|
217
|
+
label: '1',
|
|
221
218
|
}),
|
|
222
219
|
SeatingPlanSeat.create({
|
|
223
|
-
label: '2'
|
|
220
|
+
label: '2',
|
|
224
221
|
}),
|
|
225
222
|
SeatingPlanSeat.create({
|
|
226
|
-
label: '3'
|
|
223
|
+
label: '3',
|
|
227
224
|
}),
|
|
228
225
|
SeatingPlanSeat.create({
|
|
229
|
-
label: '4'
|
|
230
|
-
})
|
|
231
|
-
]
|
|
232
|
-
})
|
|
233
|
-
]
|
|
234
|
-
})
|
|
235
|
-
]
|
|
236
|
-
})
|
|
237
|
-
meta.seatingPlans.addPut(seatingPlan)
|
|
226
|
+
label: '4',
|
|
227
|
+
}),
|
|
228
|
+
],
|
|
229
|
+
}),
|
|
230
|
+
],
|
|
231
|
+
}),
|
|
232
|
+
],
|
|
233
|
+
});
|
|
234
|
+
meta.seatingPlans.addPut(seatingPlan);
|
|
238
235
|
|
|
239
236
|
seatProduct = Product.create({
|
|
240
237
|
name: 'seatProduct',
|
|
241
238
|
type: ProductType.Ticket,
|
|
242
|
-
seatingPlanId: seatingPlan.id
|
|
243
|
-
})
|
|
244
|
-
seatProductPrice = seatProduct.prices[0]
|
|
239
|
+
seatingPlanId: seatingPlan.id,
|
|
240
|
+
});
|
|
241
|
+
seatProductPrice = seatProduct.prices[0];
|
|
245
242
|
|
|
246
243
|
// Takeout
|
|
247
244
|
takeoutMethod = WebshopTakeoutMethod.create({
|
|
248
245
|
name: 'Bakkerij Test',
|
|
249
|
-
address
|
|
250
|
-
})
|
|
246
|
+
address,
|
|
247
|
+
});
|
|
251
248
|
|
|
252
249
|
slot1 = WebshopTimeSlot.create({
|
|
253
250
|
date: new Date(),
|
|
254
251
|
maxPersons: 100,
|
|
255
|
-
maxOrders: 100
|
|
252
|
+
maxOrders: 100,
|
|
256
253
|
});
|
|
257
|
-
takeoutMethod.timeSlots.timeSlots.push(slot1)
|
|
254
|
+
takeoutMethod.timeSlots.timeSlots.push(slot1);
|
|
258
255
|
|
|
259
256
|
slot2 = WebshopTimeSlot.create({
|
|
260
257
|
date: new Date(),
|
|
261
258
|
maxPersons: 100,
|
|
262
259
|
maxOrders: 100,
|
|
263
|
-
startTime: 14*60,
|
|
264
|
-
endTime: 15*60
|
|
265
|
-
})
|
|
266
|
-
takeoutMethod.timeSlots.timeSlots.push(slot2)
|
|
267
|
-
meta.checkoutMethods.addPut(takeoutMethod)
|
|
268
|
-
|
|
260
|
+
startTime: 14 * 60,
|
|
261
|
+
endTime: 15 * 60,
|
|
262
|
+
});
|
|
263
|
+
takeoutMethod.timeSlots.timeSlots.push(slot2);
|
|
264
|
+
meta.checkoutMethods.addPut(takeoutMethod);
|
|
269
265
|
|
|
270
266
|
// Delivery
|
|
271
267
|
deliveryMethod = WebshopDeliveryMethod.create({
|
|
272
268
|
name: 'Delivery',
|
|
273
|
-
countries: [Country.Belgium]
|
|
274
|
-
})
|
|
269
|
+
countries: [Country.Belgium],
|
|
270
|
+
});
|
|
275
271
|
|
|
276
272
|
slot3 = WebshopTimeSlot.create({
|
|
277
273
|
date: new Date(),
|
|
278
274
|
maxPersons: 100,
|
|
279
|
-
maxOrders: 100
|
|
275
|
+
maxOrders: 100,
|
|
280
276
|
});
|
|
281
277
|
|
|
282
|
-
deliveryMethod.timeSlots.timeSlots.push(slot3)
|
|
283
|
-
meta.checkoutMethods.addPut(deliveryMethod)
|
|
278
|
+
deliveryMethod.timeSlots.timeSlots.push(slot3);
|
|
279
|
+
meta.checkoutMethods.addPut(deliveryMethod);
|
|
284
280
|
|
|
285
281
|
// OnSite
|
|
286
282
|
onSiteMethod = WebshopOnSiteMethod.create({
|
|
287
283
|
name: 'Onsite',
|
|
288
|
-
address
|
|
289
|
-
})
|
|
284
|
+
address,
|
|
285
|
+
});
|
|
290
286
|
|
|
291
287
|
slot4 = WebshopTimeSlot.create({
|
|
292
288
|
date: new Date(),
|
|
293
289
|
maxPersons: 100,
|
|
294
|
-
maxOrders: 100
|
|
290
|
+
maxOrders: 100,
|
|
295
291
|
});
|
|
296
292
|
|
|
297
|
-
onSiteMethod.timeSlots.timeSlots.push(slot4)
|
|
298
|
-
meta.checkoutMethods.addPut(onSiteMethod)
|
|
299
|
-
|
|
293
|
+
onSiteMethod.timeSlots.timeSlots.push(slot4);
|
|
294
|
+
meta.checkoutMethods.addPut(onSiteMethod);
|
|
295
|
+
|
|
300
296
|
const paymentConfigurationPatch = PaymentConfiguration.patch({
|
|
301
297
|
transferSettings: TransferSettings.create({
|
|
302
|
-
iban: 'BE56587127952688' // = random IBAN
|
|
298
|
+
iban: 'BE56587127952688', // = random IBAN
|
|
303
299
|
}),
|
|
304
|
-
})
|
|
305
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale)
|
|
306
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer)
|
|
307
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact)
|
|
300
|
+
});
|
|
301
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale);
|
|
302
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer);
|
|
303
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact);
|
|
308
304
|
|
|
309
305
|
const privatePaymentConfiguration = PrivatePaymentConfiguration.patch({
|
|
310
|
-
stripeAccountId: stripeAccount.id
|
|
311
|
-
})
|
|
306
|
+
stripeAccountId: stripeAccount.id,
|
|
307
|
+
});
|
|
312
308
|
|
|
313
309
|
meta = meta.patch({
|
|
314
|
-
paymentConfiguration: paymentConfigurationPatch
|
|
315
|
-
})
|
|
310
|
+
paymentConfiguration: paymentConfigurationPatch,
|
|
311
|
+
});
|
|
316
312
|
|
|
317
313
|
const privateMeta = WebshopPrivateMetaData.patch({
|
|
318
|
-
paymentConfiguration: privatePaymentConfiguration
|
|
319
|
-
})
|
|
314
|
+
paymentConfiguration: privatePaymentConfiguration,
|
|
315
|
+
});
|
|
320
316
|
|
|
321
317
|
webshop = await new WebshopFactory({
|
|
322
318
|
organizationId: organization.id,
|
|
323
319
|
name: 'Test webshop',
|
|
324
320
|
meta,
|
|
325
321
|
privateMeta,
|
|
326
|
-
products: [product, seatProduct, personProduct]
|
|
327
|
-
}).create()
|
|
322
|
+
products: [product, seatProduct, personProduct],
|
|
323
|
+
}).create();
|
|
328
324
|
});
|
|
329
325
|
|
|
330
326
|
describe('User authentication', () => {
|
|
331
|
-
test(
|
|
332
|
-
const user = await new UserFactory({ organization, firstName: 'User', lastName: 'Tester' }).create()
|
|
333
|
-
const token = await Token.createToken(user)
|
|
327
|
+
test('Placing an order with a signed in user overrides the order customer', async () => {
|
|
328
|
+
const user = await new UserFactory({ organization, firstName: 'User', lastName: 'Tester' }).create();
|
|
329
|
+
const token = await Token.createToken(user);
|
|
334
330
|
|
|
335
331
|
const orderData = OrderData.create({
|
|
336
332
|
paymentMethod: PaymentMethod.Unknown,
|
|
@@ -345,21 +341,21 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
345
341
|
options: [
|
|
346
342
|
CartItemOption.create({
|
|
347
343
|
optionMenu: multipleChoiceOptionMenu,
|
|
348
|
-
option: checkboxOption2
|
|
344
|
+
option: checkboxOption2,
|
|
349
345
|
}),
|
|
350
346
|
CartItemOption.create({
|
|
351
347
|
optionMenu: chooseOneOptionMenu,
|
|
352
|
-
option: radioOption2
|
|
353
|
-
})
|
|
354
|
-
]
|
|
355
|
-
})
|
|
356
|
-
]
|
|
348
|
+
option: radioOption2,
|
|
349
|
+
}),
|
|
350
|
+
],
|
|
351
|
+
}),
|
|
352
|
+
],
|
|
357
353
|
}),
|
|
358
|
-
customer
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
const r = Request.buildJson(
|
|
362
|
-
r.headers.authorization =
|
|
354
|
+
customer,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
358
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
363
359
|
|
|
364
360
|
const response = await testServer.test(endpoint, r);
|
|
365
361
|
expect(response.body).toBeDefined();
|
|
@@ -373,7 +369,7 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
373
369
|
/**
|
|
374
370
|
* This checks if the authenticated context is passed when multiple orders are executed in a queue
|
|
375
371
|
*/
|
|
376
|
-
test(
|
|
372
|
+
test('Authenticated context is guarded with race conditions', async () => {
|
|
377
373
|
const orderData = OrderData.create({
|
|
378
374
|
paymentMethod: PaymentMethod.Unknown,
|
|
379
375
|
checkoutMethod: onSiteMethod,
|
|
@@ -387,18 +383,18 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
387
383
|
options: [
|
|
388
384
|
CartItemOption.create({
|
|
389
385
|
optionMenu: multipleChoiceOptionMenu,
|
|
390
|
-
option: checkboxOption2
|
|
386
|
+
option: checkboxOption2,
|
|
391
387
|
}),
|
|
392
388
|
CartItemOption.create({
|
|
393
389
|
optionMenu: chooseOneOptionMenu,
|
|
394
|
-
option: radioOption2
|
|
395
|
-
})
|
|
396
|
-
]
|
|
397
|
-
})
|
|
398
|
-
]
|
|
390
|
+
option: radioOption2,
|
|
391
|
+
}),
|
|
392
|
+
],
|
|
393
|
+
}),
|
|
394
|
+
],
|
|
399
395
|
}),
|
|
400
|
-
customer
|
|
401
|
-
})
|
|
396
|
+
customer,
|
|
397
|
+
});
|
|
402
398
|
|
|
403
399
|
let counter = 0;
|
|
404
400
|
let resolve: null | (() => void) = null;
|
|
@@ -420,17 +416,17 @@ describe("Endpoint.PlaceOrderEndpoint", () => {
|
|
|
420
416
|
return stub.wrappedMethod.apply(this, args);
|
|
421
417
|
});
|
|
422
418
|
|
|
423
|
-
const pendingResponses: {promise: Promise<Response<OrderResponse
|
|
419
|
+
const pendingResponses: { promise: Promise<Response<OrderResponse>>; user: User }[] = [];
|
|
424
420
|
for (let i = 0; i < 10; i++) {
|
|
425
|
-
const user = await new UserFactory({ organization, firstName: 'User', lastName: 'Tester' }).create()
|
|
426
|
-
const token = await Token.createToken(user)
|
|
421
|
+
const user = await new UserFactory({ organization, firstName: 'User', lastName: 'Tester' }).create();
|
|
422
|
+
const token = await Token.createToken(user);
|
|
427
423
|
|
|
428
|
-
const r = Request.buildJson(
|
|
429
|
-
r.headers.authorization =
|
|
424
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
425
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
430
426
|
|
|
431
427
|
pendingResponses.push({
|
|
432
428
|
promise: testServer.test(endpoint, r),
|
|
433
|
-
user
|
|
429
|
+
user,
|
|
434
430
|
});
|
|
435
431
|
}
|
|
436
432
|
|