@jarwizz/create-jarshop 0.4.0 → 0.4.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.
|
@@ -14,14 +14,22 @@ import {
|
|
|
14
14
|
type VendureConfig,
|
|
15
15
|
} from "@vendure/core";
|
|
16
16
|
import type { MigrationInterface } from "typeorm";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
createTariffShippingCalculator,
|
|
19
|
+
jarShopKitMigrations,
|
|
20
|
+
} from "@jarwizz/feature-adapter-kit/server";
|
|
18
21
|
import { JarShopPacketaPlugin } from "@jarwizz/feature-packeta/server";
|
|
19
22
|
import {
|
|
20
23
|
JarShopInvoicingPlugin,
|
|
24
|
+
configureSlovakInvoicing,
|
|
21
25
|
jarShopInvoicingMigrations,
|
|
22
26
|
} from "@jarwizz/jarshop-invoicing/server";
|
|
23
27
|
|
|
24
|
-
import
|
|
28
|
+
import {
|
|
29
|
+
jarShopCodPaymentHandler,
|
|
30
|
+
referenceRedirectPaymentHandler,
|
|
31
|
+
type JarShopFeatures,
|
|
32
|
+
} from "./jarshop-features.js";
|
|
25
33
|
import { JarShopInvoiceDeliveryPlugin } from "./plugins/jarshop-checkout/invoice-delivery.plugin.js";
|
|
26
34
|
import { JarShopCheckoutPlugin } from "./plugins/jarshop-checkout/index.js";
|
|
27
35
|
import { JarShopOperationCodeCheck } from "./plugins/jarshop-checkout/operation-code-check.js";
|
|
@@ -31,7 +39,6 @@ let createVendureConfig: (
|
|
|
31
39
|
environment?: NodeJS.ProcessEnv,
|
|
32
40
|
) => VendureConfig;
|
|
33
41
|
let config: VendureConfig;
|
|
34
|
-
let clientFeatures: JarShopFeatures;
|
|
35
42
|
const originalAppEnvironment = process.env.APP_ENV;
|
|
36
43
|
const originalPacketaApiKey = process.env.PACKETA_API_KEY;
|
|
37
44
|
|
|
@@ -39,9 +46,42 @@ beforeAll(async () => {
|
|
|
39
46
|
process.env.APP_ENV = "test";
|
|
40
47
|
process.env.PACKETA_API_KEY = "0000000000000000";
|
|
41
48
|
({ createVendureConfig, config } = await import("./vendure-config.js"));
|
|
42
|
-
({ default: clientFeatures } = await import("./client/features.js"));
|
|
43
49
|
});
|
|
44
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The starter's default `src/client/features.ts`, rebuilt here. That file is
|
|
53
|
+
* client-owned, so a Client Project may change it (switch invoicing off, add a
|
|
54
|
+
* payment Feature) and this platform-managed test must not depend on it.
|
|
55
|
+
*/
|
|
56
|
+
const starterFeatures: JarShopFeatures = {
|
|
57
|
+
paymentMethodHandlers: [
|
|
58
|
+
jarShopCodPaymentHandler,
|
|
59
|
+
referenceRedirectPaymentHandler,
|
|
60
|
+
],
|
|
61
|
+
shippingEligibilityCheckers: [defaultShippingEligibilityChecker],
|
|
62
|
+
shippingCalculators: [createTariffShippingCalculator()],
|
|
63
|
+
packeta: true,
|
|
64
|
+
invoicing: configureSlovakInvoicing({
|
|
65
|
+
seller: {
|
|
66
|
+
name: "JarShop test seller",
|
|
67
|
+
street: "Testovacia 1",
|
|
68
|
+
city: "Žilina",
|
|
69
|
+
postalCode: "010 01",
|
|
70
|
+
ico: "00000000",
|
|
71
|
+
dic: "0000000000",
|
|
72
|
+
vatStatus: "non-payer",
|
|
73
|
+
iban: "TEST-IBAN",
|
|
74
|
+
registerEntry: "Test register",
|
|
75
|
+
},
|
|
76
|
+
lastIssuedNumber: 20260000,
|
|
77
|
+
vendureHost: "http://localhost:3000",
|
|
78
|
+
localStorageDirectory: "/tmp/jarshop-features-test-invoices",
|
|
79
|
+
chromeExecutablePath: "/usr/bin/chromium",
|
|
80
|
+
}),
|
|
81
|
+
plugins: [],
|
|
82
|
+
migrations: [],
|
|
83
|
+
};
|
|
84
|
+
|
|
45
85
|
afterAll(() => {
|
|
46
86
|
if (originalAppEnvironment === undefined) delete process.env.APP_ENV;
|
|
47
87
|
else process.env.APP_ENV = originalAppEnvironment;
|
|
@@ -72,12 +112,18 @@ const codes = (operations: readonly { code: string }[] | undefined) =>
|
|
|
72
112
|
(operations ?? []).map((operation) => operation.code);
|
|
73
113
|
|
|
74
114
|
describe("the client-owned features slot", () => {
|
|
115
|
+
it("builds the project's config from its own client features", () => {
|
|
116
|
+
// Whatever the client composed, the checkout core is always present.
|
|
117
|
+
expect(config.plugins).toContain(JarShopCheckoutPlugin);
|
|
118
|
+
});
|
|
119
|
+
|
|
75
120
|
it("composes today's starter behaviour from the default features", () => {
|
|
76
|
-
|
|
121
|
+
const composed = createVendureConfig(starterFeatures);
|
|
122
|
+
expect(codes(composed.paymentOptions.paymentMethodHandlers)).toEqual([
|
|
77
123
|
"jarshop-cod-handler",
|
|
78
124
|
"reference-redirect",
|
|
79
125
|
]);
|
|
80
|
-
expect(
|
|
126
|
+
expect(composed.plugins).toEqual(
|
|
81
127
|
expect.arrayContaining([
|
|
82
128
|
JarShopCheckoutPlugin,
|
|
83
129
|
JarShopInvoicingPlugin,
|
|
@@ -85,7 +131,7 @@ describe("the client-owned features slot", () => {
|
|
|
85
131
|
JarShopPacketaPlugin,
|
|
86
132
|
]),
|
|
87
133
|
);
|
|
88
|
-
expect(
|
|
134
|
+
expect(composed.dbConnectionOptions.migrations).toEqual(
|
|
89
135
|
expect.arrayContaining([
|
|
90
136
|
...jarShopKitMigrations,
|
|
91
137
|
...jarShopInvoicingMigrations,
|
|
@@ -95,9 +141,9 @@ describe("the client-owned features slot", () => {
|
|
|
95
141
|
|
|
96
142
|
it("switches invoicing off and adds a client payment handler, plugin and migration", () => {
|
|
97
143
|
const composed = createVendureConfig({
|
|
98
|
-
...
|
|
144
|
+
...starterFeatures,
|
|
99
145
|
paymentMethodHandlers: [
|
|
100
|
-
...
|
|
146
|
+
...starterFeatures.paymentMethodHandlers,
|
|
101
147
|
dummyPaymentHandler,
|
|
102
148
|
],
|
|
103
149
|
invoicing: false,
|
|
@@ -125,10 +171,10 @@ describe("the client-owned features slot", () => {
|
|
|
125
171
|
|
|
126
172
|
it("lets the features and the environment each switch Packeta off", () => {
|
|
127
173
|
const disabledInFeatures = createVendureConfig({
|
|
128
|
-
...
|
|
174
|
+
...starterFeatures,
|
|
129
175
|
packeta: false,
|
|
130
176
|
});
|
|
131
|
-
const disabledByEnvironment = createVendureConfig(
|
|
177
|
+
const disabledByEnvironment = createVendureConfig(starterFeatures, {
|
|
132
178
|
...process.env,
|
|
133
179
|
JARSHOP_PACKETA_ENABLED: "0",
|
|
134
180
|
});
|
|
@@ -145,7 +191,7 @@ describe("the client-owned features slot", () => {
|
|
|
145
191
|
|
|
146
192
|
it("replaces the shipping operations with the client's own list", () => {
|
|
147
193
|
const composed = createVendureConfig({
|
|
148
|
-
...
|
|
194
|
+
...starterFeatures,
|
|
149
195
|
packeta: false,
|
|
150
196
|
shippingEligibilityCheckers: [defaultShippingEligibilityChecker],
|
|
151
197
|
shippingCalculators: [],
|
|
@@ -159,7 +205,7 @@ describe("the client-owned features slot", () => {
|
|
|
159
205
|
it("rejects two operations of one kind with the same code", () => {
|
|
160
206
|
expect(() =>
|
|
161
207
|
createVendureConfig({
|
|
162
|
-
...
|
|
208
|
+
...starterFeatures,
|
|
163
209
|
paymentMethodHandlers: [dummyPaymentHandler, dummyPaymentHandler],
|
|
164
210
|
shippingCalculators: [
|
|
165
211
|
defaultShippingCalculator,
|
|
@@ -204,13 +250,13 @@ describe("the client-owned features slot", () => {
|
|
|
204
250
|
};
|
|
205
251
|
|
|
206
252
|
// The starter's own composition passes once every plugin hook has run.
|
|
207
|
-
await expect(check(
|
|
253
|
+
await expect(check(starterFeatures)).resolves.toBeUndefined();
|
|
208
254
|
// createVendureConfig cannot see this clash; the startup check can.
|
|
209
255
|
await expect(
|
|
210
256
|
check({
|
|
211
|
-
...
|
|
257
|
+
...starterFeatures,
|
|
212
258
|
paymentMethodHandlers: [
|
|
213
|
-
...
|
|
259
|
+
...starterFeatures.paymentMethodHandlers,
|
|
214
260
|
dummyPaymentHandler,
|
|
215
261
|
],
|
|
216
262
|
plugins: [PaymentContributingPlugin],
|