@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
package/tests/e2e/stock.test.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
/* eslint-disable jest/expect-expect */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/* eslint-disable jest/no-standalone-expect */
|
|
4
|
-
import { PatchableArray, PatchableArrayAutoEncoder } from
|
|
5
|
-
import { Request } from
|
|
6
|
-
import { Order, Organization, OrganizationFactory, StripeAccount, Token, UserFactory, Webshop, WebshopFactory } from
|
|
7
|
-
import { Address, Cart, CartItem, CartItemOption, CartReservedSeat, Country, Customer, Option, OptionMenu, OrderData, OrderStatus, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivateOrder, PrivatePaymentConfiguration, Product, ProductPrice, ProductType, ReservedSeat, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, ValidatedAddress, WebshopDeliveryMethod, WebshopMetaData, WebshopOnSiteMethod, WebshopPrivateMetaData, WebshopTakeoutMethod, WebshopTimeSlot } from
|
|
8
|
-
import { v4 as uuidv4 } from
|
|
4
|
+
import { PatchableArray, PatchableArrayAutoEncoder } from '@simonbackx/simple-encoding';
|
|
5
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
6
|
+
import { Order, Organization, OrganizationFactory, StripeAccount, Token, UserFactory, Webshop, WebshopFactory } from '@stamhoofd/models';
|
|
7
|
+
import { Address, Cart, CartItem, CartItemOption, CartReservedSeat, Country, Customer, Option, OptionMenu, OrderData, OrderStatus, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivateOrder, PrivatePaymentConfiguration, Product, ProductPrice, ProductType, ReservedSeat, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, ValidatedAddress, WebshopDeliveryMethod, WebshopMetaData, WebshopOnSiteMethod, WebshopPrivateMetaData, WebshopTakeoutMethod, WebshopTimeSlot } from '@stamhoofd/structures';
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
9
|
|
|
10
|
-
import { PatchWebshopOrdersEndpoint } from
|
|
10
|
+
import { PatchWebshopOrdersEndpoint } from '../../src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint';
|
|
11
11
|
import { PlaceOrderEndpoint } from '../../src/endpoints/organization/webshops/PlaceOrderEndpoint';
|
|
12
|
-
import { StripeMocker } from
|
|
13
|
-
import { testServer } from
|
|
12
|
+
import { StripeMocker } from '../helpers/StripeMocker';
|
|
13
|
+
import { testServer } from '../helpers/TestServer';
|
|
14
14
|
|
|
15
15
|
const address = Address.create({
|
|
16
16
|
street: 'Demostraat',
|
|
17
17
|
number: '15',
|
|
18
18
|
postalCode: '9000',
|
|
19
19
|
city: 'Gent',
|
|
20
|
-
country: Country.Belgium
|
|
21
|
-
})
|
|
20
|
+
country: Country.Belgium,
|
|
21
|
+
});
|
|
22
22
|
|
|
23
23
|
const customer = Customer.create({
|
|
24
24
|
firstName: 'John',
|
|
25
25
|
lastName: 'Doe',
|
|
26
26
|
email: 'john@example.com',
|
|
27
|
-
phone: '+32412345678'
|
|
27
|
+
phone: '+32412345678',
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
describe(
|
|
30
|
+
describe('E2E.Stock', () => {
|
|
31
31
|
// Test endpoint
|
|
32
32
|
const endpoint = new PlaceOrderEndpoint();
|
|
33
33
|
const patchWebshopOrdersEndpoint = new PatchWebshopOrdersEndpoint();
|
|
@@ -58,8 +58,8 @@ describe("E2E.Stock", () => {
|
|
|
58
58
|
let checkboxOption2: Option;
|
|
59
59
|
let radioOption1: Option;
|
|
60
60
|
let radioOption2: Option;
|
|
61
|
-
let stripeMocker: StripeMocker
|
|
62
|
-
let stripeAccount: StripeAccount
|
|
61
|
+
let stripeMocker: StripeMocker;
|
|
62
|
+
let stripeAccount: StripeAccount;
|
|
63
63
|
let token: Token;
|
|
64
64
|
|
|
65
65
|
async function refreshAll() {
|
|
@@ -110,7 +110,7 @@ describe("E2E.Stock", () => {
|
|
|
110
110
|
const products = [product, seatProduct, personProduct];
|
|
111
111
|
for (const product of products) {
|
|
112
112
|
let used = 0;
|
|
113
|
-
const seats: ReservedSeat[] = []
|
|
113
|
+
const seats: ReservedSeat[] = [];
|
|
114
114
|
|
|
115
115
|
for (const item of cartItems) {
|
|
116
116
|
if (item.product.id == product.id) {
|
|
@@ -152,11 +152,12 @@ describe("E2E.Stock", () => {
|
|
|
152
152
|
// Now check reserved for each item
|
|
153
153
|
for (const item of cartItems) {
|
|
154
154
|
expect(item.reservedAmount).toBe(item.amount);
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
for (const price of productPrices) {
|
|
157
157
|
if (item.productPrice.id == price.id) {
|
|
158
158
|
expect(item.reservedPrices.get(price.id)).toBe(item.amount);
|
|
159
|
-
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
160
161
|
expect(item.reservedPrices.get(price.id) ?? 0).toBe(0);
|
|
161
162
|
}
|
|
162
163
|
}
|
|
@@ -175,7 +176,7 @@ describe("E2E.Stock", () => {
|
|
|
175
176
|
for (const item of excludedCartItems) {
|
|
176
177
|
expect(item.reservedAmount).toBe(0);
|
|
177
178
|
expect(item.reservedSeats.length).toBe(0);
|
|
178
|
-
|
|
179
|
+
|
|
179
180
|
for (const price of productPrices) {
|
|
180
181
|
expect(item.reservedPrices.get(price.id) ?? 0).toBe(0);
|
|
181
182
|
}
|
|
@@ -187,7 +188,7 @@ describe("E2E.Stock", () => {
|
|
|
187
188
|
|
|
188
189
|
// Check order stock
|
|
189
190
|
for (const order of orders) {
|
|
190
|
-
const filteredItems = cartItems.filter(i => !!order.data.cart.items.find(c => c.id === i.id))
|
|
191
|
+
const filteredItems = cartItems.filter(i => !!order.data.cart.items.find(c => c.id === i.id));
|
|
191
192
|
let persons = 0;
|
|
192
193
|
for (const item of filteredItems) {
|
|
193
194
|
if (item.product.type === ProductType.Person) {
|
|
@@ -206,7 +207,7 @@ describe("E2E.Stock", () => {
|
|
|
206
207
|
for (const order of orders) {
|
|
207
208
|
if (order.data.timeSlot?.id === slot.id) {
|
|
208
209
|
let persons = 0;
|
|
209
|
-
const filteredItems = cartItems.filter(i => !!order.data.cart.items.find(c => c.id === i.id))
|
|
210
|
+
const filteredItems = cartItems.filter(i => !!order.data.cart.items.find(c => c.id === i.id));
|
|
210
211
|
|
|
211
212
|
for (const item of filteredItems) {
|
|
212
213
|
if (item.product.type === ProductType.Person) {
|
|
@@ -214,7 +215,7 @@ describe("E2E.Stock", () => {
|
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
ordersCount += filteredItems.length > 0 ? 1 : 0
|
|
218
|
+
ordersCount += filteredItems.length > 0 ? 1 : 0;
|
|
218
219
|
personsCount += persons;
|
|
219
220
|
}
|
|
220
221
|
}
|
|
@@ -227,15 +228,15 @@ describe("E2E.Stock", () => {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
async function checkStock(orderId: string, cartItems: CartItem[], excludedCartItems: CartItem[] = []) {
|
|
230
|
-
const otherOrders = (await Order.where({webshopId: webshop.id})).filter(o => o.id !== orderId)
|
|
231
|
-
return (await checkStocks([orderId, ...otherOrders.map(o => o.id)], [...cartItems, ...otherOrders.flatMap(o => o.data.cart.items)], excludedCartItems))[0]
|
|
231
|
+
const otherOrders = (await Order.where({ webshopId: webshop.id })).filter(o => o.id !== orderId);
|
|
232
|
+
return (await checkStocks([orderId, ...otherOrders.map(o => o.id)], [...cartItems, ...otherOrders.flatMap(o => o.data.cart.items)], excludedCartItems))[0];
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
/** Allows to change the stock */
|
|
235
236
|
async function saveChanges() {
|
|
236
237
|
// Set products
|
|
237
238
|
webshop = (await Webshop.getByID(webshop.id))!;
|
|
238
|
-
webshop.products = [product, seatProduct, personProduct]
|
|
239
|
+
webshop.products = [product, seatProduct, personProduct];
|
|
239
240
|
await webshop.save();
|
|
240
241
|
await refreshAll();
|
|
241
242
|
}
|
|
@@ -243,16 +244,16 @@ describe("E2E.Stock", () => {
|
|
|
243
244
|
beforeAll(async () => {
|
|
244
245
|
stripeMocker = new StripeMocker();
|
|
245
246
|
stripeMocker.start();
|
|
246
|
-
organization = await new OrganizationFactory({}).create()
|
|
247
|
+
organization = await new OrganizationFactory({}).create();
|
|
247
248
|
stripeAccount = await stripeMocker.createStripeAccount(organization.id);
|
|
248
249
|
|
|
249
250
|
const user = await new UserFactory({
|
|
250
251
|
organization,
|
|
251
252
|
permissions: Permissions.create({
|
|
252
|
-
level: PermissionLevel.Full
|
|
253
|
-
})
|
|
254
|
-
}).create()
|
|
255
|
-
token = await Token.createToken(user)
|
|
253
|
+
level: PermissionLevel.Full,
|
|
254
|
+
}),
|
|
255
|
+
}).create();
|
|
256
|
+
token = await Token.createToken(user);
|
|
256
257
|
});
|
|
257
258
|
|
|
258
259
|
afterAll(() => {
|
|
@@ -266,70 +267,70 @@ describe("E2E.Stock", () => {
|
|
|
266
267
|
productPrice1 = ProductPrice.create({
|
|
267
268
|
name: 'productPrice1',
|
|
268
269
|
price: 100,
|
|
269
|
-
stock: 100
|
|
270
|
-
})
|
|
270
|
+
stock: 100,
|
|
271
|
+
});
|
|
271
272
|
|
|
272
273
|
productPrice2 = ProductPrice.create({
|
|
273
274
|
name: 'productPrice2',
|
|
274
275
|
price: 150,
|
|
275
|
-
stock: 100
|
|
276
|
-
})
|
|
276
|
+
stock: 100,
|
|
277
|
+
});
|
|
277
278
|
|
|
278
279
|
freeProductPrice = ProductPrice.create({
|
|
279
280
|
name: 'freeProductPrice',
|
|
280
281
|
price: 0,
|
|
281
|
-
stock: 100
|
|
282
|
-
})
|
|
282
|
+
stock: 100,
|
|
283
|
+
});
|
|
283
284
|
|
|
284
285
|
checkboxOption1 = Option.create({
|
|
285
286
|
name: 'checkboxOption1',
|
|
286
287
|
price: 10,
|
|
287
|
-
stock: 100
|
|
288
|
-
})
|
|
288
|
+
stock: 100,
|
|
289
|
+
});
|
|
289
290
|
|
|
290
291
|
checkboxOption2 = Option.create({
|
|
291
292
|
name: 'checkboxOption2',
|
|
292
293
|
price: 0,
|
|
293
|
-
stock: 100
|
|
294
|
-
})
|
|
294
|
+
stock: 100,
|
|
295
|
+
});
|
|
295
296
|
|
|
296
297
|
radioOption1 = Option.create({
|
|
297
298
|
name: 'radioOption1',
|
|
298
299
|
price: 10,
|
|
299
|
-
stock: 100
|
|
300
|
-
})
|
|
300
|
+
stock: 100,
|
|
301
|
+
});
|
|
301
302
|
|
|
302
303
|
radioOption2 = Option.create({
|
|
303
304
|
name: 'radioOption2',
|
|
304
305
|
price: 0,
|
|
305
|
-
stock: 100
|
|
306
|
-
})
|
|
306
|
+
stock: 100,
|
|
307
|
+
});
|
|
307
308
|
|
|
308
309
|
multipleChoiceOptionMenu = OptionMenu.create({
|
|
309
310
|
name: 'multipleChoiceOptionMenu',
|
|
310
311
|
multipleChoice: true,
|
|
311
|
-
options: [checkboxOption1, checkboxOption2]
|
|
312
|
-
})
|
|
312
|
+
options: [checkboxOption1, checkboxOption2],
|
|
313
|
+
});
|
|
313
314
|
|
|
314
315
|
chooseOneOptionMenu = OptionMenu.create({
|
|
315
316
|
name: 'chooseOneOptionMenu',
|
|
316
317
|
multipleChoice: false,
|
|
317
|
-
options: [radioOption1, radioOption2]
|
|
318
|
-
})
|
|
318
|
+
options: [radioOption1, radioOption2],
|
|
319
|
+
});
|
|
319
320
|
|
|
320
321
|
product = Product.create({
|
|
321
322
|
name: 'product',
|
|
322
323
|
stock: 100,
|
|
323
324
|
prices: [productPrice1, productPrice2, freeProductPrice],
|
|
324
|
-
optionMenus: [multipleChoiceOptionMenu, chooseOneOptionMenu]
|
|
325
|
-
})
|
|
325
|
+
optionMenus: [multipleChoiceOptionMenu, chooseOneOptionMenu],
|
|
326
|
+
});
|
|
326
327
|
|
|
327
328
|
personProduct = Product.create({
|
|
328
329
|
name: 'personProduct',
|
|
329
330
|
type: ProductType.Person,
|
|
330
|
-
stock: 100
|
|
331
|
-
})
|
|
332
|
-
personProductPrice = personProduct.prices[0]
|
|
331
|
+
stock: 100,
|
|
332
|
+
});
|
|
333
|
+
personProductPrice = personProduct.prices[0];
|
|
333
334
|
|
|
334
335
|
seatingPlan = SeatingPlan.create({
|
|
335
336
|
name: 'Testzaal',
|
|
@@ -340,135 +341,134 @@ describe("E2E.Stock", () => {
|
|
|
340
341
|
label: 'A',
|
|
341
342
|
seats: [
|
|
342
343
|
SeatingPlanSeat.create({
|
|
343
|
-
label: '1'
|
|
344
|
+
label: '1',
|
|
344
345
|
}),
|
|
345
346
|
SeatingPlanSeat.create({
|
|
346
|
-
label: '2'
|
|
347
|
+
label: '2',
|
|
347
348
|
}),
|
|
348
349
|
SeatingPlanSeat.create({
|
|
349
|
-
label: '3'
|
|
350
|
+
label: '3',
|
|
350
351
|
}),
|
|
351
352
|
SeatingPlanSeat.create({
|
|
352
|
-
label: '4'
|
|
353
|
-
})
|
|
354
|
-
]
|
|
353
|
+
label: '4',
|
|
354
|
+
}),
|
|
355
|
+
],
|
|
355
356
|
}),
|
|
356
357
|
SeatingPlanRow.create({
|
|
357
358
|
label: 'B',
|
|
358
359
|
seats: [
|
|
359
360
|
SeatingPlanSeat.create({
|
|
360
|
-
label: '1'
|
|
361
|
+
label: '1',
|
|
361
362
|
}),
|
|
362
363
|
SeatingPlanSeat.create({
|
|
363
|
-
label: '2'
|
|
364
|
+
label: '2',
|
|
364
365
|
}),
|
|
365
366
|
SeatingPlanSeat.create({
|
|
366
|
-
label: '3'
|
|
367
|
+
label: '3',
|
|
367
368
|
}),
|
|
368
369
|
SeatingPlanSeat.create({
|
|
369
|
-
label: '4'
|
|
370
|
-
})
|
|
371
|
-
]
|
|
372
|
-
})
|
|
373
|
-
]
|
|
374
|
-
})
|
|
375
|
-
]
|
|
376
|
-
})
|
|
377
|
-
meta.seatingPlans.addPut(seatingPlan)
|
|
370
|
+
label: '4',
|
|
371
|
+
}),
|
|
372
|
+
],
|
|
373
|
+
}),
|
|
374
|
+
],
|
|
375
|
+
}),
|
|
376
|
+
],
|
|
377
|
+
});
|
|
378
|
+
meta.seatingPlans.addPut(seatingPlan);
|
|
378
379
|
|
|
379
380
|
seatProduct = Product.create({
|
|
380
381
|
name: 'seatProduct',
|
|
381
382
|
type: ProductType.Ticket,
|
|
382
|
-
seatingPlanId: seatingPlan.id
|
|
383
|
-
})
|
|
384
|
-
seatProductPrice = seatProduct.prices[0]
|
|
383
|
+
seatingPlanId: seatingPlan.id,
|
|
384
|
+
});
|
|
385
|
+
seatProductPrice = seatProduct.prices[0];
|
|
385
386
|
|
|
386
387
|
// Takeout
|
|
387
388
|
takeoutMethod = WebshopTakeoutMethod.create({
|
|
388
389
|
name: 'Bakkerij Test',
|
|
389
|
-
address
|
|
390
|
-
})
|
|
390
|
+
address,
|
|
391
|
+
});
|
|
391
392
|
|
|
392
393
|
slot1 = WebshopTimeSlot.create({
|
|
393
394
|
date: new Date(),
|
|
394
395
|
maxPersons: 100,
|
|
395
|
-
maxOrders: 100
|
|
396
|
+
maxOrders: 100,
|
|
396
397
|
});
|
|
397
|
-
takeoutMethod.timeSlots.timeSlots.push(slot1)
|
|
398
|
+
takeoutMethod.timeSlots.timeSlots.push(slot1);
|
|
398
399
|
|
|
399
400
|
slot2 = WebshopTimeSlot.create({
|
|
400
401
|
date: new Date(),
|
|
401
402
|
maxPersons: 100,
|
|
402
403
|
maxOrders: 100,
|
|
403
|
-
startTime: 14*60,
|
|
404
|
-
endTime: 15*60
|
|
405
|
-
})
|
|
406
|
-
takeoutMethod.timeSlots.timeSlots.push(slot2)
|
|
407
|
-
meta.checkoutMethods.addPut(takeoutMethod)
|
|
408
|
-
|
|
404
|
+
startTime: 14 * 60,
|
|
405
|
+
endTime: 15 * 60,
|
|
406
|
+
});
|
|
407
|
+
takeoutMethod.timeSlots.timeSlots.push(slot2);
|
|
408
|
+
meta.checkoutMethods.addPut(takeoutMethod);
|
|
409
409
|
|
|
410
410
|
// Delivery
|
|
411
411
|
deliveryMethod = WebshopDeliveryMethod.create({
|
|
412
412
|
name: 'Delivery',
|
|
413
|
-
countries: [Country.Belgium]
|
|
414
|
-
})
|
|
413
|
+
countries: [Country.Belgium],
|
|
414
|
+
});
|
|
415
415
|
|
|
416
416
|
slot3 = WebshopTimeSlot.create({
|
|
417
417
|
date: new Date(),
|
|
418
418
|
maxPersons: 100,
|
|
419
|
-
maxOrders: 100
|
|
419
|
+
maxOrders: 100,
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
-
deliveryMethod.timeSlots.timeSlots.push(slot3)
|
|
423
|
-
meta.checkoutMethods.addPut(deliveryMethod)
|
|
422
|
+
deliveryMethod.timeSlots.timeSlots.push(slot3);
|
|
423
|
+
meta.checkoutMethods.addPut(deliveryMethod);
|
|
424
424
|
|
|
425
425
|
// OnSite
|
|
426
426
|
onSiteMethod = WebshopOnSiteMethod.create({
|
|
427
427
|
name: 'Onsite',
|
|
428
|
-
address
|
|
429
|
-
})
|
|
428
|
+
address,
|
|
429
|
+
});
|
|
430
430
|
|
|
431
431
|
slot4 = WebshopTimeSlot.create({
|
|
432
432
|
date: new Date(),
|
|
433
433
|
maxPersons: 100,
|
|
434
|
-
maxOrders: 100
|
|
434
|
+
maxOrders: 100,
|
|
435
435
|
});
|
|
436
436
|
|
|
437
|
-
onSiteMethod.timeSlots.timeSlots.push(slot4)
|
|
438
|
-
meta.checkoutMethods.addPut(onSiteMethod)
|
|
439
|
-
|
|
437
|
+
onSiteMethod.timeSlots.timeSlots.push(slot4);
|
|
438
|
+
meta.checkoutMethods.addPut(onSiteMethod);
|
|
439
|
+
|
|
440
440
|
const paymentConfigurationPatch = PaymentConfiguration.patch({
|
|
441
441
|
transferSettings: TransferSettings.create({
|
|
442
|
-
iban: 'BE56587127952688' // = random IBAN
|
|
442
|
+
iban: 'BE56587127952688', // = random IBAN
|
|
443
443
|
}),
|
|
444
|
-
})
|
|
445
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale)
|
|
446
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer)
|
|
447
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact)
|
|
444
|
+
});
|
|
445
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale);
|
|
446
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer);
|
|
447
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact);
|
|
448
448
|
|
|
449
449
|
const privatePaymentConfiguration = PrivatePaymentConfiguration.patch({
|
|
450
|
-
stripeAccountId: stripeAccount.id
|
|
451
|
-
})
|
|
450
|
+
stripeAccountId: stripeAccount.id,
|
|
451
|
+
});
|
|
452
452
|
|
|
453
453
|
meta = meta.patch({
|
|
454
|
-
paymentConfiguration: paymentConfigurationPatch
|
|
455
|
-
})
|
|
454
|
+
paymentConfiguration: paymentConfigurationPatch,
|
|
455
|
+
});
|
|
456
456
|
|
|
457
457
|
const privateMeta = WebshopPrivateMetaData.patch({
|
|
458
|
-
paymentConfiguration: privatePaymentConfiguration
|
|
459
|
-
})
|
|
458
|
+
paymentConfiguration: privatePaymentConfiguration,
|
|
459
|
+
});
|
|
460
460
|
|
|
461
461
|
webshop = await new WebshopFactory({
|
|
462
462
|
organizationId: organization.id,
|
|
463
463
|
name: 'Test webshop',
|
|
464
464
|
meta,
|
|
465
465
|
privateMeta,
|
|
466
|
-
products: [product, seatProduct, personProduct]
|
|
467
|
-
}).create()
|
|
466
|
+
products: [product, seatProduct, personProduct],
|
|
467
|
+
}).create();
|
|
468
468
|
});
|
|
469
469
|
|
|
470
470
|
describe('Reserving stock', () => {
|
|
471
|
-
test(
|
|
471
|
+
test('Online payments reserve the stock and remain if they succeed', async () => {
|
|
472
472
|
const orderData = OrderData.create({
|
|
473
473
|
paymentMethod: PaymentMethod.Bancontact,
|
|
474
474
|
checkoutMethod: onSiteMethod,
|
|
@@ -482,24 +482,24 @@ describe("E2E.Stock", () => {
|
|
|
482
482
|
options: [
|
|
483
483
|
CartItemOption.create({
|
|
484
484
|
optionMenu: multipleChoiceOptionMenu,
|
|
485
|
-
option: checkboxOption1
|
|
485
|
+
option: checkboxOption1,
|
|
486
486
|
}),
|
|
487
|
-
|
|
487
|
+
CartItemOption.create({
|
|
488
488
|
optionMenu: multipleChoiceOptionMenu,
|
|
489
|
-
option: checkboxOption2
|
|
489
|
+
option: checkboxOption2,
|
|
490
490
|
}),
|
|
491
491
|
CartItemOption.create({
|
|
492
492
|
optionMenu: chooseOneOptionMenu,
|
|
493
|
-
option: radioOption2
|
|
494
|
-
})
|
|
495
|
-
]
|
|
496
|
-
})
|
|
497
|
-
]
|
|
493
|
+
option: radioOption2,
|
|
494
|
+
}),
|
|
495
|
+
],
|
|
496
|
+
}),
|
|
497
|
+
],
|
|
498
498
|
}),
|
|
499
|
-
customer
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
const r = Request.buildJson(
|
|
499
|
+
customer,
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
503
503
|
|
|
504
504
|
const response = await testServer.test(endpoint, r);
|
|
505
505
|
expect(response.body).toBeDefined();
|
|
@@ -508,14 +508,14 @@ describe("E2E.Stock", () => {
|
|
|
508
508
|
await checkStock(order.id, order.data.cart.items);
|
|
509
509
|
|
|
510
510
|
// Cancel the payment
|
|
511
|
-
await stripeMocker.succeedPayment(stripeMocker.getLastIntent())
|
|
511
|
+
await stripeMocker.succeedPayment(stripeMocker.getLastIntent());
|
|
512
512
|
|
|
513
513
|
const updatedOrder = await checkStock(order.id, order.data.cart.items);
|
|
514
514
|
expect(updatedOrder.status).toBe(OrderStatus.Created);
|
|
515
515
|
expect(updatedOrder.number).toBeDefined();
|
|
516
516
|
});
|
|
517
517
|
|
|
518
|
-
test(
|
|
518
|
+
test('Online payments do not reserve the stock if creation fails', async () => {
|
|
519
519
|
stripeMocker.forceFailure();
|
|
520
520
|
const orderData = OrderData.create({
|
|
521
521
|
paymentMethod: PaymentMethod.Bancontact,
|
|
@@ -530,30 +530,30 @@ describe("E2E.Stock", () => {
|
|
|
530
530
|
options: [
|
|
531
531
|
CartItemOption.create({
|
|
532
532
|
optionMenu: multipleChoiceOptionMenu,
|
|
533
|
-
option: checkboxOption1
|
|
533
|
+
option: checkboxOption1,
|
|
534
534
|
}),
|
|
535
|
-
|
|
535
|
+
CartItemOption.create({
|
|
536
536
|
optionMenu: multipleChoiceOptionMenu,
|
|
537
|
-
option: checkboxOption2
|
|
537
|
+
option: checkboxOption2,
|
|
538
538
|
}),
|
|
539
539
|
CartItemOption.create({
|
|
540
540
|
optionMenu: chooseOneOptionMenu,
|
|
541
|
-
option: radioOption2
|
|
542
|
-
})
|
|
543
|
-
]
|
|
544
|
-
})
|
|
545
|
-
]
|
|
541
|
+
option: radioOption2,
|
|
542
|
+
}),
|
|
543
|
+
],
|
|
544
|
+
}),
|
|
545
|
+
],
|
|
546
546
|
}),
|
|
547
|
-
customer
|
|
548
|
-
})
|
|
549
|
-
|
|
550
|
-
const r = Request.buildJson(
|
|
547
|
+
customer,
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
551
551
|
|
|
552
552
|
await expect(testServer.test(endpoint, r)).toReject();
|
|
553
553
|
await checkStocks([], []);
|
|
554
554
|
});
|
|
555
555
|
|
|
556
|
-
test(
|
|
556
|
+
test('Free payments reserve the stock', async () => {
|
|
557
557
|
const orderData = OrderData.create({
|
|
558
558
|
paymentMethod: PaymentMethod.Unknown,
|
|
559
559
|
checkoutMethod: onSiteMethod,
|
|
@@ -567,20 +567,20 @@ describe("E2E.Stock", () => {
|
|
|
567
567
|
options: [
|
|
568
568
|
CartItemOption.create({
|
|
569
569
|
optionMenu: multipleChoiceOptionMenu,
|
|
570
|
-
option: checkboxOption2
|
|
570
|
+
option: checkboxOption2,
|
|
571
571
|
}),
|
|
572
572
|
CartItemOption.create({
|
|
573
573
|
optionMenu: chooseOneOptionMenu,
|
|
574
|
-
option: radioOption2
|
|
575
|
-
})
|
|
576
|
-
]
|
|
577
|
-
})
|
|
578
|
-
]
|
|
574
|
+
option: radioOption2,
|
|
575
|
+
}),
|
|
576
|
+
],
|
|
577
|
+
}),
|
|
578
|
+
],
|
|
579
579
|
}),
|
|
580
|
-
customer
|
|
581
|
-
})
|
|
582
|
-
|
|
583
|
-
const r = Request.buildJson(
|
|
580
|
+
customer,
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
584
584
|
|
|
585
585
|
const response = await testServer.test(endpoint, r);
|
|
586
586
|
expect(response.body).toBeDefined();
|
|
@@ -589,7 +589,7 @@ describe("E2E.Stock", () => {
|
|
|
589
589
|
await checkStock(order.id, order.data.cart.items);
|
|
590
590
|
});
|
|
591
591
|
|
|
592
|
-
test(
|
|
592
|
+
test('Transfer payments reserve the stock', async () => {
|
|
593
593
|
const orderData = OrderData.create({
|
|
594
594
|
paymentMethod: PaymentMethod.Transfer,
|
|
595
595
|
checkoutMethod: onSiteMethod,
|
|
@@ -603,24 +603,24 @@ describe("E2E.Stock", () => {
|
|
|
603
603
|
options: [
|
|
604
604
|
CartItemOption.create({
|
|
605
605
|
optionMenu: multipleChoiceOptionMenu,
|
|
606
|
-
option: checkboxOption1
|
|
606
|
+
option: checkboxOption1,
|
|
607
607
|
}),
|
|
608
|
-
|
|
608
|
+
CartItemOption.create({
|
|
609
609
|
optionMenu: multipleChoiceOptionMenu,
|
|
610
|
-
option: checkboxOption2
|
|
610
|
+
option: checkboxOption2,
|
|
611
611
|
}),
|
|
612
612
|
CartItemOption.create({
|
|
613
613
|
optionMenu: chooseOneOptionMenu,
|
|
614
|
-
option: radioOption2
|
|
615
|
-
})
|
|
616
|
-
]
|
|
617
|
-
})
|
|
618
|
-
]
|
|
614
|
+
option: radioOption2,
|
|
615
|
+
}),
|
|
616
|
+
],
|
|
617
|
+
}),
|
|
618
|
+
],
|
|
619
619
|
}),
|
|
620
|
-
customer
|
|
621
|
-
})
|
|
622
|
-
|
|
623
|
-
const r = Request.buildJson(
|
|
620
|
+
customer,
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
624
624
|
|
|
625
625
|
const response = await testServer.test(endpoint, r);
|
|
626
626
|
expect(response.body).toBeDefined();
|
|
@@ -629,10 +629,10 @@ describe("E2E.Stock", () => {
|
|
|
629
629
|
await checkStock(order.id, order.data.cart.items);
|
|
630
630
|
});
|
|
631
631
|
|
|
632
|
-
test(
|
|
632
|
+
test('Transfer payments do not reserve the stock if iban is missing and throws on validating', async () => {
|
|
633
633
|
webshop.meta.paymentConfiguration.transferSettings.iban = null;
|
|
634
634
|
await webshop.save();
|
|
635
|
-
|
|
635
|
+
|
|
636
636
|
const orderData = OrderData.create({
|
|
637
637
|
paymentMethod: PaymentMethod.Transfer,
|
|
638
638
|
checkoutMethod: onSiteMethod,
|
|
@@ -646,30 +646,30 @@ describe("E2E.Stock", () => {
|
|
|
646
646
|
options: [
|
|
647
647
|
CartItemOption.create({
|
|
648
648
|
optionMenu: multipleChoiceOptionMenu,
|
|
649
|
-
option: checkboxOption1
|
|
649
|
+
option: checkboxOption1,
|
|
650
650
|
}),
|
|
651
|
-
|
|
651
|
+
CartItemOption.create({
|
|
652
652
|
optionMenu: multipleChoiceOptionMenu,
|
|
653
|
-
option: checkboxOption2
|
|
653
|
+
option: checkboxOption2,
|
|
654
654
|
}),
|
|
655
655
|
CartItemOption.create({
|
|
656
656
|
optionMenu: chooseOneOptionMenu,
|
|
657
|
-
option: radioOption2
|
|
658
|
-
})
|
|
659
|
-
]
|
|
660
|
-
})
|
|
661
|
-
]
|
|
657
|
+
option: radioOption2,
|
|
658
|
+
}),
|
|
659
|
+
],
|
|
660
|
+
}),
|
|
661
|
+
],
|
|
662
662
|
}),
|
|
663
|
-
customer
|
|
664
|
-
})
|
|
665
|
-
|
|
666
|
-
const r = Request.buildJson(
|
|
663
|
+
customer,
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
667
667
|
|
|
668
668
|
await expect(testServer.test(endpoint, r)).rejects.toThrow('Missing IBAN');
|
|
669
669
|
await checkStocks([], []);
|
|
670
670
|
});
|
|
671
671
|
|
|
672
|
-
test(
|
|
672
|
+
test('POS payments reserve the stock', async () => {
|
|
673
673
|
const orderData = OrderData.create({
|
|
674
674
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
675
675
|
checkoutMethod: takeoutMethod,
|
|
@@ -683,20 +683,20 @@ describe("E2E.Stock", () => {
|
|
|
683
683
|
options: [
|
|
684
684
|
CartItemOption.create({
|
|
685
685
|
optionMenu: multipleChoiceOptionMenu,
|
|
686
|
-
option: checkboxOption2
|
|
686
|
+
option: checkboxOption2,
|
|
687
687
|
}),
|
|
688
688
|
CartItemOption.create({
|
|
689
689
|
optionMenu: chooseOneOptionMenu,
|
|
690
|
-
option: radioOption1
|
|
691
|
-
})
|
|
692
|
-
]
|
|
693
|
-
})
|
|
694
|
-
]
|
|
690
|
+
option: radioOption1,
|
|
691
|
+
}),
|
|
692
|
+
],
|
|
693
|
+
}),
|
|
694
|
+
],
|
|
695
695
|
}),
|
|
696
|
-
customer
|
|
697
|
-
})
|
|
698
|
-
|
|
699
|
-
const r = Request.buildJson(
|
|
696
|
+
customer,
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
700
700
|
|
|
701
701
|
const response = await testServer.test(endpoint, r);
|
|
702
702
|
expect(response.body).toBeDefined();
|
|
@@ -705,7 +705,7 @@ describe("E2E.Stock", () => {
|
|
|
705
705
|
await checkStock(order.id, order.data.cart.items);
|
|
706
706
|
});
|
|
707
707
|
|
|
708
|
-
test(
|
|
708
|
+
test('Orders placed by an admin reserve the stock', async () => {
|
|
709
709
|
const orderData = OrderData.create({
|
|
710
710
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
711
711
|
checkoutMethod: takeoutMethod,
|
|
@@ -719,31 +719,31 @@ describe("E2E.Stock", () => {
|
|
|
719
719
|
options: [
|
|
720
720
|
CartItemOption.create({
|
|
721
721
|
optionMenu: multipleChoiceOptionMenu,
|
|
722
|
-
option: checkboxOption2
|
|
722
|
+
option: checkboxOption2,
|
|
723
723
|
}),
|
|
724
724
|
CartItemOption.create({
|
|
725
725
|
optionMenu: chooseOneOptionMenu,
|
|
726
|
-
option: radioOption1
|
|
727
|
-
})
|
|
728
|
-
]
|
|
729
|
-
})
|
|
730
|
-
]
|
|
726
|
+
option: radioOption1,
|
|
727
|
+
}),
|
|
728
|
+
],
|
|
729
|
+
}),
|
|
730
|
+
],
|
|
731
731
|
}),
|
|
732
|
-
customer
|
|
733
|
-
})
|
|
732
|
+
customer,
|
|
733
|
+
});
|
|
734
734
|
|
|
735
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
735
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
736
736
|
|
|
737
737
|
const orderPatch = PrivateOrder.create({
|
|
738
738
|
id: uuidv4(),
|
|
739
739
|
data: orderData,
|
|
740
|
-
webshopId: webshop.id
|
|
740
|
+
webshopId: webshop.id,
|
|
741
741
|
});
|
|
742
742
|
patchArray.addPut(orderPatch);
|
|
743
743
|
|
|
744
744
|
// Send a patch
|
|
745
|
-
const r = Request.buildJson(
|
|
746
|
-
r.headers.authorization =
|
|
745
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
746
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
747
747
|
|
|
748
748
|
const response = await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
749
749
|
expect(response.body).toBeDefined();
|
|
@@ -751,8 +751,7 @@ describe("E2E.Stock", () => {
|
|
|
751
751
|
await checkStock(order.id, order.data.cart.items);
|
|
752
752
|
});
|
|
753
753
|
|
|
754
|
-
test(
|
|
755
|
-
|
|
754
|
+
test('Orders placed by an admin do not reserve the stock if IBAN is missing', async () => {
|
|
756
755
|
webshop.meta.paymentConfiguration.transferSettings.iban = null;
|
|
757
756
|
await webshop.save();
|
|
758
757
|
|
|
@@ -769,37 +768,37 @@ describe("E2E.Stock", () => {
|
|
|
769
768
|
options: [
|
|
770
769
|
CartItemOption.create({
|
|
771
770
|
optionMenu: multipleChoiceOptionMenu,
|
|
772
|
-
option: checkboxOption2
|
|
771
|
+
option: checkboxOption2,
|
|
773
772
|
}),
|
|
774
773
|
CartItemOption.create({
|
|
775
774
|
optionMenu: chooseOneOptionMenu,
|
|
776
|
-
option: radioOption1
|
|
777
|
-
})
|
|
778
|
-
]
|
|
779
|
-
})
|
|
780
|
-
]
|
|
775
|
+
option: radioOption1,
|
|
776
|
+
}),
|
|
777
|
+
],
|
|
778
|
+
}),
|
|
779
|
+
],
|
|
781
780
|
}),
|
|
782
|
-
customer
|
|
783
|
-
})
|
|
781
|
+
customer,
|
|
782
|
+
});
|
|
784
783
|
|
|
785
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
784
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
786
785
|
|
|
787
786
|
const orderPatch = PrivateOrder.create({
|
|
788
787
|
id: uuidv4(),
|
|
789
788
|
data: orderData,
|
|
790
|
-
webshopId: webshop.id
|
|
789
|
+
webshopId: webshop.id,
|
|
791
790
|
});
|
|
792
791
|
patchArray.addPut(orderPatch);
|
|
793
792
|
|
|
794
793
|
// Send a patch
|
|
795
|
-
const r = Request.buildJson(
|
|
796
|
-
r.headers.authorization =
|
|
794
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
795
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
797
796
|
|
|
798
797
|
await expect(testServer.test(patchWebshopOrdersEndpoint, r)).rejects.toThrow('Missing IBAN');
|
|
799
798
|
await checkStocks([], []);
|
|
800
799
|
});
|
|
801
800
|
|
|
802
|
-
test(
|
|
801
|
+
test('Chosen seats reserve the stock for POS order', async () => {
|
|
803
802
|
const orderData = OrderData.create({
|
|
804
803
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
805
804
|
checkoutMethod: takeoutMethod,
|
|
@@ -814,21 +813,21 @@ describe("E2E.Stock", () => {
|
|
|
814
813
|
CartReservedSeat.create({
|
|
815
814
|
section: seatingPlan.sections[0].id,
|
|
816
815
|
row: 'A',
|
|
817
|
-
seat: '1'
|
|
816
|
+
seat: '1',
|
|
818
817
|
}),
|
|
819
818
|
CartReservedSeat.create({
|
|
820
819
|
section: seatingPlan.sections[0].id,
|
|
821
820
|
row: 'A',
|
|
822
|
-
seat: '2'
|
|
823
|
-
})
|
|
824
|
-
]
|
|
825
|
-
})
|
|
826
|
-
]
|
|
821
|
+
seat: '2',
|
|
822
|
+
}),
|
|
823
|
+
],
|
|
824
|
+
}),
|
|
825
|
+
],
|
|
827
826
|
}),
|
|
828
|
-
customer
|
|
829
|
-
})
|
|
830
|
-
|
|
831
|
-
const r = Request.buildJson(
|
|
827
|
+
customer,
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
832
831
|
|
|
833
832
|
const response = await testServer.test(endpoint, r);
|
|
834
833
|
expect(response.body).toBeDefined();
|
|
@@ -837,7 +836,7 @@ describe("E2E.Stock", () => {
|
|
|
837
836
|
await checkStock(order.id, order.data.cart.items);
|
|
838
837
|
});
|
|
839
838
|
|
|
840
|
-
test(
|
|
839
|
+
test('Chosen seats reserve the stock for an admin order', async () => {
|
|
841
840
|
const orderData = OrderData.create({
|
|
842
841
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
843
842
|
checkoutMethod: takeoutMethod,
|
|
@@ -852,31 +851,31 @@ describe("E2E.Stock", () => {
|
|
|
852
851
|
CartReservedSeat.create({
|
|
853
852
|
section: seatingPlan.sections[0].id,
|
|
854
853
|
row: 'A',
|
|
855
|
-
seat: '1'
|
|
854
|
+
seat: '1',
|
|
856
855
|
}),
|
|
857
856
|
CartReservedSeat.create({
|
|
858
857
|
section: seatingPlan.sections[0].id,
|
|
859
858
|
row: 'A',
|
|
860
|
-
seat: '2'
|
|
861
|
-
})
|
|
862
|
-
]
|
|
863
|
-
})
|
|
864
|
-
]
|
|
859
|
+
seat: '2',
|
|
860
|
+
}),
|
|
861
|
+
],
|
|
862
|
+
}),
|
|
863
|
+
],
|
|
865
864
|
}),
|
|
866
|
-
customer
|
|
867
|
-
})
|
|
868
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
865
|
+
customer,
|
|
866
|
+
});
|
|
867
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
869
868
|
|
|
870
869
|
const orderPatch = PrivateOrder.create({
|
|
871
870
|
id: uuidv4(),
|
|
872
871
|
data: orderData,
|
|
873
|
-
webshopId: webshop.id
|
|
872
|
+
webshopId: webshop.id,
|
|
874
873
|
});
|
|
875
874
|
patchArray.addPut(orderPatch);
|
|
876
875
|
|
|
877
876
|
// Send a patch
|
|
878
|
-
const r = Request.buildJson(
|
|
879
|
-
r.headers.authorization =
|
|
877
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
878
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
880
879
|
|
|
881
880
|
const response = await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
882
881
|
expect(response.body).toBeDefined();
|
|
@@ -884,7 +883,7 @@ describe("E2E.Stock", () => {
|
|
|
884
883
|
await checkStock(order.id, order.data.cart.items);
|
|
885
884
|
});
|
|
886
885
|
|
|
887
|
-
test(
|
|
886
|
+
test('Amount of a cart item should match the amount of chosen seats', async () => {
|
|
888
887
|
const orderData = OrderData.create({
|
|
889
888
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
890
889
|
checkoutMethod: takeoutMethod,
|
|
@@ -899,27 +898,26 @@ describe("E2E.Stock", () => {
|
|
|
899
898
|
CartReservedSeat.create({
|
|
900
899
|
section: seatingPlan.sections[0].id,
|
|
901
900
|
row: 'A',
|
|
902
|
-
seat: '1'
|
|
903
|
-
})
|
|
904
|
-
]
|
|
905
|
-
})
|
|
906
|
-
]
|
|
901
|
+
seat: '1',
|
|
902
|
+
}),
|
|
903
|
+
],
|
|
904
|
+
}),
|
|
905
|
+
],
|
|
907
906
|
}),
|
|
908
|
-
customer
|
|
909
|
-
})
|
|
910
|
-
|
|
911
|
-
const r = Request.buildJson(
|
|
907
|
+
customer,
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
912
911
|
await expect(testServer.test(endpoint, r)).rejects.toThrow('Invalid seats');
|
|
913
912
|
});
|
|
914
913
|
|
|
915
|
-
test.todo(
|
|
916
|
-
|
|
917
|
-
test.todo("Amount of persons and orders for a delivery method is calculated correctly");
|
|
914
|
+
test.todo('Amount of persons and orders for a takeout method is calculated correctly');
|
|
918
915
|
|
|
916
|
+
test.todo('Amount of persons and orders for a delivery method is calculated correctly');
|
|
919
917
|
});
|
|
920
918
|
|
|
921
919
|
describe('Full stock', () => {
|
|
922
|
-
test(
|
|
920
|
+
test('Cannot place an order when product stock is full', async () => {
|
|
923
921
|
// Set stock
|
|
924
922
|
product.stock = 2;
|
|
925
923
|
await saveChanges();
|
|
@@ -937,25 +935,25 @@ describe("E2E.Stock", () => {
|
|
|
937
935
|
options: [
|
|
938
936
|
CartItemOption.create({
|
|
939
937
|
optionMenu: multipleChoiceOptionMenu,
|
|
940
|
-
option: checkboxOption2
|
|
938
|
+
option: checkboxOption2,
|
|
941
939
|
}),
|
|
942
940
|
CartItemOption.create({
|
|
943
941
|
optionMenu: chooseOneOptionMenu,
|
|
944
|
-
option: radioOption1
|
|
945
|
-
})
|
|
946
|
-
]
|
|
947
|
-
})
|
|
948
|
-
]
|
|
942
|
+
option: radioOption1,
|
|
943
|
+
}),
|
|
944
|
+
],
|
|
945
|
+
}),
|
|
946
|
+
],
|
|
949
947
|
}),
|
|
950
|
-
customer
|
|
951
|
-
})
|
|
952
|
-
|
|
953
|
-
const r = Request.buildJson(
|
|
948
|
+
customer,
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
954
952
|
|
|
955
953
|
await expect(testServer.test(endpoint, r)).rejects.toThrow('Product unavailable');
|
|
956
954
|
});
|
|
957
955
|
|
|
958
|
-
test(
|
|
956
|
+
test('Cannot place an order when product price stock is full', async () => {
|
|
959
957
|
// Set stock
|
|
960
958
|
productPrice1.stock = 2;
|
|
961
959
|
await saveChanges();
|
|
@@ -973,25 +971,25 @@ describe("E2E.Stock", () => {
|
|
|
973
971
|
options: [
|
|
974
972
|
CartItemOption.create({
|
|
975
973
|
optionMenu: multipleChoiceOptionMenu,
|
|
976
|
-
option: checkboxOption2
|
|
974
|
+
option: checkboxOption2,
|
|
977
975
|
}),
|
|
978
976
|
CartItemOption.create({
|
|
979
977
|
optionMenu: chooseOneOptionMenu,
|
|
980
|
-
option: radioOption1
|
|
981
|
-
})
|
|
982
|
-
]
|
|
983
|
-
})
|
|
984
|
-
]
|
|
978
|
+
option: radioOption1,
|
|
979
|
+
}),
|
|
980
|
+
],
|
|
981
|
+
}),
|
|
982
|
+
],
|
|
985
983
|
}),
|
|
986
|
-
customer
|
|
987
|
-
})
|
|
988
|
-
|
|
989
|
-
const r = Request.buildJson(
|
|
984
|
+
customer,
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
990
988
|
|
|
991
|
-
await expect(testServer.test(endpoint, r)).rejects.toHaveProperty('human','Er zijn nog maar 2 stuks van productPrice1 beschikbaar');
|
|
989
|
+
await expect(testServer.test(endpoint, r)).rejects.toHaveProperty('human', 'Er zijn nog maar 2 stuks van productPrice1 beschikbaar');
|
|
992
990
|
});
|
|
993
991
|
|
|
994
|
-
test(
|
|
992
|
+
test('Cannot place an order when option stock is full', async () => {
|
|
995
993
|
// Set stock
|
|
996
994
|
radioOption1.stock = 2;
|
|
997
995
|
await saveChanges();
|
|
@@ -1009,25 +1007,25 @@ describe("E2E.Stock", () => {
|
|
|
1009
1007
|
options: [
|
|
1010
1008
|
CartItemOption.create({
|
|
1011
1009
|
optionMenu: multipleChoiceOptionMenu,
|
|
1012
|
-
option: checkboxOption2
|
|
1010
|
+
option: checkboxOption2,
|
|
1013
1011
|
}),
|
|
1014
1012
|
CartItemOption.create({
|
|
1015
1013
|
optionMenu: chooseOneOptionMenu,
|
|
1016
|
-
option: radioOption1
|
|
1017
|
-
})
|
|
1018
|
-
]
|
|
1019
|
-
})
|
|
1020
|
-
]
|
|
1014
|
+
option: radioOption1,
|
|
1015
|
+
}),
|
|
1016
|
+
],
|
|
1017
|
+
}),
|
|
1018
|
+
],
|
|
1021
1019
|
}),
|
|
1022
|
-
customer
|
|
1023
|
-
})
|
|
1024
|
-
|
|
1025
|
-
const r = Request.buildJson("POST", `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1020
|
+
customer,
|
|
1021
|
+
});
|
|
1026
1022
|
|
|
1027
|
-
|
|
1023
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1024
|
+
|
|
1025
|
+
await expect(testServer.test(endpoint, r)).rejects.toHaveProperty('human', 'Er zijn nog maar 2 stuks van radioOption1 beschikbaar');
|
|
1028
1026
|
});
|
|
1029
1027
|
|
|
1030
|
-
test(
|
|
1028
|
+
test('Cannot place an order when multiple choice option stock is full', async () => {
|
|
1031
1029
|
// Set stock
|
|
1032
1030
|
checkboxOption2.stock = 2;
|
|
1033
1031
|
await saveChanges();
|
|
@@ -1045,37 +1043,37 @@ describe("E2E.Stock", () => {
|
|
|
1045
1043
|
options: [
|
|
1046
1044
|
CartItemOption.create({
|
|
1047
1045
|
optionMenu: multipleChoiceOptionMenu,
|
|
1048
|
-
option: checkboxOption2
|
|
1046
|
+
option: checkboxOption2,
|
|
1049
1047
|
}),
|
|
1050
1048
|
CartItemOption.create({
|
|
1051
1049
|
optionMenu: chooseOneOptionMenu,
|
|
1052
|
-
option: radioOption1
|
|
1053
|
-
})
|
|
1054
|
-
]
|
|
1055
|
-
})
|
|
1056
|
-
]
|
|
1050
|
+
option: radioOption1,
|
|
1051
|
+
}),
|
|
1052
|
+
],
|
|
1053
|
+
}),
|
|
1054
|
+
],
|
|
1057
1055
|
}),
|
|
1058
|
-
customer
|
|
1059
|
-
})
|
|
1060
|
-
|
|
1061
|
-
const r = Request.buildJson(
|
|
1056
|
+
customer,
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1062
1060
|
|
|
1063
|
-
await expect(testServer.test(endpoint, r)).rejects.toHaveProperty('human','Er zijn nog maar 2 stuks van checkboxOption2 beschikbaar');
|
|
1061
|
+
await expect(testServer.test(endpoint, r)).rejects.toHaveProperty('human', 'Er zijn nog maar 2 stuks van checkboxOption2 beschikbaar');
|
|
1064
1062
|
});
|
|
1065
1063
|
|
|
1066
|
-
test.todo(
|
|
1064
|
+
test.todo('Cannot place an order when takeout persons stock is full');
|
|
1067
1065
|
|
|
1068
|
-
test.todo(
|
|
1066
|
+
test.todo('Cannot place an order when takeout orders stock is full');
|
|
1069
1067
|
|
|
1070
|
-
test(
|
|
1068
|
+
test('Cannot place an order for a reserved seat', async () => {
|
|
1071
1069
|
// Set stock
|
|
1072
1070
|
seatProduct.reservedSeats = [
|
|
1073
1071
|
ReservedSeat.create({
|
|
1074
1072
|
section: seatingPlan.sections[0].id,
|
|
1075
1073
|
row: 'A',
|
|
1076
|
-
seat: '1'
|
|
1077
|
-
})
|
|
1078
|
-
]
|
|
1074
|
+
seat: '1',
|
|
1075
|
+
}),
|
|
1076
|
+
];
|
|
1079
1077
|
await saveChanges();
|
|
1080
1078
|
|
|
1081
1079
|
const orderData = OrderData.create({
|
|
@@ -1092,35 +1090,35 @@ describe("E2E.Stock", () => {
|
|
|
1092
1090
|
CartReservedSeat.create({
|
|
1093
1091
|
section: seatingPlan.sections[0].id,
|
|
1094
1092
|
row: 'A',
|
|
1095
|
-
seat: '1'
|
|
1093
|
+
seat: '1',
|
|
1096
1094
|
}),
|
|
1097
1095
|
CartReservedSeat.create({
|
|
1098
1096
|
section: seatingPlan.sections[0].id,
|
|
1099
1097
|
row: 'A',
|
|
1100
|
-
seat: '2'
|
|
1101
|
-
})
|
|
1102
|
-
]
|
|
1103
|
-
})
|
|
1104
|
-
]
|
|
1098
|
+
seat: '2',
|
|
1099
|
+
}),
|
|
1100
|
+
],
|
|
1101
|
+
}),
|
|
1102
|
+
],
|
|
1105
1103
|
}),
|
|
1106
|
-
customer
|
|
1107
|
-
})
|
|
1108
|
-
|
|
1109
|
-
const r = Request.buildJson(
|
|
1104
|
+
customer,
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1110
1108
|
await expect(testServer.test(endpoint, r)).rejects.toThrow('Seats unavailable');
|
|
1111
1109
|
});
|
|
1112
1110
|
|
|
1113
|
-
test(
|
|
1111
|
+
test('Admin cannot place an order for a reserved seat', async () => {
|
|
1114
1112
|
// Set stock
|
|
1115
1113
|
seatProduct.reservedSeats = [
|
|
1116
1114
|
ReservedSeat.create({
|
|
1117
1115
|
section: seatingPlan.sections[0].id,
|
|
1118
1116
|
row: 'A',
|
|
1119
|
-
seat: '1'
|
|
1120
|
-
})
|
|
1121
|
-
]
|
|
1117
|
+
seat: '1',
|
|
1118
|
+
}),
|
|
1119
|
+
];
|
|
1122
1120
|
await saveChanges();
|
|
1123
|
-
|
|
1121
|
+
|
|
1124
1122
|
const orderData = OrderData.create({
|
|
1125
1123
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
1126
1124
|
checkoutMethod: takeoutMethod,
|
|
@@ -1135,39 +1133,39 @@ describe("E2E.Stock", () => {
|
|
|
1135
1133
|
CartReservedSeat.create({
|
|
1136
1134
|
section: seatingPlan.sections[0].id,
|
|
1137
1135
|
row: 'A',
|
|
1138
|
-
seat: '1'
|
|
1136
|
+
seat: '1',
|
|
1139
1137
|
}),
|
|
1140
1138
|
CartReservedSeat.create({
|
|
1141
1139
|
section: seatingPlan.sections[0].id,
|
|
1142
1140
|
row: 'A',
|
|
1143
|
-
seat: '2'
|
|
1144
|
-
})
|
|
1145
|
-
]
|
|
1146
|
-
})
|
|
1147
|
-
]
|
|
1141
|
+
seat: '2',
|
|
1142
|
+
}),
|
|
1143
|
+
],
|
|
1144
|
+
}),
|
|
1145
|
+
],
|
|
1148
1146
|
}),
|
|
1149
|
-
customer
|
|
1150
|
-
})
|
|
1151
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1147
|
+
customer,
|
|
1148
|
+
});
|
|
1149
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1152
1150
|
|
|
1153
1151
|
const orderPatch = PrivateOrder.create({
|
|
1154
1152
|
id: uuidv4(),
|
|
1155
1153
|
data: orderData,
|
|
1156
|
-
webshopId: webshop.id
|
|
1154
|
+
webshopId: webshop.id,
|
|
1157
1155
|
});
|
|
1158
1156
|
patchArray.addPut(orderPatch);
|
|
1159
1157
|
|
|
1160
1158
|
// Send a patch
|
|
1161
|
-
const r = Request.buildJson(
|
|
1162
|
-
r.headers.authorization =
|
|
1159
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1160
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1163
1161
|
await expect(testServer.test(patchWebshopOrdersEndpoint, r)).rejects.toThrow('Seats unavailable');
|
|
1164
1162
|
});
|
|
1165
1163
|
|
|
1166
|
-
test.todo(
|
|
1164
|
+
test.todo('Admin cannot edit an an order to a reserved seat');
|
|
1167
1165
|
});
|
|
1168
1166
|
|
|
1169
1167
|
describe('Cleaning up stock', () => {
|
|
1170
|
-
test(
|
|
1168
|
+
test('Stock is returned when a payment failed', async () => {
|
|
1171
1169
|
const orderData = OrderData.create({
|
|
1172
1170
|
paymentMethod: PaymentMethod.Bancontact,
|
|
1173
1171
|
checkoutMethod: onSiteMethod,
|
|
@@ -1181,24 +1179,24 @@ describe("E2E.Stock", () => {
|
|
|
1181
1179
|
options: [
|
|
1182
1180
|
CartItemOption.create({
|
|
1183
1181
|
optionMenu: multipleChoiceOptionMenu,
|
|
1184
|
-
option: checkboxOption1
|
|
1182
|
+
option: checkboxOption1,
|
|
1185
1183
|
}),
|
|
1186
|
-
|
|
1184
|
+
CartItemOption.create({
|
|
1187
1185
|
optionMenu: multipleChoiceOptionMenu,
|
|
1188
|
-
option: checkboxOption2
|
|
1186
|
+
option: checkboxOption2,
|
|
1189
1187
|
}),
|
|
1190
1188
|
CartItemOption.create({
|
|
1191
1189
|
optionMenu: chooseOneOptionMenu,
|
|
1192
|
-
option: radioOption2
|
|
1193
|
-
})
|
|
1194
|
-
]
|
|
1195
|
-
})
|
|
1196
|
-
]
|
|
1190
|
+
option: radioOption2,
|
|
1191
|
+
}),
|
|
1192
|
+
],
|
|
1193
|
+
}),
|
|
1194
|
+
],
|
|
1197
1195
|
}),
|
|
1198
|
-
customer
|
|
1199
|
-
})
|
|
1200
|
-
|
|
1201
|
-
const r = Request.buildJson(
|
|
1196
|
+
customer,
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1202
1200
|
|
|
1203
1201
|
const response = await testServer.test(endpoint, r);
|
|
1204
1202
|
expect(response.body).toBeDefined();
|
|
@@ -1207,7 +1205,7 @@ describe("E2E.Stock", () => {
|
|
|
1207
1205
|
await checkStock(order.id, order.data.cart.items);
|
|
1208
1206
|
|
|
1209
1207
|
// Cancel the payment
|
|
1210
|
-
await stripeMocker.failPayment(stripeMocker.getLastIntent())
|
|
1208
|
+
await stripeMocker.failPayment(stripeMocker.getLastIntent());
|
|
1211
1209
|
|
|
1212
1210
|
const updatedOrder = await checkStock(order.id, [], order.data.cart.items);
|
|
1213
1211
|
expect(updatedOrder.status).toBe(OrderStatus.Deleted);
|
|
@@ -1217,8 +1215,8 @@ describe("E2E.Stock", () => {
|
|
|
1217
1215
|
describe('Modifying orders', () => {
|
|
1218
1216
|
let order: Order;
|
|
1219
1217
|
let baseOrder: Order;
|
|
1220
|
-
let productCartItem: CartItem|undefined;
|
|
1221
|
-
let personCartItem: CartItem|undefined;
|
|
1218
|
+
let productCartItem: CartItem | undefined;
|
|
1219
|
+
let personCartItem: CartItem | undefined;
|
|
1222
1220
|
|
|
1223
1221
|
beforeEach(async () => {
|
|
1224
1222
|
productCartItem = CartItem.create({
|
|
@@ -1228,20 +1226,20 @@ describe("E2E.Stock", () => {
|
|
|
1228
1226
|
options: [
|
|
1229
1227
|
CartItemOption.create({
|
|
1230
1228
|
optionMenu: multipleChoiceOptionMenu,
|
|
1231
|
-
option: checkboxOption1
|
|
1229
|
+
option: checkboxOption1,
|
|
1232
1230
|
}),
|
|
1233
1231
|
CartItemOption.create({
|
|
1234
1232
|
optionMenu: chooseOneOptionMenu,
|
|
1235
|
-
option: radioOption1
|
|
1236
|
-
})
|
|
1237
|
-
]
|
|
1238
|
-
})
|
|
1233
|
+
option: radioOption1,
|
|
1234
|
+
}),
|
|
1235
|
+
],
|
|
1236
|
+
});
|
|
1239
1237
|
|
|
1240
1238
|
personCartItem = CartItem.create({
|
|
1241
1239
|
product: personProduct,
|
|
1242
1240
|
productPrice: personProductPrice,
|
|
1243
|
-
amount: 2
|
|
1244
|
-
})
|
|
1241
|
+
amount: 2,
|
|
1242
|
+
});
|
|
1245
1243
|
|
|
1246
1244
|
{
|
|
1247
1245
|
const orderData = OrderData.create({
|
|
@@ -1251,24 +1249,23 @@ describe("E2E.Stock", () => {
|
|
|
1251
1249
|
cart: Cart.create({
|
|
1252
1250
|
items: [
|
|
1253
1251
|
productCartItem,
|
|
1254
|
-
personCartItem
|
|
1255
|
-
]
|
|
1252
|
+
personCartItem,
|
|
1253
|
+
],
|
|
1256
1254
|
}),
|
|
1257
|
-
customer
|
|
1258
|
-
})
|
|
1259
|
-
|
|
1260
|
-
const r = Request.buildJson(
|
|
1255
|
+
customer,
|
|
1256
|
+
});
|
|
1257
|
+
|
|
1258
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1261
1259
|
|
|
1262
1260
|
const response = await testServer.test(endpoint, r);
|
|
1263
1261
|
expect(response.body).toBeDefined();
|
|
1264
1262
|
const orderStruct = response.body.order;
|
|
1265
1263
|
|
|
1266
|
-
|
|
1267
1264
|
// Now check the stock has changed for the product
|
|
1268
1265
|
order = await checkStock(orderStruct.id, [productCartItem, personCartItem]);
|
|
1269
1266
|
}
|
|
1270
1267
|
|
|
1271
|
-
// Make sure all items in the cart, options etc, have at least a usedStock of 1, to also test they don't decrease when making
|
|
1268
|
+
// Make sure all items in the cart, options etc, have at least a usedStock of 1, to also test they don't decrease when making
|
|
1272
1269
|
// changes to roders
|
|
1273
1270
|
{
|
|
1274
1271
|
const orderData = OrderData.create({
|
|
@@ -1284,13 +1281,13 @@ describe("E2E.Stock", () => {
|
|
|
1284
1281
|
options: [
|
|
1285
1282
|
CartItemOption.create({
|
|
1286
1283
|
optionMenu: multipleChoiceOptionMenu,
|
|
1287
|
-
option: checkboxOption1
|
|
1284
|
+
option: checkboxOption1,
|
|
1288
1285
|
}),
|
|
1289
1286
|
CartItemOption.create({
|
|
1290
1287
|
optionMenu: chooseOneOptionMenu,
|
|
1291
|
-
option: radioOption1
|
|
1292
|
-
})
|
|
1293
|
-
]
|
|
1288
|
+
option: radioOption1,
|
|
1289
|
+
}),
|
|
1290
|
+
],
|
|
1294
1291
|
}),
|
|
1295
1292
|
CartItem.create({
|
|
1296
1293
|
product,
|
|
@@ -1299,49 +1296,48 @@ describe("E2E.Stock", () => {
|
|
|
1299
1296
|
options: [
|
|
1300
1297
|
CartItemOption.create({
|
|
1301
1298
|
optionMenu: multipleChoiceOptionMenu,
|
|
1302
|
-
option: checkboxOption2
|
|
1299
|
+
option: checkboxOption2,
|
|
1303
1300
|
}),
|
|
1304
1301
|
CartItemOption.create({
|
|
1305
1302
|
optionMenu: chooseOneOptionMenu,
|
|
1306
|
-
option: radioOption2
|
|
1307
|
-
})
|
|
1308
|
-
]
|
|
1303
|
+
option: radioOption2,
|
|
1304
|
+
}),
|
|
1305
|
+
],
|
|
1309
1306
|
}),
|
|
1310
1307
|
CartItem.create({
|
|
1311
1308
|
product: personProduct,
|
|
1312
1309
|
productPrice: personProductPrice,
|
|
1313
|
-
amount: 1
|
|
1314
|
-
})
|
|
1315
|
-
]
|
|
1310
|
+
amount: 1,
|
|
1311
|
+
}),
|
|
1312
|
+
],
|
|
1316
1313
|
}),
|
|
1317
|
-
customer
|
|
1318
|
-
})
|
|
1319
|
-
|
|
1320
|
-
const r = Request.buildJson(
|
|
1314
|
+
customer,
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1321
1318
|
|
|
1322
1319
|
const response = await testServer.test(endpoint, r);
|
|
1323
1320
|
expect(response.body).toBeDefined();
|
|
1324
1321
|
const orderStruct = response.body.order;
|
|
1325
1322
|
|
|
1326
|
-
|
|
1327
1323
|
// Now check the stock has changed for the product
|
|
1328
1324
|
const orders = await checkStocks([order.id, orderStruct.id], [productCartItem, personCartItem, ...orderStruct.data.cart.items]);
|
|
1329
|
-
baseOrder = orders.find(o => o.id === orderStruct.id)
|
|
1325
|
+
baseOrder = orders.find(o => o.id === orderStruct.id)!;
|
|
1330
1326
|
}
|
|
1331
1327
|
});
|
|
1332
1328
|
|
|
1333
|
-
test(
|
|
1329
|
+
test('Stock is removed when a product is removed or added in two steps', async () => {
|
|
1334
1330
|
{
|
|
1335
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1331
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1336
1332
|
|
|
1337
|
-
const cartPatch = Cart.patch({})
|
|
1338
|
-
cartPatch.items.addDelete(productCartItem!.id)
|
|
1339
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1333
|
+
const cartPatch = Cart.patch({});
|
|
1334
|
+
cartPatch.items.addDelete(productCartItem!.id);
|
|
1335
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1340
1336
|
patchArray.addPatch(orderPatch);
|
|
1341
1337
|
|
|
1342
1338
|
// Send a patch
|
|
1343
|
-
const r = Request.buildJson(
|
|
1344
|
-
r.headers.authorization =
|
|
1339
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1340
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1345
1341
|
|
|
1346
1342
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1347
1343
|
|
|
@@ -1349,10 +1345,10 @@ describe("E2E.Stock", () => {
|
|
|
1349
1345
|
}
|
|
1350
1346
|
|
|
1351
1347
|
{
|
|
1352
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1348
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1353
1349
|
|
|
1354
|
-
const cartPatch = Cart.patch({})
|
|
1355
|
-
cartPatch.items.addDelete(personCartItem!.id)
|
|
1350
|
+
const cartPatch = Cart.patch({});
|
|
1351
|
+
cartPatch.items.addDelete(personCartItem!.id);
|
|
1356
1352
|
const newItem = CartItem.create({
|
|
1357
1353
|
product,
|
|
1358
1354
|
productPrice: productPrice2,
|
|
@@ -1360,21 +1356,21 @@ describe("E2E.Stock", () => {
|
|
|
1360
1356
|
options: [
|
|
1361
1357
|
CartItemOption.create({
|
|
1362
1358
|
optionMenu: chooseOneOptionMenu,
|
|
1363
|
-
option: radioOption2
|
|
1364
|
-
})
|
|
1365
|
-
]
|
|
1359
|
+
option: radioOption2,
|
|
1360
|
+
}),
|
|
1361
|
+
],
|
|
1366
1362
|
});
|
|
1367
1363
|
|
|
1368
1364
|
cartPatch.items.addPut(
|
|
1369
|
-
newItem
|
|
1370
|
-
)
|
|
1365
|
+
newItem,
|
|
1366
|
+
);
|
|
1371
1367
|
|
|
1372
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1368
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1373
1369
|
patchArray.addPatch(orderPatch);
|
|
1374
1370
|
|
|
1375
1371
|
// Send a patch
|
|
1376
|
-
const r = Request.buildJson(
|
|
1377
|
-
r.headers.authorization =
|
|
1372
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1373
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1378
1374
|
|
|
1379
1375
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1380
1376
|
|
|
@@ -1382,14 +1378,14 @@ describe("E2E.Stock", () => {
|
|
|
1382
1378
|
}
|
|
1383
1379
|
});
|
|
1384
1380
|
|
|
1385
|
-
test(
|
|
1386
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1381
|
+
test('Stock is removed when a product is removed or added in single step', async () => {
|
|
1382
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1383
|
+
|
|
1384
|
+
const cartPatch = Cart.patch({});
|
|
1385
|
+
cartPatch.items.addDelete(productCartItem!.id);
|
|
1386
|
+
cartPatch.items.addDelete(personCartItem!.id);
|
|
1387
|
+
cartPatch.items.addPut(personCartItem!);
|
|
1387
1388
|
|
|
1388
|
-
const cartPatch = Cart.patch({})
|
|
1389
|
-
cartPatch.items.addDelete(productCartItem!.id)
|
|
1390
|
-
cartPatch.items.addDelete(personCartItem!.id)
|
|
1391
|
-
cartPatch.items.addPut(personCartItem!)
|
|
1392
|
-
|
|
1393
1389
|
const newItem = CartItem.create({
|
|
1394
1390
|
product,
|
|
1395
1391
|
productPrice: productPrice2,
|
|
@@ -1397,65 +1393,65 @@ describe("E2E.Stock", () => {
|
|
|
1397
1393
|
options: [
|
|
1398
1394
|
CartItemOption.create({
|
|
1399
1395
|
optionMenu: chooseOneOptionMenu,
|
|
1400
|
-
option: radioOption2
|
|
1401
|
-
})
|
|
1402
|
-
]
|
|
1396
|
+
option: radioOption2,
|
|
1397
|
+
}),
|
|
1398
|
+
],
|
|
1403
1399
|
});
|
|
1404
1400
|
|
|
1405
1401
|
cartPatch.items.addPut(
|
|
1406
|
-
newItem
|
|
1407
|
-
)
|
|
1402
|
+
newItem,
|
|
1403
|
+
);
|
|
1408
1404
|
|
|
1409
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1405
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1410
1406
|
patchArray.addPatch(orderPatch);
|
|
1411
1407
|
|
|
1412
1408
|
// Send a patch
|
|
1413
|
-
const r = Request.buildJson(
|
|
1414
|
-
r.headers.authorization =
|
|
1409
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1410
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1415
1411
|
|
|
1416
1412
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1417
1413
|
|
|
1418
1414
|
order = await checkStock(order.id, [personCartItem!, newItem]);
|
|
1419
1415
|
});
|
|
1420
1416
|
|
|
1421
|
-
test(
|
|
1422
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1417
|
+
test('Stock is adjusted if product amount is changed', async () => {
|
|
1418
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1423
1419
|
|
|
1424
|
-
const cartPatch = Cart.patch({})
|
|
1420
|
+
const cartPatch = Cart.patch({});
|
|
1425
1421
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1426
1422
|
id: productCartItem!.id,
|
|
1427
|
-
amount: 6
|
|
1428
|
-
}))
|
|
1423
|
+
amount: 6,
|
|
1424
|
+
}));
|
|
1429
1425
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1430
1426
|
id: personCartItem!.id,
|
|
1431
|
-
amount: 13
|
|
1432
|
-
}))
|
|
1433
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1427
|
+
amount: 13,
|
|
1428
|
+
}));
|
|
1429
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1434
1430
|
patchArray.addPatch(orderPatch);
|
|
1435
1431
|
|
|
1436
1432
|
// Send a patch
|
|
1437
|
-
const r = Request.buildJson(
|
|
1438
|
-
r.headers.authorization =
|
|
1433
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1434
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1439
1435
|
|
|
1440
1436
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1441
1437
|
|
|
1442
1438
|
await checkStock(order.id, [personCartItem!, productCartItem!]);
|
|
1443
1439
|
});
|
|
1444
1440
|
|
|
1445
|
-
test(
|
|
1446
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1441
|
+
test('Stock is changed if timeslot is changed', async () => {
|
|
1442
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1447
1443
|
|
|
1448
1444
|
const orderPatch = PrivateOrder.patch({
|
|
1449
|
-
id: order.id,
|
|
1445
|
+
id: order.id,
|
|
1450
1446
|
data: OrderData.patch({
|
|
1451
|
-
timeSlot: slot2
|
|
1452
|
-
})
|
|
1447
|
+
timeSlot: slot2,
|
|
1448
|
+
}),
|
|
1453
1449
|
});
|
|
1454
1450
|
patchArray.addPatch(orderPatch);
|
|
1455
1451
|
|
|
1456
1452
|
// Send a patch
|
|
1457
|
-
const r = Request.buildJson(
|
|
1458
|
-
r.headers.authorization =
|
|
1453
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1454
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1459
1455
|
|
|
1460
1456
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1461
1457
|
|
|
@@ -1463,20 +1459,20 @@ describe("E2E.Stock", () => {
|
|
|
1463
1459
|
});
|
|
1464
1460
|
|
|
1465
1461
|
test('Stock is changed if productPrice is changed', async () => {
|
|
1466
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1467
|
-
|
|
1468
|
-
const cartPatch = Cart.patch({})
|
|
1462
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1463
|
+
|
|
1464
|
+
const cartPatch = Cart.patch({});
|
|
1469
1465
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1470
1466
|
id: productCartItem!.id,
|
|
1471
|
-
productPrice: productPrice2
|
|
1472
|
-
}))
|
|
1467
|
+
productPrice: productPrice2,
|
|
1468
|
+
}));
|
|
1473
1469
|
|
|
1474
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1470
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1475
1471
|
patchArray.addPatch(orderPatch);
|
|
1476
1472
|
|
|
1477
1473
|
// Send a patch
|
|
1478
|
-
const r = Request.buildJson(
|
|
1479
|
-
r.headers.authorization =
|
|
1474
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1475
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1480
1476
|
|
|
1481
1477
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1482
1478
|
|
|
@@ -1484,25 +1480,25 @@ describe("E2E.Stock", () => {
|
|
|
1484
1480
|
});
|
|
1485
1481
|
|
|
1486
1482
|
test('Stock is changed when option is removed', async () => {
|
|
1487
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1488
|
-
|
|
1489
|
-
const cartPatch = Cart.patch({})
|
|
1483
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1484
|
+
|
|
1485
|
+
const cartPatch = Cart.patch({});
|
|
1490
1486
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1491
1487
|
id: productCartItem!.id,
|
|
1492
1488
|
options: [
|
|
1493
1489
|
CartItemOption.create({
|
|
1494
1490
|
optionMenu: chooseOneOptionMenu,
|
|
1495
|
-
option: radioOption1
|
|
1496
|
-
})
|
|
1497
|
-
]
|
|
1498
|
-
}))
|
|
1491
|
+
option: radioOption1,
|
|
1492
|
+
}),
|
|
1493
|
+
],
|
|
1494
|
+
}));
|
|
1499
1495
|
|
|
1500
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1496
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1501
1497
|
patchArray.addPatch(orderPatch);
|
|
1502
1498
|
|
|
1503
1499
|
// Send a patch
|
|
1504
|
-
const r = Request.buildJson(
|
|
1505
|
-
r.headers.authorization =
|
|
1500
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1501
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1506
1502
|
|
|
1507
1503
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1508
1504
|
|
|
@@ -1510,29 +1506,29 @@ describe("E2E.Stock", () => {
|
|
|
1510
1506
|
});
|
|
1511
1507
|
|
|
1512
1508
|
test('Stock is changed when option is changed', async () => {
|
|
1513
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1514
|
-
|
|
1515
|
-
const cartPatch = Cart.patch({})
|
|
1509
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1510
|
+
|
|
1511
|
+
const cartPatch = Cart.patch({});
|
|
1516
1512
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1517
1513
|
id: productCartItem!.id,
|
|
1518
1514
|
options: [
|
|
1519
1515
|
CartItemOption.create({
|
|
1520
1516
|
optionMenu: chooseOneOptionMenu,
|
|
1521
|
-
option: radioOption2
|
|
1517
|
+
option: radioOption2,
|
|
1522
1518
|
}),
|
|
1523
1519
|
CartItemOption.create({
|
|
1524
1520
|
optionMenu: multipleChoiceOptionMenu,
|
|
1525
|
-
option: checkboxOption2
|
|
1526
|
-
})
|
|
1527
|
-
]
|
|
1528
|
-
}))
|
|
1521
|
+
option: checkboxOption2,
|
|
1522
|
+
}),
|
|
1523
|
+
],
|
|
1524
|
+
}));
|
|
1529
1525
|
|
|
1530
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1526
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1531
1527
|
patchArray.addPatch(orderPatch);
|
|
1532
1528
|
|
|
1533
1529
|
// Send a patch
|
|
1534
|
-
const r = Request.buildJson(
|
|
1535
|
-
r.headers.authorization =
|
|
1530
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1531
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1536
1532
|
|
|
1537
1533
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1538
1534
|
|
|
@@ -1540,44 +1536,44 @@ describe("E2E.Stock", () => {
|
|
|
1540
1536
|
});
|
|
1541
1537
|
|
|
1542
1538
|
test('Stock is changed when option is added', async () => {
|
|
1543
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1544
|
-
|
|
1545
|
-
const cartPatch = Cart.patch({})
|
|
1539
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1540
|
+
|
|
1541
|
+
const cartPatch = Cart.patch({});
|
|
1546
1542
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1547
1543
|
id: productCartItem!.id,
|
|
1548
1544
|
options: [
|
|
1549
1545
|
CartItemOption.create({
|
|
1550
1546
|
optionMenu: chooseOneOptionMenu,
|
|
1551
|
-
option: radioOption1
|
|
1547
|
+
option: radioOption1,
|
|
1552
1548
|
}),
|
|
1553
1549
|
CartItemOption.create({
|
|
1554
1550
|
optionMenu: multipleChoiceOptionMenu,
|
|
1555
|
-
option: checkboxOption1
|
|
1551
|
+
option: checkboxOption1,
|
|
1556
1552
|
}),
|
|
1557
1553
|
CartItemOption.create({
|
|
1558
1554
|
optionMenu: multipleChoiceOptionMenu,
|
|
1559
|
-
option: checkboxOption2
|
|
1560
|
-
})
|
|
1561
|
-
]
|
|
1562
|
-
}))
|
|
1555
|
+
option: checkboxOption2,
|
|
1556
|
+
}),
|
|
1557
|
+
],
|
|
1558
|
+
}));
|
|
1563
1559
|
|
|
1564
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1560
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1565
1561
|
patchArray.addPatch(orderPatch);
|
|
1566
1562
|
|
|
1567
1563
|
// Send a patch
|
|
1568
|
-
const r = Request.buildJson(
|
|
1569
|
-
r.headers.authorization =
|
|
1564
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1565
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1570
1566
|
|
|
1571
1567
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1572
1568
|
|
|
1573
1569
|
await checkStock(order.id, [personCartItem!, productCartItem!]);
|
|
1574
1570
|
});
|
|
1575
1571
|
|
|
1576
|
-
test(
|
|
1577
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1572
|
+
test('Stock is changed if delivery method is changed', async () => {
|
|
1573
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1578
1574
|
|
|
1579
1575
|
const orderPatch = PrivateOrder.patch({
|
|
1580
|
-
id: order.id,
|
|
1576
|
+
id: order.id,
|
|
1581
1577
|
data: OrderData.patch({
|
|
1582
1578
|
checkoutMethod: deliveryMethod,
|
|
1583
1579
|
timeSlot: slot3,
|
|
@@ -1585,33 +1581,33 @@ describe("E2E.Stock", () => {
|
|
|
1585
1581
|
...address,
|
|
1586
1582
|
cityId: '',
|
|
1587
1583
|
parentCityId: null,
|
|
1588
|
-
provinceId: ''
|
|
1589
|
-
})
|
|
1590
|
-
})
|
|
1584
|
+
provinceId: '',
|
|
1585
|
+
}),
|
|
1586
|
+
}),
|
|
1591
1587
|
});
|
|
1592
1588
|
patchArray.addPatch(orderPatch);
|
|
1593
1589
|
|
|
1594
1590
|
// Send a patch
|
|
1595
|
-
const r = Request.buildJson(
|
|
1596
|
-
r.headers.authorization =
|
|
1591
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1592
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1597
1593
|
|
|
1598
1594
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1599
1595
|
await checkStock(order.id, [personCartItem!, productCartItem!]);
|
|
1600
1596
|
});
|
|
1601
1597
|
|
|
1602
|
-
test(
|
|
1598
|
+
test('Stock is returned when an order is canceled and added when uncanceled again', async () => {
|
|
1603
1599
|
{
|
|
1604
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1600
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1605
1601
|
|
|
1606
1602
|
const orderPatch = PrivateOrder.patch({
|
|
1607
|
-
id: order.id,
|
|
1608
|
-
status: OrderStatus.Canceled
|
|
1603
|
+
id: order.id,
|
|
1604
|
+
status: OrderStatus.Canceled,
|
|
1609
1605
|
});
|
|
1610
1606
|
patchArray.addPatch(orderPatch);
|
|
1611
1607
|
|
|
1612
1608
|
// Send a patch
|
|
1613
|
-
const r = Request.buildJson(
|
|
1614
|
-
r.headers.authorization =
|
|
1609
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1610
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1615
1611
|
|
|
1616
1612
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1617
1613
|
|
|
@@ -1620,17 +1616,17 @@ describe("E2E.Stock", () => {
|
|
|
1620
1616
|
|
|
1621
1617
|
// Uncancel
|
|
1622
1618
|
{
|
|
1623
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1619
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1624
1620
|
|
|
1625
1621
|
const orderPatch = PrivateOrder.patch({
|
|
1626
|
-
id: order.id,
|
|
1627
|
-
status: OrderStatus.Created
|
|
1622
|
+
id: order.id,
|
|
1623
|
+
status: OrderStatus.Created,
|
|
1628
1624
|
});
|
|
1629
1625
|
patchArray.addPatch(orderPatch);
|
|
1630
1626
|
|
|
1631
1627
|
// Send a patch
|
|
1632
|
-
const r = Request.buildJson(
|
|
1633
|
-
r.headers.authorization =
|
|
1628
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1629
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1634
1630
|
|
|
1635
1631
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1636
1632
|
|
|
@@ -1638,19 +1634,19 @@ describe("E2E.Stock", () => {
|
|
|
1638
1634
|
}
|
|
1639
1635
|
});
|
|
1640
1636
|
|
|
1641
|
-
test(
|
|
1637
|
+
test('Stock is returned when an order is deleted and added when undeleted', async () => {
|
|
1642
1638
|
{
|
|
1643
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1639
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1644
1640
|
|
|
1645
1641
|
const orderPatch = PrivateOrder.patch({
|
|
1646
|
-
id: order.id,
|
|
1647
|
-
status: OrderStatus.Deleted
|
|
1642
|
+
id: order.id,
|
|
1643
|
+
status: OrderStatus.Deleted,
|
|
1648
1644
|
});
|
|
1649
1645
|
patchArray.addPatch(orderPatch);
|
|
1650
1646
|
|
|
1651
1647
|
// Send a patch
|
|
1652
|
-
const r = Request.buildJson(
|
|
1653
|
-
r.headers.authorization =
|
|
1648
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1649
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1654
1650
|
|
|
1655
1651
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1656
1652
|
|
|
@@ -1659,17 +1655,17 @@ describe("E2E.Stock", () => {
|
|
|
1659
1655
|
|
|
1660
1656
|
// Undelete
|
|
1661
1657
|
{
|
|
1662
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1658
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1663
1659
|
|
|
1664
1660
|
const orderPatch = PrivateOrder.patch({
|
|
1665
|
-
id: order.id,
|
|
1666
|
-
status: OrderStatus.Created
|
|
1661
|
+
id: order.id,
|
|
1662
|
+
status: OrderStatus.Created,
|
|
1667
1663
|
});
|
|
1668
1664
|
patchArray.addPatch(orderPatch);
|
|
1669
1665
|
|
|
1670
1666
|
// Send a patch
|
|
1671
|
-
const r = Request.buildJson(
|
|
1672
|
-
r.headers.authorization =
|
|
1667
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1668
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1673
1669
|
|
|
1674
1670
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1675
1671
|
|
|
@@ -1680,7 +1676,7 @@ describe("E2E.Stock", () => {
|
|
|
1680
1676
|
|
|
1681
1677
|
describe('Modifying seat orders', () => {
|
|
1682
1678
|
let order: Order;
|
|
1683
|
-
let seatCartItem: CartItem|undefined;
|
|
1679
|
+
let seatCartItem: CartItem | undefined;
|
|
1684
1680
|
|
|
1685
1681
|
beforeEach(async () => {
|
|
1686
1682
|
seatCartItem = CartItem.create({
|
|
@@ -1691,15 +1687,15 @@ describe("E2E.Stock", () => {
|
|
|
1691
1687
|
CartReservedSeat.create({
|
|
1692
1688
|
section: seatingPlan.sections[0].id,
|
|
1693
1689
|
row: 'A',
|
|
1694
|
-
seat: '1'
|
|
1690
|
+
seat: '1',
|
|
1695
1691
|
}),
|
|
1696
1692
|
CartReservedSeat.create({
|
|
1697
1693
|
section: seatingPlan.sections[0].id,
|
|
1698
1694
|
row: 'A',
|
|
1699
|
-
seat: '2'
|
|
1700
|
-
})
|
|
1701
|
-
]
|
|
1702
|
-
})
|
|
1695
|
+
seat: '2',
|
|
1696
|
+
}),
|
|
1697
|
+
],
|
|
1698
|
+
});
|
|
1703
1699
|
|
|
1704
1700
|
const orderData = OrderData.create({
|
|
1705
1701
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
@@ -1707,13 +1703,13 @@ describe("E2E.Stock", () => {
|
|
|
1707
1703
|
timeSlot: slot1,
|
|
1708
1704
|
cart: Cart.create({
|
|
1709
1705
|
items: [
|
|
1710
|
-
seatCartItem
|
|
1711
|
-
]
|
|
1706
|
+
seatCartItem,
|
|
1707
|
+
],
|
|
1712
1708
|
}),
|
|
1713
|
-
customer
|
|
1714
|
-
})
|
|
1715
|
-
|
|
1716
|
-
const r = Request.buildJson(
|
|
1709
|
+
customer,
|
|
1710
|
+
});
|
|
1711
|
+
|
|
1712
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1717
1713
|
|
|
1718
1714
|
const response = await testServer.test(endpoint, r);
|
|
1719
1715
|
expect(response.body).toBeDefined();
|
|
@@ -1723,11 +1719,11 @@ describe("E2E.Stock", () => {
|
|
|
1723
1719
|
order = await checkStock(orderStruct.id, [seatCartItem]);
|
|
1724
1720
|
});
|
|
1725
1721
|
|
|
1726
|
-
test(
|
|
1727
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1722
|
+
test('Stock is removed when a product is removed and another is added', async () => {
|
|
1723
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1728
1724
|
|
|
1729
|
-
const cartPatch = Cart.patch({})
|
|
1730
|
-
cartPatch.items.addDelete(seatCartItem!.id)
|
|
1725
|
+
const cartPatch = Cart.patch({});
|
|
1726
|
+
cartPatch.items.addDelete(seatCartItem!.id);
|
|
1731
1727
|
|
|
1732
1728
|
const newItem = CartItem.create({
|
|
1733
1729
|
product: seatProduct,
|
|
@@ -1737,32 +1733,31 @@ describe("E2E.Stock", () => {
|
|
|
1737
1733
|
CartReservedSeat.create({
|
|
1738
1734
|
section: seatingPlan.sections[0].id,
|
|
1739
1735
|
row: 'B',
|
|
1740
|
-
seat: '1'
|
|
1741
|
-
})
|
|
1742
|
-
]
|
|
1736
|
+
seat: '1',
|
|
1737
|
+
}),
|
|
1738
|
+
],
|
|
1743
1739
|
});
|
|
1744
1740
|
|
|
1745
1741
|
cartPatch.items.addPut(
|
|
1746
|
-
newItem
|
|
1747
|
-
)
|
|
1742
|
+
newItem,
|
|
1743
|
+
);
|
|
1748
1744
|
|
|
1749
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1745
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1750
1746
|
patchArray.addPatch(orderPatch);
|
|
1751
1747
|
|
|
1752
1748
|
// Send a patch
|
|
1753
|
-
const r = Request.buildJson(
|
|
1754
|
-
r.headers.authorization =
|
|
1749
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1750
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1755
1751
|
|
|
1756
1752
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1757
1753
|
|
|
1758
1754
|
await checkStock(order.id, [newItem]);
|
|
1759
|
-
|
|
1760
1755
|
});
|
|
1761
1756
|
|
|
1762
|
-
test(
|
|
1763
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1757
|
+
test('Stock is adjusted if extra seat is selected', async () => {
|
|
1758
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1764
1759
|
|
|
1765
|
-
const cartPatch = Cart.patch({})
|
|
1760
|
+
const cartPatch = Cart.patch({});
|
|
1766
1761
|
const c = CartItem.patch({
|
|
1767
1762
|
id: seatCartItem!.id,
|
|
1768
1763
|
amount: 3,
|
|
@@ -1770,78 +1765,78 @@ describe("E2E.Stock", () => {
|
|
|
1770
1765
|
CartReservedSeat.create({
|
|
1771
1766
|
section: seatingPlan.sections[0].id,
|
|
1772
1767
|
row: 'A',
|
|
1773
|
-
seat: '1'
|
|
1768
|
+
seat: '1',
|
|
1774
1769
|
}),
|
|
1775
1770
|
CartReservedSeat.create({
|
|
1776
1771
|
section: seatingPlan.sections[0].id,
|
|
1777
1772
|
row: 'A',
|
|
1778
|
-
seat: '2'
|
|
1773
|
+
seat: '2',
|
|
1779
1774
|
}),
|
|
1780
1775
|
CartReservedSeat.create({
|
|
1781
1776
|
section: seatingPlan.sections[0].id,
|
|
1782
1777
|
row: 'A',
|
|
1783
|
-
seat: '3'
|
|
1784
|
-
})
|
|
1785
|
-
]
|
|
1778
|
+
seat: '3',
|
|
1779
|
+
}),
|
|
1780
|
+
],
|
|
1786
1781
|
});
|
|
1787
|
-
cartPatch.items.addPatch(c)
|
|
1782
|
+
cartPatch.items.addPatch(c);
|
|
1788
1783
|
|
|
1789
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1784
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1790
1785
|
patchArray.addPatch(orderPatch);
|
|
1791
1786
|
|
|
1792
1787
|
// Send a patch
|
|
1793
|
-
const r = Request.buildJson(
|
|
1794
|
-
r.headers.authorization =
|
|
1788
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1789
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1795
1790
|
|
|
1796
1791
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1797
1792
|
|
|
1798
1793
|
await checkStock(order.id, [seatCartItem!]);
|
|
1799
|
-
});
|
|
1794
|
+
});
|
|
1800
1795
|
|
|
1801
|
-
test(
|
|
1802
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1796
|
+
test('Reserved seats are changed when seats are moved', async () => {
|
|
1797
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1803
1798
|
|
|
1804
|
-
const cartPatch = Cart.patch({})
|
|
1799
|
+
const cartPatch = Cart.patch({});
|
|
1805
1800
|
cartPatch.items.addPatch(CartItem.patch({
|
|
1806
1801
|
id: seatCartItem?.id,
|
|
1807
1802
|
seats: [
|
|
1808
1803
|
CartReservedSeat.create({
|
|
1809
1804
|
section: seatingPlan.sections[0].id,
|
|
1810
1805
|
row: 'B',
|
|
1811
|
-
seat: '1'
|
|
1806
|
+
seat: '1',
|
|
1812
1807
|
}),
|
|
1813
1808
|
CartReservedSeat.create({
|
|
1814
1809
|
section: seatingPlan.sections[0].id,
|
|
1815
1810
|
row: 'B',
|
|
1816
|
-
seat: '2'
|
|
1817
|
-
})
|
|
1818
|
-
]
|
|
1819
|
-
}))
|
|
1820
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
1811
|
+
seat: '2',
|
|
1812
|
+
}),
|
|
1813
|
+
],
|
|
1814
|
+
}));
|
|
1815
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
1821
1816
|
patchArray.addPatch(orderPatch);
|
|
1822
1817
|
|
|
1823
1818
|
// Send a patch
|
|
1824
|
-
const r = Request.buildJson(
|
|
1825
|
-
r.headers.authorization =
|
|
1819
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1820
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1826
1821
|
|
|
1827
1822
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1828
1823
|
|
|
1829
1824
|
await checkStock(order.id, [seatCartItem!]);
|
|
1830
1825
|
});
|
|
1831
1826
|
|
|
1832
|
-
test(
|
|
1827
|
+
test('Stock is returned when an order is canceled and added when uncanceled again', async () => {
|
|
1833
1828
|
{
|
|
1834
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1829
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1835
1830
|
|
|
1836
1831
|
const orderPatch = PrivateOrder.patch({
|
|
1837
|
-
id: order.id,
|
|
1838
|
-
status: OrderStatus.Canceled
|
|
1832
|
+
id: order.id,
|
|
1833
|
+
status: OrderStatus.Canceled,
|
|
1839
1834
|
});
|
|
1840
1835
|
patchArray.addPatch(orderPatch);
|
|
1841
1836
|
|
|
1842
1837
|
// Send a patch
|
|
1843
|
-
const r = Request.buildJson(
|
|
1844
|
-
r.headers.authorization =
|
|
1838
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1839
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1845
1840
|
|
|
1846
1841
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1847
1842
|
|
|
@@ -1850,17 +1845,17 @@ describe("E2E.Stock", () => {
|
|
|
1850
1845
|
|
|
1851
1846
|
// Uncancel
|
|
1852
1847
|
{
|
|
1853
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1848
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1854
1849
|
|
|
1855
1850
|
const orderPatch = PrivateOrder.patch({
|
|
1856
|
-
id: order.id,
|
|
1857
|
-
status: OrderStatus.Created
|
|
1851
|
+
id: order.id,
|
|
1852
|
+
status: OrderStatus.Created,
|
|
1858
1853
|
});
|
|
1859
1854
|
patchArray.addPatch(orderPatch);
|
|
1860
1855
|
|
|
1861
1856
|
// Send a patch
|
|
1862
|
-
const r = Request.buildJson(
|
|
1863
|
-
r.headers.authorization =
|
|
1857
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1858
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1864
1859
|
|
|
1865
1860
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1866
1861
|
|
|
@@ -1868,19 +1863,19 @@ describe("E2E.Stock", () => {
|
|
|
1868
1863
|
}
|
|
1869
1864
|
});
|
|
1870
1865
|
|
|
1871
|
-
test(
|
|
1866
|
+
test('Stock is returned when an order is deleted and added when undeleted', async () => {
|
|
1872
1867
|
{
|
|
1873
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1868
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1874
1869
|
|
|
1875
1870
|
const orderPatch = PrivateOrder.patch({
|
|
1876
|
-
id: order.id,
|
|
1877
|
-
status: OrderStatus.Deleted
|
|
1871
|
+
id: order.id,
|
|
1872
|
+
status: OrderStatus.Deleted,
|
|
1878
1873
|
});
|
|
1879
1874
|
patchArray.addPatch(orderPatch);
|
|
1880
1875
|
|
|
1881
1876
|
// Send a patch
|
|
1882
|
-
const r = Request.buildJson(
|
|
1883
|
-
r.headers.authorization =
|
|
1877
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1878
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1884
1879
|
|
|
1885
1880
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1886
1881
|
|
|
@@ -1889,17 +1884,17 @@ describe("E2E.Stock", () => {
|
|
|
1889
1884
|
|
|
1890
1885
|
// Undelete
|
|
1891
1886
|
{
|
|
1892
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1887
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1893
1888
|
|
|
1894
1889
|
const orderPatch = PrivateOrder.patch({
|
|
1895
|
-
id: order.id,
|
|
1896
|
-
status: OrderStatus.Created
|
|
1890
|
+
id: order.id,
|
|
1891
|
+
status: OrderStatus.Created,
|
|
1897
1892
|
});
|
|
1898
1893
|
patchArray.addPatch(orderPatch);
|
|
1899
1894
|
|
|
1900
1895
|
// Send a patch
|
|
1901
|
-
const r = Request.buildJson(
|
|
1902
|
-
r.headers.authorization =
|
|
1896
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1897
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1903
1898
|
|
|
1904
1899
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1905
1900
|
|
|
@@ -1907,19 +1902,19 @@ describe("E2E.Stock", () => {
|
|
|
1907
1902
|
}
|
|
1908
1903
|
});
|
|
1909
1904
|
|
|
1910
|
-
test(
|
|
1905
|
+
test('Correctly handles duplicate seat booking recovery', async () => {
|
|
1911
1906
|
{
|
|
1912
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1907
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1913
1908
|
|
|
1914
1909
|
const orderPatch = PrivateOrder.patch({
|
|
1915
|
-
id: order.id,
|
|
1916
|
-
status: OrderStatus.Canceled
|
|
1910
|
+
id: order.id,
|
|
1911
|
+
status: OrderStatus.Canceled,
|
|
1917
1912
|
});
|
|
1918
1913
|
patchArray.addPatch(orderPatch);
|
|
1919
1914
|
|
|
1920
1915
|
// Send a patch
|
|
1921
|
-
const r = Request.buildJson(
|
|
1922
|
-
r.headers.authorization =
|
|
1916
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1917
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1923
1918
|
|
|
1924
1919
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1925
1920
|
|
|
@@ -1935,15 +1930,15 @@ describe("E2E.Stock", () => {
|
|
|
1935
1930
|
CartReservedSeat.create({
|
|
1936
1931
|
section: seatingPlan.sections[0].id,
|
|
1937
1932
|
row: 'A',
|
|
1938
|
-
seat: '1'
|
|
1933
|
+
seat: '1',
|
|
1939
1934
|
}),
|
|
1940
1935
|
CartReservedSeat.create({
|
|
1941
1936
|
section: seatingPlan.sections[0].id,
|
|
1942
1937
|
row: 'A',
|
|
1943
|
-
seat: '2'
|
|
1944
|
-
})
|
|
1945
|
-
]
|
|
1946
|
-
})
|
|
1938
|
+
seat: '2',
|
|
1939
|
+
}),
|
|
1940
|
+
],
|
|
1941
|
+
});
|
|
1947
1942
|
|
|
1948
1943
|
const orderData = OrderData.create({
|
|
1949
1944
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
@@ -1951,15 +1946,15 @@ describe("E2E.Stock", () => {
|
|
|
1951
1946
|
timeSlot: slot1,
|
|
1952
1947
|
cart: Cart.create({
|
|
1953
1948
|
items: [
|
|
1954
|
-
newItem
|
|
1955
|
-
]
|
|
1949
|
+
newItem,
|
|
1950
|
+
],
|
|
1956
1951
|
}),
|
|
1957
|
-
customer
|
|
1958
|
-
})
|
|
1952
|
+
customer,
|
|
1953
|
+
});
|
|
1959
1954
|
let orders: Order[];
|
|
1960
1955
|
|
|
1961
1956
|
{
|
|
1962
|
-
const r = Request.buildJson(
|
|
1957
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
1963
1958
|
|
|
1964
1959
|
const response = await testServer.test(endpoint, r);
|
|
1965
1960
|
expect(response.body).toBeDefined();
|
|
@@ -1971,17 +1966,17 @@ describe("E2E.Stock", () => {
|
|
|
1971
1966
|
|
|
1972
1967
|
// Uncancel
|
|
1973
1968
|
{
|
|
1974
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
1969
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
1975
1970
|
|
|
1976
1971
|
const orderPatch = PrivateOrder.patch({
|
|
1977
|
-
id: order.id,
|
|
1978
|
-
status: OrderStatus.Created
|
|
1972
|
+
id: order.id,
|
|
1973
|
+
status: OrderStatus.Created,
|
|
1979
1974
|
});
|
|
1980
1975
|
patchArray.addPatch(orderPatch);
|
|
1981
1976
|
|
|
1982
1977
|
// Send a patch
|
|
1983
|
-
const r = Request.buildJson(
|
|
1984
|
-
r.headers.authorization =
|
|
1978
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
1979
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
1985
1980
|
|
|
1986
1981
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
1987
1982
|
|
|
@@ -1991,58 +1986,58 @@ describe("E2E.Stock", () => {
|
|
|
1991
1986
|
// Now we are in a duplicate seat selected situation.
|
|
1992
1987
|
// To recover, move seats of one of the orders
|
|
1993
1988
|
// and check in the final result, all seats are still correctly reserved (once)
|
|
1994
|
-
|
|
1989
|
+
|
|
1995
1990
|
// Manual check
|
|
1996
1991
|
expect(seatProduct.reservedSeats).toHaveLength(4);
|
|
1997
1992
|
expect(seatProduct.reservedSeats).toIncludeSameMembers([
|
|
1998
1993
|
ReservedSeat.create({
|
|
1999
1994
|
section: seatingPlan.sections[0].id,
|
|
2000
1995
|
row: 'A',
|
|
2001
|
-
seat: '1'
|
|
1996
|
+
seat: '1',
|
|
2002
1997
|
}),
|
|
2003
1998
|
ReservedSeat.create({
|
|
2004
1999
|
section: seatingPlan.sections[0].id,
|
|
2005
2000
|
row: 'A',
|
|
2006
|
-
seat: '1'
|
|
2001
|
+
seat: '1',
|
|
2007
2002
|
}),
|
|
2008
2003
|
ReservedSeat.create({
|
|
2009
2004
|
section: seatingPlan.sections[0].id,
|
|
2010
2005
|
row: 'A',
|
|
2011
|
-
seat: '2'
|
|
2006
|
+
seat: '2',
|
|
2012
2007
|
}),
|
|
2013
2008
|
ReservedSeat.create({
|
|
2014
2009
|
section: seatingPlan.sections[0].id,
|
|
2015
2010
|
row: 'A',
|
|
2016
|
-
seat: '2'
|
|
2011
|
+
seat: '2',
|
|
2017
2012
|
}),
|
|
2018
|
-
])
|
|
2013
|
+
]);
|
|
2019
2014
|
|
|
2020
2015
|
// Move seats of first order
|
|
2021
2016
|
{
|
|
2022
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
2017
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
2023
2018
|
|
|
2024
|
-
const cartPatch = Cart.patch({})
|
|
2019
|
+
const cartPatch = Cart.patch({});
|
|
2025
2020
|
cartPatch.items.addPatch(CartItem.patch({
|
|
2026
2021
|
id: seatCartItem?.id,
|
|
2027
2022
|
seats: [
|
|
2028
2023
|
CartReservedSeat.create({
|
|
2029
2024
|
section: seatingPlan.sections[0].id,
|
|
2030
2025
|
row: 'B',
|
|
2031
|
-
seat: '1'
|
|
2026
|
+
seat: '1',
|
|
2032
2027
|
}),
|
|
2033
2028
|
CartReservedSeat.create({
|
|
2034
2029
|
section: seatingPlan.sections[0].id,
|
|
2035
2030
|
row: 'B',
|
|
2036
|
-
seat: '2'
|
|
2037
|
-
})
|
|
2038
|
-
]
|
|
2039
|
-
}))
|
|
2040
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
2031
|
+
seat: '2',
|
|
2032
|
+
}),
|
|
2033
|
+
],
|
|
2034
|
+
}));
|
|
2035
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
2041
2036
|
patchArray.addPatch(orderPatch);
|
|
2042
2037
|
|
|
2043
2038
|
// Send a patch
|
|
2044
|
-
const r = Request.buildJson(
|
|
2045
|
-
r.headers.authorization =
|
|
2039
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
2040
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
2046
2041
|
|
|
2047
2042
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
2048
2043
|
|
|
@@ -2055,46 +2050,46 @@ describe("E2E.Stock", () => {
|
|
|
2055
2050
|
ReservedSeat.create({
|
|
2056
2051
|
section: seatingPlan.sections[0].id,
|
|
2057
2052
|
row: 'A',
|
|
2058
|
-
seat: '1'
|
|
2053
|
+
seat: '1',
|
|
2059
2054
|
}),
|
|
2060
2055
|
ReservedSeat.create({
|
|
2061
2056
|
section: seatingPlan.sections[0].id,
|
|
2062
2057
|
row: 'B',
|
|
2063
|
-
seat: '1'
|
|
2058
|
+
seat: '1',
|
|
2064
2059
|
}),
|
|
2065
2060
|
ReservedSeat.create({
|
|
2066
2061
|
section: seatingPlan.sections[0].id,
|
|
2067
2062
|
row: 'A',
|
|
2068
|
-
seat: '2'
|
|
2063
|
+
seat: '2',
|
|
2069
2064
|
}),
|
|
2070
2065
|
ReservedSeat.create({
|
|
2071
2066
|
section: seatingPlan.sections[0].id,
|
|
2072
2067
|
row: 'B',
|
|
2073
|
-
seat: '2'
|
|
2068
|
+
seat: '2',
|
|
2074
2069
|
}),
|
|
2075
|
-
])
|
|
2070
|
+
]);
|
|
2076
2071
|
});
|
|
2077
2072
|
|
|
2078
|
-
test(
|
|
2073
|
+
test('Patching an order triggers an auto recovery of not reserved seats', async () => {
|
|
2079
2074
|
// This is required to recover from bugs in stock changes.
|
|
2080
2075
|
// Simply patching all orders will fix the stock.
|
|
2081
2076
|
|
|
2082
2077
|
// Manually remove all reserved seats = caused by a past bug
|
|
2083
|
-
seatProduct.reservedSeats = []
|
|
2078
|
+
seatProduct.reservedSeats = [];
|
|
2084
2079
|
await saveChanges();
|
|
2085
2080
|
|
|
2086
2081
|
{
|
|
2087
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
2082
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
2088
2083
|
|
|
2089
2084
|
const orderPatch = PrivateOrder.patch({
|
|
2090
|
-
id: order.id,
|
|
2091
|
-
status: OrderStatus.Completed
|
|
2085
|
+
id: order.id,
|
|
2086
|
+
status: OrderStatus.Completed,
|
|
2092
2087
|
});
|
|
2093
2088
|
patchArray.addPatch(orderPatch);
|
|
2094
2089
|
|
|
2095
2090
|
// Send a patch
|
|
2096
|
-
const r = Request.buildJson(
|
|
2097
|
-
r.headers.authorization =
|
|
2091
|
+
const r = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
2092
|
+
r.headers.authorization = 'Bearer ' + token.accessToken;
|
|
2098
2093
|
|
|
2099
2094
|
await testServer.test(patchWebshopOrdersEndpoint, r);
|
|
2100
2095
|
|
|
@@ -2107,14 +2102,14 @@ describe("E2E.Stock", () => {
|
|
|
2107
2102
|
ReservedSeat.create({
|
|
2108
2103
|
section: seatingPlan.sections[0].id,
|
|
2109
2104
|
row: 'A',
|
|
2110
|
-
seat: '1'
|
|
2105
|
+
seat: '1',
|
|
2111
2106
|
}),
|
|
2112
2107
|
ReservedSeat.create({
|
|
2113
2108
|
section: seatingPlan.sections[0].id,
|
|
2114
2109
|
row: 'A',
|
|
2115
|
-
seat: '2'
|
|
2110
|
+
seat: '2',
|
|
2116
2111
|
}),
|
|
2117
|
-
])
|
|
2112
|
+
]);
|
|
2118
2113
|
});
|
|
2119
2114
|
});
|
|
2120
2115
|
});
|