@stamhoofd/backend 2.39.1 → 2.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.mjs +5 -0
- package/index.ts +81 -74
- package/jest.config.cjs +10 -0
- package/migrations.ts +16 -14
- package/package.json +11 -11
- package/src/crons/clear-excel-cache.test.ts +48 -50
- package/src/crons/clear-excel-cache.ts +18 -18
- package/src/crons/setup-steps.ts +2 -2
- package/src/crons.ts +325 -306
- package/src/decoders/StringArrayDecoder.ts +7 -7
- package/src/decoders/StringNullableDecoder.ts +1 -2
- package/src/email-recipient-loaders/members.ts +22 -22
- package/src/endpoints/admin/memberships/ChargeMembershipsEndpoint.ts +8 -9
- package/src/endpoints/admin/memberships/GetChargeMembershipsSummaryEndpoint.ts +39 -40
- package/src/endpoints/admin/organizations/GetOrganizationsCountEndpoint.ts +8 -8
- package/src/endpoints/admin/organizations/GetOrganizationsEndpoint.ts +44 -45
- package/src/endpoints/admin/organizations/PatchOrganizationsEndpoint.ts +58 -57
- package/src/endpoints/auth/CreateAdminEndpoint.ts +48 -45
- package/src/endpoints/auth/CreateTokenEndpoint.test.ts +31 -31
- package/src/endpoints/auth/CreateTokenEndpoint.ts +146 -147
- package/src/endpoints/auth/DeleteTokenEndpoint.ts +7 -7
- package/src/endpoints/auth/DeleteUserEndpoint.ts +15 -15
- package/src/endpoints/auth/ForgotPasswordEndpoint.ts +17 -18
- package/src/endpoints/auth/GetOtherUserEndpoint.ts +9 -10
- package/src/endpoints/auth/GetUserEndpoint.test.ts +32 -35
- package/src/endpoints/auth/GetUserEndpoint.ts +5 -6
- package/src/endpoints/auth/PatchApiUserEndpoint.ts +35 -33
- package/src/endpoints/auth/PatchUserEndpoint.ts +55 -52
- package/src/endpoints/auth/PollEmailVerificationEndpoint.ts +9 -9
- package/src/endpoints/auth/RetryEmailVerificationEndpoint.ts +8 -8
- package/src/endpoints/auth/SignupEndpoint.ts +37 -36
- package/src/endpoints/auth/VerifyEmailEndpoint.ts +29 -28
- package/src/endpoints/global/addresses/SearchRegionsEndpoint.ts +33 -33
- package/src/endpoints/global/addresses/ValidateAddressEndpoint.ts +7 -7
- package/src/endpoints/global/caddy/CheckDomainCertEndpoint.ts +37 -37
- package/src/endpoints/global/email/CreateEmailEndpoint.ts +30 -30
- package/src/endpoints/global/email/GetEmailAddressEndpoint.ts +13 -13
- package/src/endpoints/global/email/GetEmailEndpoint.ts +13 -13
- package/src/endpoints/global/email/ManageEmailAddressEndpoint.ts +16 -16
- package/src/endpoints/global/email/PatchEmailEndpoint.ts +25 -25
- package/src/endpoints/global/events/GetEventsEndpoint.ts +43 -44
- package/src/endpoints/global/events/PatchEventsEndpoint.ts +127 -172
- package/src/endpoints/global/files/ExportToExcelEndpoint.ts +49 -50
- package/src/endpoints/global/files/GetFileCache.ts +13 -13
- package/src/endpoints/global/files/UploadFile.ts +51 -54
- package/src/endpoints/global/files/UploadImage.ts +53 -53
- package/src/endpoints/global/groups/GetGroupsEndpoint.ts +25 -25
- package/src/endpoints/global/members/GetMemberFamilyEndpoint.ts +24 -23
- package/src/endpoints/global/members/GetMembersCountEndpoint.ts +8 -8
- package/src/endpoints/global/members/GetMembersEndpoint.ts +105 -102
- package/src/endpoints/global/members/PatchOrganizationMembersEndpoint.ts +240 -239
- package/src/endpoints/global/organizations/CheckRegisterCodeEndpoint.ts +12 -14
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.test.ts +32 -33
- package/src/endpoints/global/organizations/CreateOrganizationEndpoint.ts +48 -57
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.test.ts +21 -22
- package/src/endpoints/global/organizations/GetOrganizationFromDomainEndpoint.ts +28 -28
- package/src/endpoints/global/organizations/GetOrganizationFromUriEndpoint.ts +18 -18
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.test.ts +20 -20
- package/src/endpoints/global/organizations/SearchOrganizationEndpoint.ts +17 -17
- package/src/endpoints/global/payments/StripeWebhookEndpoint.ts +81 -75
- package/src/endpoints/global/platform/GetPlatformAdminsEndpoint.ts +14 -14
- package/src/endpoints/global/platform/GetPlatformEnpoint.ts +11 -11
- package/src/endpoints/global/platform/PatchPlatformEnpoint.ts +71 -68
- package/src/endpoints/global/registration/GetPaymentRegistrations.ts +27 -27
- package/src/endpoints/global/registration/GetUserBillingStatusEndpoint.ts +30 -30
- package/src/endpoints/global/registration/GetUserDetailedBillingStatusEndpoint.ts +34 -34
- package/src/endpoints/global/registration/GetUserDocumentsEndpoint.ts +26 -26
- package/src/endpoints/global/registration/GetUserMembersEndpoint.ts +12 -12
- package/src/endpoints/global/registration/PatchUserMembersEndpoint.ts +90 -90
- package/src/endpoints/global/registration/RegisterMembersEndpoint.test.ts +118 -121
- package/src/endpoints/global/registration/RegisterMembersEndpoint.ts +362 -350
- package/src/endpoints/global/registration-periods/GetRegistrationPeriodsEndpoint.ts +8 -9
- package/src/endpoints/global/registration-periods/PatchRegistrationPeriodsEndpoint.ts +21 -21
- package/src/endpoints/global/webshops/GetWebshopFromDomainEndpoint.ts +65 -65
- package/src/endpoints/organization/dashboard/billing/GetOrganizationBillingStatusEndpoint.ts +9 -9
- package/src/endpoints/organization/dashboard/billing/GetOrganizationDetailedBillingStatusEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplateXML.ts +17 -17
- package/src/endpoints/organization/dashboard/documents/GetDocumentTemplatesEndpoint.ts +21 -21
- package/src/endpoints/organization/dashboard/documents/GetDocumentsEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/documents/PatchDocumentEndpoint.ts +52 -52
- package/src/endpoints/organization/dashboard/documents/PatchDocumentTemplateEndpoint.ts +37 -37
- package/src/endpoints/organization/dashboard/email/CheckEmailBouncesEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/email/EmailEndpoint.ts +113 -112
- package/src/endpoints/organization/dashboard/email-templates/GetEmailTemplatesEndpoint.ts +29 -29
- package/src/endpoints/organization/dashboard/email-templates/PatchEmailTemplatesEndpoint.ts +48 -47
- package/src/endpoints/organization/dashboard/mollie/CheckMollieEndpoint.ts +22 -21
- package/src/endpoints/organization/dashboard/mollie/ConnectMollieEndpoint.ts +13 -14
- package/src/endpoints/organization/dashboard/mollie/DisconnectMollieEndpoint.ts +12 -13
- package/src/endpoints/organization/dashboard/mollie/GetMollieDashboardEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/nolt/CreateNoltTokenEndpoint.ts +10 -12
- package/src/endpoints/organization/dashboard/organization/GetOrganizationArchivedGroups.ts +14 -14
- package/src/endpoints/organization/dashboard/organization/GetOrganizationDeletedGroups.ts +13 -13
- package/src/endpoints/organization/dashboard/organization/GetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.test.ts +120 -124
- package/src/endpoints/organization/dashboard/organization/PatchOrganizationEndpoint.ts +172 -173
- package/src/endpoints/organization/dashboard/organization/SetOrganizationDomainEndpoint.ts +88 -89
- package/src/endpoints/organization/dashboard/organization/SetOrganizationSSOEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/payments/GetMemberBalanceEndpoint.ts +17 -17
- package/src/endpoints/organization/dashboard/payments/GetPaymentsCountEndpoint.ts +8 -8
- package/src/endpoints/organization/dashboard/payments/GetPaymentsEndpoint.ts +66 -67
- package/src/endpoints/organization/dashboard/payments/PatchBalanceItemsEndpoint.ts +47 -47
- package/src/endpoints/organization/dashboard/payments/PatchPaymentsEndpoint.ts +93 -91
- package/src/endpoints/organization/dashboard/registration-periods/GetOrganizationRegistrationPeriodsEndpoint.ts +16 -17
- package/src/endpoints/organization/dashboard/registration-periods/PatchOrganizationRegistrationPeriodsEndpoint.ts +170 -167
- package/src/endpoints/organization/dashboard/registration-periods/SetupStepReviewEndpoint.ts +25 -24
- package/src/endpoints/organization/dashboard/stripe/ConnectStripeEndpoint.ts +22 -23
- package/src/endpoints/organization/dashboard/stripe/DeleteStripeAccountEndpoint.ts +22 -22
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/GetStripeAccountsEndpoint.ts +8 -9
- package/src/endpoints/organization/dashboard/stripe/GetStripeLoginLinkEndpoint.ts +17 -18
- package/src/endpoints/organization/dashboard/stripe/UpdateStripeAccountEndpoint.ts +14 -15
- package/src/endpoints/organization/dashboard/users/CreateApiUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/DeleteUserEndpoint.ts +19 -19
- package/src/endpoints/organization/dashboard/users/GetApiUsersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/users/GetOrganizationAdminsEndpoint.ts +12 -12
- package/src/endpoints/organization/dashboard/webshops/CreateWebshopEndpoint.ts +103 -100
- package/src/endpoints/organization/dashboard/webshops/DeleteWebshopEndpoint.ts +11 -12
- package/src/endpoints/organization/dashboard/webshops/GetDiscountCodesEndpoint.ts +15 -15
- package/src/endpoints/organization/dashboard/webshops/GetWebshopOrdersEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopTicketsEndpoint.ts +14 -14
- package/src/endpoints/organization/dashboard/webshops/GetWebshopUriAvailabilityEndpoint.ts +23 -23
- package/src/endpoints/organization/dashboard/webshops/PatchDiscountCodesEndpoint.ts +54 -52
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopEndpoint.ts +84 -81
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint.ts +120 -111
- package/src/endpoints/organization/dashboard/webshops/PatchWebshopTicketsEndpoint.ts +24 -24
- package/src/endpoints/organization/dashboard/webshops/VerifyWebshopDomainEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/ExchangePaymentEndpoint.ts +141 -130
- package/src/endpoints/organization/shared/GetDocumentHtml.ts +25 -25
- package/src/endpoints/organization/shared/GetPaymentEndpoint.ts +18 -18
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.test.ts +36 -37
- package/src/endpoints/organization/shared/auth/GetOrganizationEndpoint.ts +9 -9
- package/src/endpoints/organization/shared/auth/OpenIDConnectCallbackEndpoint.ts +11 -11
- package/src/endpoints/organization/shared/auth/OpenIDConnectStartEndpoint.ts +28 -27
- package/src/endpoints/organization/webshops/CheckWebshopDiscountCodesEndpoint.ts +20 -20
- package/src/endpoints/organization/webshops/GetOrderByPaymentEndpoint.ts +22 -22
- package/src/endpoints/organization/webshops/GetOrderEndpoint.ts +14 -14
- package/src/endpoints/organization/webshops/GetTicketsEndpoint.ts +57 -56
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.test.ts +65 -66
- package/src/endpoints/organization/webshops/GetWebshopEndpoint.ts +18 -17
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.test.ts +124 -128
- package/src/endpoints/organization/webshops/PlaceOrderEndpoint.ts +154 -145
- package/src/excel-loaders/members.ts +275 -273
- package/src/excel-loaders/payments.ts +155 -156
- package/src/helpers/AddressValidator.test.ts +32 -32
- package/src/helpers/AddressValidator.ts +128 -122
- package/src/helpers/AdminPermissionChecker.ts +339 -236
- package/src/helpers/AuthenticatedStructures.ts +233 -134
- package/src/helpers/BuckarooHelper.ts +134 -134
- package/src/helpers/CheckSettlements.ts +94 -88
- package/src/helpers/Context.ts +87 -86
- package/src/helpers/CookieHelper.ts +23 -22
- package/src/helpers/EmailResumer.ts +10 -10
- package/src/helpers/FileCache.ts +62 -62
- package/src/helpers/ForwardHandler.test.ts +122 -124
- package/src/helpers/ForwardHandler.ts +76 -70
- package/src/helpers/MemberUserSyncer.ts +101 -96
- package/src/helpers/MembershipCharger.ts +69 -69
- package/src/helpers/MembershipHelper.ts +11 -12
- package/src/helpers/OpenIDConnectHelper.ts +85 -82
- package/src/helpers/PeriodHelper.ts +65 -70
- package/src/helpers/StripeHelper.ts +146 -137
- package/src/helpers/StripePayoutChecker.ts +51 -52
- package/src/helpers/ViesHelper.ts +46 -44
- package/src/helpers/fetchToAsyncIterator.ts +14 -14
- package/src/helpers/xlsxAddressTransformerColumnFactory.ts +58 -60
- package/src/middleware/ContextMiddleware.ts +5 -5
- package/src/migrations/1646578856-validate-addresses.ts +6 -9
- package/src/seeds/0000000000-example.ts +3 -5
- package/src/seeds/1715028563-user-permissions.ts +16 -18
- package/src/seeds/1722256498-group-update-occupancy.ts +12 -12
- package/src/seeds/1722344162-sync-member-users.ts +14 -15
- package/src/seeds/1722344162-update-membership.ts +6 -6
- package/src/seeds/1726055544-balance-item-paid.ts +4 -4
- package/src/seeds/1726055545-balance-item-pending.ts +4 -4
- package/src/seeds/1726494419-update-cached-outstanding-balance.ts +16 -16
- package/src/seeds/1726494420-update-cached-outstanding-balance-from-items.ts +12 -12
- package/src/seeds/1726572303-schedule-stock-updates.ts +12 -12
- package/src/seeds/1726847064-setup-steps.ts +16 -0
- package/src/sql-filters/balance-item-payments.ts +7 -7
- package/src/sql-filters/events.ts +14 -14
- package/src/sql-filters/members.ts +96 -96
- package/src/sql-filters/organizations.ts +139 -75
- package/src/sql-filters/payments.ts +28 -28
- package/src/sql-filters/registrations.ts +14 -14
- package/src/sql-sorters/events.ts +25 -25
- package/src/sql-sorters/members.ts +26 -26
- package/src/sql-sorters/organizations.ts +36 -36
- package/src/sql-sorters/payments.ts +26 -26
- package/tests/e2e/stock.test.ts +616 -621
- package/tests/e2e/tickets.test.ts +255 -260
- package/tests/helpers/StripeMocker.ts +177 -179
- package/tests/helpers/TestServer.ts +9 -9
- package/tests/jest.global.setup.ts +14 -13
- package/tests/jest.setup.ts +33 -32
- package/.eslintrc.js +0 -61
- package/jest.config.js +0 -11
- package/src/helpers/SetupStepsUpdater.ts +0 -359
- package/src/seeds/1724076679-setup-steps.ts +0 -16
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { Cart, CartItem, CartReservedSeat, Customer, OrderData, OrderStatus, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivateOrder, PrivatePaymentConfiguration, Product, ProductType, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, WebshopMetaData, WebshopPrivateMetaData, WebshopTicketType } from "@stamhoofd/structures";
|
|
8
|
-
|
|
9
|
-
import { PatchWebshopOrdersEndpoint } from "../../src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint";
|
|
1
|
+
import { PatchableArray, PatchableArrayAutoEncoder } from '@simonbackx/simple-encoding';
|
|
2
|
+
import { Request } from '@simonbackx/simple-endpoints';
|
|
3
|
+
import { Organization, OrganizationFactory, StripeAccount, Ticket, Token, UserFactory, Webshop, WebshopFactory } from '@stamhoofd/models';
|
|
4
|
+
import { Cart, CartItem, CartReservedSeat, Customer, OrderData, OrderStatus, PaymentConfiguration, PaymentMethod, PermissionLevel, Permissions, PrivateOrder, PrivatePaymentConfiguration, Product, ProductType, SeatingPlan, SeatingPlanRow, SeatingPlanSeat, SeatingPlanSection, TransferSettings, WebshopMetaData, WebshopPrivateMetaData, WebshopTicketType } from '@stamhoofd/structures';
|
|
5
|
+
|
|
6
|
+
import { PatchWebshopOrdersEndpoint } from '../../src/endpoints/organization/dashboard/webshops/PatchWebshopOrdersEndpoint';
|
|
10
7
|
import { PlaceOrderEndpoint } from '../../src/endpoints/organization/webshops/PlaceOrderEndpoint';
|
|
11
|
-
import { StripeMocker } from
|
|
12
|
-
import { testServer } from
|
|
8
|
+
import { StripeMocker } from '../helpers/StripeMocker';
|
|
9
|
+
import { testServer } from '../helpers/TestServer';
|
|
13
10
|
|
|
14
11
|
const customer = Customer.create({
|
|
15
12
|
firstName: 'John',
|
|
16
13
|
lastName: 'Doe',
|
|
17
14
|
email: 'john@example.com',
|
|
18
|
-
phone: '+32412345678'
|
|
15
|
+
phone: '+32412345678',
|
|
19
16
|
});
|
|
20
17
|
|
|
21
18
|
function mapTicketChangedAmount(ticket: Ticket) {
|
|
@@ -27,7 +24,7 @@ function mapTicketChangedAmount(ticket: Ticket) {
|
|
|
27
24
|
itemId: ticket.itemId,
|
|
28
25
|
index: ticket.index,
|
|
29
26
|
secret: ticket.secret,
|
|
30
|
-
}
|
|
27
|
+
};
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
function mapTicketCreation(ticket: Ticket) {
|
|
@@ -36,11 +33,11 @@ function mapTicketCreation(ticket: Ticket) {
|
|
|
36
33
|
originalSeat: ticket.originalSeat,
|
|
37
34
|
itemId: ticket.itemId,
|
|
38
35
|
index: ticket.index,
|
|
39
|
-
total: ticket.total
|
|
40
|
-
}
|
|
36
|
+
total: ticket.total,
|
|
37
|
+
};
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
describe(
|
|
40
|
+
describe('E2E.Tickets', () => {
|
|
44
41
|
// Test endpoint
|
|
45
42
|
const endpoint = new PlaceOrderEndpoint();
|
|
46
43
|
const patchWebshopOrdersEndpoint = new PatchWebshopOrdersEndpoint();
|
|
@@ -51,23 +48,23 @@ describe("E2E.Tickets", () => {
|
|
|
51
48
|
let ticket2: Product;
|
|
52
49
|
let seatProduct: Product;
|
|
53
50
|
let seatingPlan: SeatingPlan;
|
|
54
|
-
let stripeMocker: StripeMocker
|
|
55
|
-
let stripeAccount: StripeAccount
|
|
51
|
+
let stripeMocker: StripeMocker;
|
|
52
|
+
let stripeAccount: StripeAccount;
|
|
56
53
|
let token: Token;
|
|
57
54
|
|
|
58
55
|
beforeAll(async () => {
|
|
59
56
|
stripeMocker = new StripeMocker();
|
|
60
57
|
stripeMocker.start();
|
|
61
|
-
organization = await new OrganizationFactory({}).create()
|
|
58
|
+
organization = await new OrganizationFactory({}).create();
|
|
62
59
|
stripeAccount = await stripeMocker.createStripeAccount(organization.id);
|
|
63
60
|
|
|
64
61
|
const user = await new UserFactory({
|
|
65
62
|
organization,
|
|
66
63
|
permissions: Permissions.create({
|
|
67
|
-
level: PermissionLevel.Full
|
|
68
|
-
})
|
|
69
|
-
}).create()
|
|
70
|
-
token = await Token.createToken(user)
|
|
64
|
+
level: PermissionLevel.Full,
|
|
65
|
+
}),
|
|
66
|
+
}).create();
|
|
67
|
+
token = await Token.createToken(user);
|
|
71
68
|
});
|
|
72
69
|
|
|
73
70
|
afterAll(() => {
|
|
@@ -80,13 +77,13 @@ describe("E2E.Tickets", () => {
|
|
|
80
77
|
|
|
81
78
|
ticket1 = Product.create({
|
|
82
79
|
name: 'ticket1',
|
|
83
|
-
type: ProductType.Ticket
|
|
84
|
-
})
|
|
80
|
+
type: ProductType.Ticket,
|
|
81
|
+
});
|
|
85
82
|
|
|
86
83
|
ticket2 = Product.create({
|
|
87
84
|
name: 'ticket2',
|
|
88
|
-
type: ProductType.Ticket
|
|
89
|
-
})
|
|
85
|
+
type: ProductType.Ticket,
|
|
86
|
+
});
|
|
90
87
|
|
|
91
88
|
seatingPlan = SeatingPlan.create({
|
|
92
89
|
name: 'Testzaal',
|
|
@@ -97,90 +94,90 @@ describe("E2E.Tickets", () => {
|
|
|
97
94
|
label: 'A',
|
|
98
95
|
seats: [
|
|
99
96
|
SeatingPlanSeat.create({
|
|
100
|
-
label: '1'
|
|
97
|
+
label: '1',
|
|
101
98
|
}),
|
|
102
99
|
SeatingPlanSeat.create({
|
|
103
|
-
label: '2'
|
|
100
|
+
label: '2',
|
|
104
101
|
}),
|
|
105
102
|
SeatingPlanSeat.create({
|
|
106
|
-
label: '3'
|
|
103
|
+
label: '3',
|
|
107
104
|
}),
|
|
108
105
|
SeatingPlanSeat.create({
|
|
109
|
-
label: '4'
|
|
110
|
-
})
|
|
111
|
-
]
|
|
106
|
+
label: '4',
|
|
107
|
+
}),
|
|
108
|
+
],
|
|
112
109
|
}),
|
|
113
110
|
SeatingPlanRow.create({
|
|
114
111
|
label: 'B',
|
|
115
112
|
seats: [
|
|
116
113
|
SeatingPlanSeat.create({
|
|
117
|
-
label: '1'
|
|
114
|
+
label: '1',
|
|
118
115
|
}),
|
|
119
116
|
SeatingPlanSeat.create({
|
|
120
|
-
label: '2'
|
|
117
|
+
label: '2',
|
|
121
118
|
}),
|
|
122
119
|
SeatingPlanSeat.create({
|
|
123
|
-
label: '3'
|
|
120
|
+
label: '3',
|
|
124
121
|
}),
|
|
125
122
|
SeatingPlanSeat.create({
|
|
126
|
-
label: '4'
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
})
|
|
130
|
-
]
|
|
131
|
-
})
|
|
132
|
-
]
|
|
133
|
-
})
|
|
134
|
-
meta.seatingPlans.addPut(seatingPlan)
|
|
123
|
+
label: '4',
|
|
124
|
+
}),
|
|
125
|
+
],
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
meta.seatingPlans.addPut(seatingPlan);
|
|
135
132
|
|
|
136
133
|
seatProduct = Product.create({
|
|
137
134
|
name: 'seatProduct',
|
|
138
135
|
type: ProductType.Ticket,
|
|
139
|
-
seatingPlanId: seatingPlan.id
|
|
140
|
-
})
|
|
141
|
-
|
|
136
|
+
seatingPlanId: seatingPlan.id,
|
|
137
|
+
});
|
|
138
|
+
|
|
142
139
|
const paymentConfigurationPatch = PaymentConfiguration.patch({
|
|
143
140
|
transferSettings: TransferSettings.create({
|
|
144
|
-
iban: 'BE56587127952688' // = random IBAN
|
|
141
|
+
iban: 'BE56587127952688', // = random IBAN
|
|
145
142
|
}),
|
|
146
|
-
})
|
|
147
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale)
|
|
148
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer)
|
|
149
|
-
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact)
|
|
143
|
+
});
|
|
144
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.PointOfSale);
|
|
145
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Transfer);
|
|
146
|
+
paymentConfigurationPatch.paymentMethods.addPut(PaymentMethod.Bancontact);
|
|
150
147
|
|
|
151
148
|
const privatePaymentConfiguration = PrivatePaymentConfiguration.patch({
|
|
152
|
-
stripeAccountId: stripeAccount.id
|
|
153
|
-
})
|
|
149
|
+
stripeAccountId: stripeAccount.id,
|
|
150
|
+
});
|
|
154
151
|
|
|
155
152
|
meta = meta.patch({
|
|
156
153
|
paymentConfiguration: paymentConfigurationPatch,
|
|
157
|
-
ticketType: WebshopTicketType.Tickets
|
|
158
|
-
})
|
|
154
|
+
ticketType: WebshopTicketType.Tickets,
|
|
155
|
+
});
|
|
159
156
|
|
|
160
157
|
const privateMeta = WebshopPrivateMetaData.patch({
|
|
161
|
-
paymentConfiguration: privatePaymentConfiguration
|
|
162
|
-
})
|
|
158
|
+
paymentConfiguration: privatePaymentConfiguration,
|
|
159
|
+
});
|
|
163
160
|
|
|
164
161
|
webshop = await new WebshopFactory({
|
|
165
162
|
organizationId: organization.id,
|
|
166
163
|
name: 'Test webshop',
|
|
167
164
|
meta,
|
|
168
165
|
privateMeta,
|
|
169
|
-
products: [ticket1, ticket2, seatProduct]
|
|
170
|
-
}).create()
|
|
166
|
+
products: [ticket1, ticket2, seatProduct],
|
|
167
|
+
}).create();
|
|
171
168
|
});
|
|
172
169
|
|
|
173
|
-
test(
|
|
170
|
+
test('POS payments create tickets', async () => {
|
|
174
171
|
const item1 = CartItem.create({
|
|
175
172
|
product: ticket1,
|
|
176
173
|
productPrice: ticket1.prices[0],
|
|
177
|
-
amount: 5
|
|
174
|
+
amount: 5,
|
|
178
175
|
});
|
|
179
176
|
|
|
180
177
|
const item2 = CartItem.create({
|
|
181
178
|
product: ticket2,
|
|
182
179
|
productPrice: ticket2.prices[0],
|
|
183
|
-
amount: 2
|
|
180
|
+
amount: 2,
|
|
184
181
|
});
|
|
185
182
|
|
|
186
183
|
const orderData = OrderData.create({
|
|
@@ -188,20 +185,20 @@ describe("E2E.Tickets", () => {
|
|
|
188
185
|
cart: Cart.create({
|
|
189
186
|
items: [
|
|
190
187
|
item1,
|
|
191
|
-
item2
|
|
192
|
-
]
|
|
188
|
+
item2,
|
|
189
|
+
],
|
|
193
190
|
}),
|
|
194
|
-
customer
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
const r = Request.buildJson(
|
|
191
|
+
customer,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
198
195
|
|
|
199
196
|
const response = await testServer.test(endpoint, r);
|
|
200
197
|
expect(response.body).toBeDefined();
|
|
201
198
|
const order = response.body.order;
|
|
202
199
|
|
|
203
200
|
// Check tickets
|
|
204
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
201
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
205
202
|
expect(tickets).toHaveLength(7);
|
|
206
203
|
|
|
207
204
|
const item1Tickets = tickets.filter(t => t.itemId === item1.id);
|
|
@@ -209,14 +206,14 @@ describe("E2E.Tickets", () => {
|
|
|
209
206
|
|
|
210
207
|
expect(item1Tickets).toHaveLength(5);
|
|
211
208
|
expect(item2Tickets).toHaveLength(2);
|
|
212
|
-
|
|
209
|
+
|
|
213
210
|
// Check indexes present
|
|
214
|
-
expect(item1Tickets.map(i => i.index).sort()).toEqual([1, 2, 3, 4, 5])
|
|
215
|
-
expect(item2Tickets.map(i => i.index).sort()).toEqual([1, 2])
|
|
211
|
+
expect(item1Tickets.map(i => i.index).sort()).toEqual([1, 2, 3, 4, 5]);
|
|
212
|
+
expect(item2Tickets.map(i => i.index).sort()).toEqual([1, 2]);
|
|
216
213
|
|
|
217
214
|
// Check total present
|
|
218
|
-
expect(item1Tickets.map(i => i.total).sort()).toEqual([5, 5, 5, 5, 5])
|
|
219
|
-
expect(item2Tickets.map(i => i.total).sort()).toEqual([2, 2])
|
|
215
|
+
expect(item1Tickets.map(i => i.total).sort()).toEqual([5, 5, 5, 5, 5]);
|
|
216
|
+
expect(item2Tickets.map(i => i.total).sort()).toEqual([2, 2]);
|
|
220
217
|
|
|
221
218
|
expect(tickets.map(mapTicketCreation)).toIncludeSameMembers([
|
|
222
219
|
{
|
|
@@ -224,64 +221,64 @@ describe("E2E.Tickets", () => {
|
|
|
224
221
|
originalSeat: null,
|
|
225
222
|
itemId: item1.id,
|
|
226
223
|
index: 1,
|
|
227
|
-
total: 5
|
|
224
|
+
total: 5,
|
|
228
225
|
},
|
|
229
226
|
{
|
|
230
227
|
seat: null,
|
|
231
228
|
originalSeat: null,
|
|
232
229
|
itemId: item1.id,
|
|
233
230
|
index: 2,
|
|
234
|
-
total: 5
|
|
231
|
+
total: 5,
|
|
235
232
|
},
|
|
236
233
|
{
|
|
237
234
|
seat: null,
|
|
238
235
|
originalSeat: null,
|
|
239
236
|
itemId: item1.id,
|
|
240
237
|
index: 3,
|
|
241
|
-
total: 5
|
|
238
|
+
total: 5,
|
|
242
239
|
},
|
|
243
240
|
{
|
|
244
241
|
seat: null,
|
|
245
242
|
originalSeat: null,
|
|
246
243
|
itemId: item1.id,
|
|
247
244
|
index: 4,
|
|
248
|
-
total: 5
|
|
245
|
+
total: 5,
|
|
249
246
|
},
|
|
250
247
|
{
|
|
251
248
|
seat: null,
|
|
252
249
|
originalSeat: null,
|
|
253
250
|
itemId: item1.id,
|
|
254
251
|
index: 5,
|
|
255
|
-
total: 5
|
|
252
|
+
total: 5,
|
|
256
253
|
},
|
|
257
254
|
{
|
|
258
255
|
seat: null,
|
|
259
256
|
originalSeat: null,
|
|
260
257
|
itemId: item2.id,
|
|
261
258
|
index: 1,
|
|
262
|
-
total: 2
|
|
259
|
+
total: 2,
|
|
263
260
|
},
|
|
264
261
|
{
|
|
265
262
|
seat: null,
|
|
266
263
|
originalSeat: null,
|
|
267
264
|
itemId: item2.id,
|
|
268
265
|
index: 2,
|
|
269
|
-
total: 2
|
|
270
|
-
}
|
|
271
|
-
])
|
|
266
|
+
total: 2,
|
|
267
|
+
},
|
|
268
|
+
]);
|
|
272
269
|
});
|
|
273
270
|
|
|
274
|
-
test(
|
|
271
|
+
test('Adding new items keeps all tickets in place', async () => {
|
|
275
272
|
const item1 = CartItem.create({
|
|
276
273
|
product: ticket1,
|
|
277
274
|
productPrice: ticket1.prices[0],
|
|
278
|
-
amount: 5
|
|
275
|
+
amount: 5,
|
|
279
276
|
});
|
|
280
277
|
|
|
281
278
|
const item2 = CartItem.create({
|
|
282
279
|
product: ticket2,
|
|
283
280
|
productPrice: ticket2.prices[0],
|
|
284
|
-
amount: 2
|
|
281
|
+
amount: 2,
|
|
285
282
|
});
|
|
286
283
|
|
|
287
284
|
const orderData = OrderData.create({
|
|
@@ -289,49 +286,49 @@ describe("E2E.Tickets", () => {
|
|
|
289
286
|
cart: Cart.create({
|
|
290
287
|
items: [
|
|
291
288
|
item1,
|
|
292
|
-
item2
|
|
293
|
-
]
|
|
289
|
+
item2,
|
|
290
|
+
],
|
|
294
291
|
}),
|
|
295
|
-
customer
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
const r = Request.buildJson(
|
|
292
|
+
customer,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
299
296
|
|
|
300
297
|
const response = await testServer.test(endpoint, r);
|
|
301
298
|
expect(response.body).toBeDefined();
|
|
302
299
|
const order = response.body.order;
|
|
303
300
|
|
|
304
301
|
// Check tickets
|
|
305
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
302
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
306
303
|
expect(tickets).toHaveLength(7);
|
|
307
304
|
|
|
308
305
|
// Now add an extra item
|
|
309
306
|
|
|
310
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
307
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
311
308
|
|
|
312
|
-
const cartPatch = Cart.patch({})
|
|
309
|
+
const cartPatch = Cart.patch({});
|
|
313
310
|
cartPatch.items.addPatch(CartItem.patch({
|
|
314
311
|
id: item1.id,
|
|
315
|
-
amount: 7
|
|
312
|
+
amount: 7,
|
|
316
313
|
}));
|
|
317
314
|
|
|
318
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
315
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
319
316
|
patchArray.addPatch(orderPatch);
|
|
320
317
|
|
|
321
318
|
// Send a patch
|
|
322
|
-
const r2 = Request.buildJson(
|
|
323
|
-
r2.headers.authorization =
|
|
319
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
320
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
324
321
|
|
|
325
322
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
326
323
|
|
|
327
|
-
const ticketsAfter = await Ticket.where({orderId: order.id});
|
|
324
|
+
const ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
328
325
|
expect(ticketsAfter).toHaveLength(9);
|
|
329
326
|
|
|
330
327
|
// Didn't change old tickets:
|
|
331
328
|
expect(ticketsAfter.map(mapTicketChangedAmount)).toIncludeAllMembers(tickets.map(mapTicketChangedAmount));
|
|
332
329
|
|
|
333
330
|
// Added 2 new items with index 6 and 7
|
|
334
|
-
const newTickets = ticketsAfter.filter(t => !tickets.find(tt => tt.id === t.id))
|
|
331
|
+
const newTickets = ticketsAfter.filter(t => !tickets.find(tt => tt.id === t.id));
|
|
335
332
|
expect(newTickets).toHaveLength(2);
|
|
336
333
|
|
|
337
334
|
expect(newTickets.map(mapTicketCreation)).toIncludeSameMembers([
|
|
@@ -340,16 +337,16 @@ describe("E2E.Tickets", () => {
|
|
|
340
337
|
originalSeat: null,
|
|
341
338
|
itemId: item1.id,
|
|
342
339
|
index: 6,
|
|
343
|
-
total: 7
|
|
340
|
+
total: 7,
|
|
344
341
|
},
|
|
345
342
|
{
|
|
346
343
|
seat: null,
|
|
347
344
|
originalSeat: null,
|
|
348
345
|
itemId: item1.id,
|
|
349
346
|
index: 7,
|
|
350
|
-
total: 7
|
|
351
|
-
}
|
|
352
|
-
])
|
|
347
|
+
total: 7,
|
|
348
|
+
},
|
|
349
|
+
]);
|
|
353
350
|
|
|
354
351
|
expect(ticketsAfter.map(mapTicketCreation)).toIncludeSameMembers([
|
|
355
352
|
{
|
|
@@ -357,79 +354,78 @@ describe("E2E.Tickets", () => {
|
|
|
357
354
|
originalSeat: null,
|
|
358
355
|
itemId: item1.id,
|
|
359
356
|
index: 1,
|
|
360
|
-
total: 7
|
|
357
|
+
total: 7,
|
|
361
358
|
},
|
|
362
359
|
{
|
|
363
360
|
seat: null,
|
|
364
361
|
originalSeat: null,
|
|
365
362
|
itemId: item1.id,
|
|
366
363
|
index: 2,
|
|
367
|
-
total: 7
|
|
364
|
+
total: 7,
|
|
368
365
|
},
|
|
369
366
|
{
|
|
370
367
|
seat: null,
|
|
371
368
|
originalSeat: null,
|
|
372
369
|
itemId: item1.id,
|
|
373
370
|
index: 3,
|
|
374
|
-
total: 7
|
|
371
|
+
total: 7,
|
|
375
372
|
},
|
|
376
373
|
{
|
|
377
374
|
seat: null,
|
|
378
375
|
originalSeat: null,
|
|
379
376
|
itemId: item1.id,
|
|
380
377
|
index: 4,
|
|
381
|
-
total: 7
|
|
378
|
+
total: 7,
|
|
382
379
|
},
|
|
383
380
|
{
|
|
384
381
|
seat: null,
|
|
385
382
|
originalSeat: null,
|
|
386
383
|
itemId: item1.id,
|
|
387
384
|
index: 5,
|
|
388
|
-
total: 7
|
|
385
|
+
total: 7,
|
|
389
386
|
},
|
|
390
387
|
{
|
|
391
388
|
seat: null,
|
|
392
389
|
originalSeat: null,
|
|
393
390
|
itemId: item1.id,
|
|
394
391
|
index: 6,
|
|
395
|
-
total: 7
|
|
392
|
+
total: 7,
|
|
396
393
|
},
|
|
397
394
|
{
|
|
398
395
|
seat: null,
|
|
399
396
|
originalSeat: null,
|
|
400
397
|
itemId: item1.id,
|
|
401
398
|
index: 7,
|
|
402
|
-
total: 7
|
|
399
|
+
total: 7,
|
|
403
400
|
},
|
|
404
401
|
{
|
|
405
402
|
seat: null,
|
|
406
403
|
originalSeat: null,
|
|
407
404
|
itemId: item2.id,
|
|
408
405
|
index: 1,
|
|
409
|
-
total: 2
|
|
406
|
+
total: 2,
|
|
410
407
|
},
|
|
411
408
|
{
|
|
412
409
|
seat: null,
|
|
413
410
|
originalSeat: null,
|
|
414
411
|
itemId: item2.id,
|
|
415
412
|
index: 2,
|
|
416
|
-
total: 2
|
|
417
|
-
}
|
|
418
|
-
])
|
|
419
|
-
|
|
413
|
+
total: 2,
|
|
414
|
+
},
|
|
415
|
+
]);
|
|
420
416
|
});
|
|
421
417
|
|
|
422
|
-
test(
|
|
418
|
+
test('Deleting items deletes tickets', async () => {
|
|
423
419
|
const item1 = CartItem.create({
|
|
424
420
|
product: ticket1,
|
|
425
421
|
productPrice: ticket1.prices[0],
|
|
426
|
-
amount: 5
|
|
422
|
+
amount: 5,
|
|
427
423
|
});
|
|
428
424
|
|
|
429
425
|
const item2 = CartItem.create({
|
|
430
426
|
product: ticket2,
|
|
431
427
|
productPrice: ticket2.prices[0],
|
|
432
|
-
amount: 2
|
|
428
|
+
amount: 2,
|
|
433
429
|
});
|
|
434
430
|
|
|
435
431
|
const orderData = OrderData.create({
|
|
@@ -437,42 +433,42 @@ describe("E2E.Tickets", () => {
|
|
|
437
433
|
cart: Cart.create({
|
|
438
434
|
items: [
|
|
439
435
|
item1,
|
|
440
|
-
item2
|
|
441
|
-
]
|
|
436
|
+
item2,
|
|
437
|
+
],
|
|
442
438
|
}),
|
|
443
|
-
customer
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
const r = Request.buildJson(
|
|
439
|
+
customer,
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
447
443
|
|
|
448
444
|
const response = await testServer.test(endpoint, r);
|
|
449
445
|
expect(response.body).toBeDefined();
|
|
450
446
|
const order = response.body.order;
|
|
451
447
|
|
|
452
448
|
// Check tickets
|
|
453
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
449
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
454
450
|
expect(tickets).toHaveLength(7);
|
|
455
451
|
|
|
456
452
|
// Now add an extra item
|
|
457
453
|
|
|
458
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
454
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
459
455
|
|
|
460
|
-
const cartPatch = Cart.patch({})
|
|
456
|
+
const cartPatch = Cart.patch({});
|
|
461
457
|
cartPatch.items.addDelete(item2.id);
|
|
462
458
|
|
|
463
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
459
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
464
460
|
patchArray.addPatch(orderPatch);
|
|
465
461
|
|
|
466
462
|
// Send a patch
|
|
467
|
-
const r2 = Request.buildJson(
|
|
468
|
-
r2.headers.authorization =
|
|
463
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
464
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
469
465
|
|
|
470
466
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
471
467
|
|
|
472
|
-
const ticketsAfter = await Ticket.where({orderId: order.id});
|
|
468
|
+
const ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
473
469
|
expect(ticketsAfter).toHaveLength(7);
|
|
474
|
-
const deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
475
|
-
const remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
470
|
+
const deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
471
|
+
const remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
476
472
|
expect(deletedTickets).toHaveLength(2);
|
|
477
473
|
expect(remainingTickets).toHaveLength(5);
|
|
478
474
|
|
|
@@ -481,17 +477,17 @@ describe("E2E.Tickets", () => {
|
|
|
481
477
|
expect(remainingTickets.map(mapTicketChangedAmount)).toIncludeSameMembers(tickets.filter(t => t.itemId === item1.id).map(mapTicketChangedAmount));
|
|
482
478
|
});
|
|
483
479
|
|
|
484
|
-
test(
|
|
480
|
+
test('Deleting an order deletes tickets', async () => {
|
|
485
481
|
const item1 = CartItem.create({
|
|
486
482
|
product: ticket1,
|
|
487
483
|
productPrice: ticket1.prices[0],
|
|
488
|
-
amount: 5
|
|
484
|
+
amount: 5,
|
|
489
485
|
});
|
|
490
486
|
|
|
491
487
|
const item2 = CartItem.create({
|
|
492
488
|
product: ticket2,
|
|
493
489
|
productPrice: ticket2.prices[0],
|
|
494
|
-
amount: 2
|
|
490
|
+
amount: 2,
|
|
495
491
|
});
|
|
496
492
|
|
|
497
493
|
const orderData = OrderData.create({
|
|
@@ -499,55 +495,55 @@ describe("E2E.Tickets", () => {
|
|
|
499
495
|
cart: Cart.create({
|
|
500
496
|
items: [
|
|
501
497
|
item1,
|
|
502
|
-
item2
|
|
503
|
-
]
|
|
498
|
+
item2,
|
|
499
|
+
],
|
|
504
500
|
}),
|
|
505
|
-
customer
|
|
506
|
-
})
|
|
507
|
-
|
|
508
|
-
const r = Request.buildJson(
|
|
501
|
+
customer,
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
509
505
|
|
|
510
506
|
const response = await testServer.test(endpoint, r);
|
|
511
507
|
expect(response.body).toBeDefined();
|
|
512
508
|
const order = response.body.order;
|
|
513
509
|
|
|
514
510
|
// Check tickets
|
|
515
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
511
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
516
512
|
expect(tickets).toHaveLength(7);
|
|
517
513
|
|
|
518
514
|
// Now add an extra item
|
|
519
515
|
|
|
520
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
516
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
521
517
|
|
|
522
|
-
const orderPatch = PrivateOrder.patch({id: order.id, status: OrderStatus.Deleted});
|
|
518
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, status: OrderStatus.Deleted });
|
|
523
519
|
patchArray.addPatch(orderPatch);
|
|
524
520
|
|
|
525
521
|
// Send a patch
|
|
526
|
-
const r2 = Request.buildJson(
|
|
527
|
-
r2.headers.authorization =
|
|
522
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
523
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
528
524
|
|
|
529
525
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
530
526
|
|
|
531
|
-
const ticketsAfter = await Ticket.where({orderId: order.id});
|
|
527
|
+
const ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
532
528
|
expect(ticketsAfter).toHaveLength(7);
|
|
533
|
-
|
|
534
|
-
const deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
535
|
-
const remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
529
|
+
|
|
530
|
+
const deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
531
|
+
const remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
536
532
|
expect(deletedTickets).toHaveLength(7);
|
|
537
533
|
expect(remainingTickets).toHaveLength(0);
|
|
538
534
|
});
|
|
539
535
|
|
|
540
|
-
test(
|
|
536
|
+
test('Reducing amount deletes tickets and reuses them again when added again', async () => {
|
|
541
537
|
const item1 = CartItem.create({
|
|
542
538
|
product: ticket1,
|
|
543
539
|
productPrice: ticket1.prices[0],
|
|
544
|
-
amount: 5
|
|
540
|
+
amount: 5,
|
|
545
541
|
});
|
|
546
542
|
|
|
547
543
|
const item2 = CartItem.create({
|
|
548
544
|
product: ticket2,
|
|
549
545
|
productPrice: ticket2.prices[0],
|
|
550
|
-
amount: 2
|
|
546
|
+
amount: 2,
|
|
551
547
|
});
|
|
552
548
|
|
|
553
549
|
const orderData = OrderData.create({
|
|
@@ -555,47 +551,47 @@ describe("E2E.Tickets", () => {
|
|
|
555
551
|
cart: Cart.create({
|
|
556
552
|
items: [
|
|
557
553
|
item1,
|
|
558
|
-
item2
|
|
559
|
-
]
|
|
554
|
+
item2,
|
|
555
|
+
],
|
|
560
556
|
}),
|
|
561
|
-
customer
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
const r = Request.buildJson(
|
|
557
|
+
customer,
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
565
561
|
|
|
566
562
|
const response = await testServer.test(endpoint, r);
|
|
567
563
|
expect(response.body).toBeDefined();
|
|
568
564
|
const order = response.body.order;
|
|
569
565
|
|
|
570
566
|
// Check tickets
|
|
571
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
567
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
572
568
|
expect(tickets).toHaveLength(7);
|
|
573
569
|
|
|
574
570
|
// Now add an extra item
|
|
575
571
|
{
|
|
576
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
572
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
577
573
|
|
|
578
|
-
const cartPatch = Cart.patch({})
|
|
574
|
+
const cartPatch = Cart.patch({});
|
|
579
575
|
cartPatch.items.addPatch(CartItem.patch({
|
|
580
576
|
id: item1.id,
|
|
581
|
-
amount: 1
|
|
577
|
+
amount: 1,
|
|
582
578
|
}));
|
|
583
579
|
|
|
584
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
580
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
585
581
|
patchArray.addPatch(orderPatch);
|
|
586
582
|
|
|
587
583
|
// Send a patch
|
|
588
|
-
const r2 = Request.buildJson(
|
|
589
|
-
r2.headers.authorization =
|
|
584
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
585
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
590
586
|
|
|
591
587
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
592
588
|
}
|
|
593
589
|
|
|
594
|
-
let ticketsAfter = await Ticket.where({orderId: order.id});
|
|
590
|
+
let ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
595
591
|
expect(ticketsAfter).toHaveLength(7);
|
|
596
592
|
|
|
597
|
-
let deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
598
|
-
let remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
593
|
+
let deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
594
|
+
let remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
599
595
|
expect(deletedTickets).toHaveLength(4);
|
|
600
596
|
expect(remainingTickets).toHaveLength(3);
|
|
601
597
|
|
|
@@ -605,28 +601,28 @@ describe("E2E.Tickets", () => {
|
|
|
605
601
|
// Now add an extra item
|
|
606
602
|
|
|
607
603
|
{
|
|
608
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
609
|
-
const cartPatch = Cart.patch({})
|
|
604
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
605
|
+
const cartPatch = Cart.patch({});
|
|
610
606
|
cartPatch.items.addPatch(CartItem.patch({
|
|
611
607
|
id: item1.id,
|
|
612
|
-
amount: 5
|
|
608
|
+
amount: 5,
|
|
613
609
|
}));
|
|
614
610
|
|
|
615
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
611
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
616
612
|
patchArray.addPatch(orderPatch);
|
|
617
613
|
|
|
618
614
|
// Send a patch
|
|
619
|
-
const r2 = Request.buildJson(
|
|
620
|
-
r2.headers.authorization =
|
|
615
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
616
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
621
617
|
|
|
622
618
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
623
619
|
}
|
|
624
620
|
|
|
625
|
-
ticketsAfter = await Ticket.where({orderId: order.id});
|
|
621
|
+
ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
626
622
|
expect(ticketsAfter).toHaveLength(7);
|
|
627
623
|
|
|
628
|
-
deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
629
|
-
remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
624
|
+
deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
625
|
+
remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
630
626
|
expect(deletedTickets).toHaveLength(0);
|
|
631
627
|
expect(remainingTickets).toHaveLength(7);
|
|
632
628
|
|
|
@@ -634,7 +630,7 @@ describe("E2E.Tickets", () => {
|
|
|
634
630
|
expect(ticketsAfter.map(mapTicketChangedAmount)).toIncludeSameMembers(tickets.map(mapTicketChangedAmount));
|
|
635
631
|
});
|
|
636
632
|
|
|
637
|
-
test(
|
|
633
|
+
test('Seats are assigned to each ticket as expected', async () => {
|
|
638
634
|
const item1 = CartItem.create({
|
|
639
635
|
product: ticket1,
|
|
640
636
|
productPrice: ticket1.prices[0],
|
|
@@ -643,39 +639,39 @@ describe("E2E.Tickets", () => {
|
|
|
643
639
|
CartReservedSeat.create({
|
|
644
640
|
section: seatingPlan.sections[0].id,
|
|
645
641
|
row: 'A',
|
|
646
|
-
seat: '1'
|
|
642
|
+
seat: '1',
|
|
647
643
|
}),
|
|
648
644
|
CartReservedSeat.create({
|
|
649
645
|
section: seatingPlan.sections[0].id,
|
|
650
646
|
row: 'A',
|
|
651
|
-
seat: '2'
|
|
647
|
+
seat: '2',
|
|
652
648
|
}),
|
|
653
649
|
CartReservedSeat.create({
|
|
654
650
|
section: seatingPlan.sections[0].id,
|
|
655
651
|
row: 'A',
|
|
656
|
-
seat: '3'
|
|
657
|
-
})
|
|
658
|
-
]
|
|
652
|
+
seat: '3',
|
|
653
|
+
}),
|
|
654
|
+
],
|
|
659
655
|
});
|
|
660
656
|
|
|
661
657
|
const orderData = OrderData.create({
|
|
662
658
|
paymentMethod: PaymentMethod.PointOfSale,
|
|
663
659
|
cart: Cart.create({
|
|
664
660
|
items: [
|
|
665
|
-
item1
|
|
666
|
-
]
|
|
661
|
+
item1,
|
|
662
|
+
],
|
|
667
663
|
}),
|
|
668
|
-
customer
|
|
669
|
-
})
|
|
670
|
-
|
|
671
|
-
const r = Request.buildJson(
|
|
664
|
+
customer,
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
const r = Request.buildJson('POST', `/webshop/${webshop.id}/order`, organization.getApiHost(), orderData);
|
|
672
668
|
|
|
673
669
|
const response = await testServer.test(endpoint, r);
|
|
674
670
|
expect(response.body).toBeDefined();
|
|
675
671
|
const order = response.body.order;
|
|
676
672
|
|
|
677
673
|
// Check tickets
|
|
678
|
-
const tickets = await Ticket.where({orderId: order.id});
|
|
674
|
+
const tickets = await Ticket.where({ orderId: order.id });
|
|
679
675
|
expect(tickets).toHaveLength(3);
|
|
680
676
|
|
|
681
677
|
expect(tickets.map(mapTicketCreation)).toIncludeSameMembers([
|
|
@@ -691,58 +687,58 @@ describe("E2E.Tickets", () => {
|
|
|
691
687
|
index: 2,
|
|
692
688
|
seat: item1.seats[1],
|
|
693
689
|
originalSeat: item1.seats[1],
|
|
694
|
-
total: 3
|
|
690
|
+
total: 3,
|
|
695
691
|
},
|
|
696
692
|
{
|
|
697
693
|
itemId: item1.id,
|
|
698
694
|
index: 3,
|
|
699
695
|
seat: item1.seats[2],
|
|
700
696
|
originalSeat: item1.seats[2],
|
|
701
|
-
total: 3
|
|
702
|
-
}
|
|
703
|
-
])
|
|
697
|
+
total: 3,
|
|
698
|
+
},
|
|
699
|
+
]);
|
|
704
700
|
|
|
705
701
|
// Now move a seat
|
|
706
702
|
{
|
|
707
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
703
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
708
704
|
|
|
709
|
-
const cartPatch = Cart.patch({})
|
|
705
|
+
const cartPatch = Cart.patch({});
|
|
710
706
|
cartPatch.items.addPatch(CartItem.patch({
|
|
711
707
|
id: item1.id,
|
|
712
708
|
seats: [
|
|
713
709
|
CartReservedSeat.create({
|
|
714
710
|
section: seatingPlan.sections[0].id,
|
|
715
711
|
row: 'A',
|
|
716
|
-
seat: '2'
|
|
712
|
+
seat: '2',
|
|
717
713
|
}),
|
|
718
714
|
CartReservedSeat.create({
|
|
719
715
|
section: seatingPlan.sections[0].id,
|
|
720
716
|
row: 'A',
|
|
721
|
-
seat: '3'
|
|
717
|
+
seat: '3',
|
|
722
718
|
}),
|
|
723
719
|
CartReservedSeat.create({
|
|
724
720
|
section: seatingPlan.sections[0].id,
|
|
725
721
|
row: 'A',
|
|
726
|
-
seat: '4'
|
|
722
|
+
seat: '4',
|
|
727
723
|
}),
|
|
728
|
-
]
|
|
724
|
+
],
|
|
729
725
|
}));
|
|
730
726
|
|
|
731
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
727
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
732
728
|
patchArray.addPatch(orderPatch);
|
|
733
729
|
|
|
734
730
|
// Send a patch
|
|
735
|
-
const r2 = Request.buildJson(
|
|
736
|
-
r2.headers.authorization =
|
|
731
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
732
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
737
733
|
|
|
738
734
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
739
735
|
}
|
|
740
736
|
|
|
741
|
-
let ticketsAfter = await Ticket.where({orderId: order.id});
|
|
737
|
+
let ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
742
738
|
expect(ticketsAfter).toHaveLength(3);
|
|
743
739
|
|
|
744
|
-
let deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
745
|
-
let remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
740
|
+
let deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
741
|
+
let remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
746
742
|
expect(deletedTickets).toHaveLength(0);
|
|
747
743
|
expect(remainingTickets).toHaveLength(3);
|
|
748
744
|
|
|
@@ -753,29 +749,29 @@ describe("E2E.Tickets", () => {
|
|
|
753
749
|
seat: CartReservedSeat.create({
|
|
754
750
|
section: seatingPlan.sections[0].id,
|
|
755
751
|
row: 'A',
|
|
756
|
-
seat: '4'
|
|
752
|
+
seat: '4',
|
|
757
753
|
}),
|
|
758
|
-
originalSeat: item1.seats[0]
|
|
754
|
+
originalSeat: item1.seats[0],
|
|
759
755
|
},
|
|
760
756
|
{
|
|
761
757
|
...mapTicketChangedAmount(tickets.find(t => t.index === 2)!),
|
|
762
758
|
index: 1,
|
|
763
759
|
seat: item1.seats[1],
|
|
764
|
-
originalSeat: item1.seats[1]
|
|
760
|
+
originalSeat: item1.seats[1],
|
|
765
761
|
},
|
|
766
762
|
{
|
|
767
763
|
...mapTicketChangedAmount(tickets.find(t => t.index === 3)!),
|
|
768
764
|
index: 2,
|
|
769
765
|
seat: item1.seats[2],
|
|
770
|
-
originalSeat: item1.seats[2]
|
|
771
|
-
}
|
|
772
|
-
])
|
|
766
|
+
originalSeat: item1.seats[2],
|
|
767
|
+
},
|
|
768
|
+
]);
|
|
773
769
|
|
|
774
770
|
// Move it back and also delete a different seat
|
|
775
771
|
{
|
|
776
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
772
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
777
773
|
|
|
778
|
-
const cartPatch = Cart.patch({})
|
|
774
|
+
const cartPatch = Cart.patch({});
|
|
779
775
|
cartPatch.items.addPatch(CartItem.patch({
|
|
780
776
|
id: item1.id,
|
|
781
777
|
amount: 2,
|
|
@@ -783,31 +779,31 @@ describe("E2E.Tickets", () => {
|
|
|
783
779
|
CartReservedSeat.create({
|
|
784
780
|
section: seatingPlan.sections[0].id,
|
|
785
781
|
row: 'A',
|
|
786
|
-
seat: '2'
|
|
782
|
+
seat: '2',
|
|
787
783
|
}),
|
|
788
784
|
CartReservedSeat.create({
|
|
789
785
|
section: seatingPlan.sections[0].id,
|
|
790
786
|
row: 'A',
|
|
791
|
-
seat: '1'
|
|
787
|
+
seat: '1',
|
|
792
788
|
}),
|
|
793
|
-
]
|
|
789
|
+
],
|
|
794
790
|
}));
|
|
795
791
|
|
|
796
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
792
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
797
793
|
patchArray.addPatch(orderPatch);
|
|
798
794
|
|
|
799
795
|
// Send a patch
|
|
800
|
-
const r2 = Request.buildJson(
|
|
801
|
-
r2.headers.authorization =
|
|
796
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
797
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
802
798
|
|
|
803
799
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
804
800
|
}
|
|
805
801
|
|
|
806
|
-
ticketsAfter = await Ticket.where({orderId: order.id});
|
|
802
|
+
ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
807
803
|
expect(ticketsAfter).toHaveLength(3);
|
|
808
804
|
|
|
809
|
-
deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
810
|
-
remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
805
|
+
deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
806
|
+
remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
811
807
|
expect(deletedTickets).toHaveLength(1);
|
|
812
808
|
expect(remainingTickets).toHaveLength(2);
|
|
813
809
|
|
|
@@ -815,26 +811,26 @@ describe("E2E.Tickets", () => {
|
|
|
815
811
|
expect(remainingTickets.map(mapTicketChangedAmount)).toIncludeSameMembers([
|
|
816
812
|
{
|
|
817
813
|
...mapTicketChangedAmount(tickets.find(t => t.index === 1)!),
|
|
818
|
-
index: 2
|
|
814
|
+
index: 2,
|
|
819
815
|
},
|
|
820
816
|
{
|
|
821
817
|
...mapTicketChangedAmount(tickets.find(t => t.index === 2)!),
|
|
822
|
-
index: 1
|
|
823
|
-
}
|
|
824
|
-
])
|
|
818
|
+
index: 1,
|
|
819
|
+
},
|
|
820
|
+
]);
|
|
825
821
|
|
|
826
822
|
expect(deletedTickets.map(mapTicketChangedAmount)).toIncludeSameMembers([
|
|
827
823
|
{
|
|
828
824
|
...mapTicketChangedAmount(tickets.find(t => t.index === 3)!),
|
|
829
|
-
index: 2
|
|
830
|
-
}
|
|
831
|
-
])
|
|
825
|
+
index: 2,
|
|
826
|
+
},
|
|
827
|
+
]);
|
|
832
828
|
|
|
833
829
|
// Add two total new different seats
|
|
834
830
|
{
|
|
835
|
-
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray()
|
|
831
|
+
const patchArray: PatchableArrayAutoEncoder<PrivateOrder> = new PatchableArray();
|
|
836
832
|
|
|
837
|
-
const cartPatch = Cart.patch({})
|
|
833
|
+
const cartPatch = Cart.patch({});
|
|
838
834
|
cartPatch.items.addPatch(CartItem.patch({
|
|
839
835
|
id: item1.id,
|
|
840
836
|
amount: 4,
|
|
@@ -842,41 +838,41 @@ describe("E2E.Tickets", () => {
|
|
|
842
838
|
CartReservedSeat.create({
|
|
843
839
|
section: seatingPlan.sections[0].id,
|
|
844
840
|
row: 'A',
|
|
845
|
-
seat: '2'
|
|
841
|
+
seat: '2',
|
|
846
842
|
}),
|
|
847
843
|
CartReservedSeat.create({
|
|
848
844
|
section: seatingPlan.sections[0].id,
|
|
849
845
|
row: 'A',
|
|
850
|
-
seat: '1'
|
|
846
|
+
seat: '1',
|
|
851
847
|
}),
|
|
852
848
|
CartReservedSeat.create({
|
|
853
849
|
section: seatingPlan.sections[0].id,
|
|
854
850
|
row: 'B',
|
|
855
|
-
seat: '1'
|
|
851
|
+
seat: '1',
|
|
856
852
|
}),
|
|
857
853
|
CartReservedSeat.create({
|
|
858
854
|
section: seatingPlan.sections[0].id,
|
|
859
855
|
row: 'B',
|
|
860
|
-
seat: '2'
|
|
856
|
+
seat: '2',
|
|
861
857
|
}),
|
|
862
|
-
]
|
|
858
|
+
],
|
|
863
859
|
}));
|
|
864
860
|
|
|
865
|
-
const orderPatch = PrivateOrder.patch({id: order.id, data: OrderData.patch({cart: cartPatch})});
|
|
861
|
+
const orderPatch = PrivateOrder.patch({ id: order.id, data: OrderData.patch({ cart: cartPatch }) });
|
|
866
862
|
patchArray.addPatch(orderPatch);
|
|
867
863
|
|
|
868
864
|
// Send a patch
|
|
869
|
-
const r2 = Request.buildJson(
|
|
870
|
-
r2.headers.authorization =
|
|
865
|
+
const r2 = Request.buildJson('PATCH', `/webshop/${webshop.id}/orders`, organization.getApiHost(), patchArray);
|
|
866
|
+
r2.headers.authorization = 'Bearer ' + token.accessToken;
|
|
871
867
|
|
|
872
868
|
await testServer.test(patchWebshopOrdersEndpoint, r2);
|
|
873
869
|
}
|
|
874
870
|
|
|
875
|
-
ticketsAfter = await Ticket.where({orderId: order.id});
|
|
871
|
+
ticketsAfter = await Ticket.where({ orderId: order.id });
|
|
876
872
|
expect(ticketsAfter).toHaveLength(4);
|
|
877
873
|
|
|
878
|
-
deletedTickets = ticketsAfter.filter(t => t.isDeleted)
|
|
879
|
-
remainingTickets = ticketsAfter.filter(t => !t.isDeleted)
|
|
874
|
+
deletedTickets = ticketsAfter.filter(t => t.isDeleted);
|
|
875
|
+
remainingTickets = ticketsAfter.filter(t => !t.isDeleted);
|
|
880
876
|
expect(deletedTickets).toHaveLength(0);
|
|
881
877
|
expect(remainingTickets).toHaveLength(4);
|
|
882
878
|
|
|
@@ -884,11 +880,11 @@ describe("E2E.Tickets", () => {
|
|
|
884
880
|
expect(remainingTickets.map(mapTicketChangedAmount)).toIncludeAllMembers([
|
|
885
881
|
{
|
|
886
882
|
...mapTicketChangedAmount(tickets.find(t => t.index === 1)!),
|
|
887
|
-
index: 2
|
|
883
|
+
index: 2,
|
|
888
884
|
},
|
|
889
885
|
{
|
|
890
886
|
...mapTicketChangedAmount(tickets.find(t => t.index === 2)!),
|
|
891
|
-
index: 1
|
|
887
|
+
index: 1,
|
|
892
888
|
},
|
|
893
889
|
{
|
|
894
890
|
...mapTicketChangedAmount(tickets.find(t => t.index === 3)!),
|
|
@@ -896,10 +892,10 @@ describe("E2E.Tickets", () => {
|
|
|
896
892
|
seat: CartReservedSeat.create({
|
|
897
893
|
section: seatingPlan.sections[0].id,
|
|
898
894
|
row: 'B',
|
|
899
|
-
seat: '1'
|
|
900
|
-
})
|
|
901
|
-
}
|
|
902
|
-
])
|
|
895
|
+
seat: '1',
|
|
896
|
+
}),
|
|
897
|
+
},
|
|
898
|
+
]);
|
|
903
899
|
|
|
904
900
|
// One new one
|
|
905
901
|
expect(remainingTickets.map(mapTicketCreation)).toIncludeAllMembers([
|
|
@@ -912,15 +908,14 @@ describe("E2E.Tickets", () => {
|
|
|
912
908
|
seat: CartReservedSeat.create({
|
|
913
909
|
section: seatingPlan.sections[0].id,
|
|
914
910
|
row: 'B',
|
|
915
|
-
seat: '2'
|
|
911
|
+
seat: '2',
|
|
916
912
|
}),
|
|
917
913
|
originalSeat: CartReservedSeat.create({
|
|
918
914
|
section: seatingPlan.sections[0].id,
|
|
919
915
|
row: 'B',
|
|
920
|
-
seat: '2'
|
|
921
|
-
})
|
|
922
|
-
}
|
|
916
|
+
seat: '2',
|
|
917
|
+
}),
|
|
918
|
+
},
|
|
923
919
|
]);
|
|
924
|
-
|
|
925
920
|
});
|
|
926
921
|
});
|