@tribe-nest/forge 3.69.0 → 3.74.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.
@@ -193,6 +193,91 @@ describe("CheckoutLinkPayment", () => {
193
193
  });
194
194
  });
195
195
 
196
+ describe("several items and shipping (phase 2)", () => {
197
+ const multi = (shipping: CheckoutLinkView["shipping"]) =>
198
+ view({
199
+ item: { type: "product", title: "Tour Tee (Large)" },
200
+ items: [
201
+ {
202
+ type: "product",
203
+ title: "Tour Tee (Large)",
204
+ quantity: 2,
205
+ unitPriceCents: 3000,
206
+ physical: true,
207
+ productId: "p-1",
208
+ productVariantId: "v-1",
209
+ },
210
+ { type: "event_ticket", title: "Spring Show: General", quantity: 1, unitPriceCents: 2000, physical: false },
211
+ ],
212
+ quantity: 3,
213
+ unitPriceCents: null,
214
+ totalCents: 8000,
215
+ shipping,
216
+ });
217
+
218
+ it("lists every line with its amount, and holds Pay until the delivery address is in", () => {
219
+ const html = render(
220
+ page({
221
+ link: { isLoading: false, error: null, data: multi({ required: true, set: false, address: null, costCents: null }) },
222
+ }),
223
+ );
224
+ expect(html).toContain('data-testid="checkout-link-items"');
225
+ expect(html).toContain("2 x Tour Tee (Large)");
226
+ expect(html).toContain("$60.00");
227
+ expect(html).toContain("Spring Show: General");
228
+ expect(html).not.toContain("Quantity:");
229
+ expect(html).toContain('data-testid="checkout-link-shipping" data-state="address"');
230
+ expect(html).toContain("Delivery address");
231
+ expect(html).toMatch(/<button disabled=""[^>]*data-testid="checkout-link-pay"/);
232
+ expect(html).not.toContain('data-testid="checkout-link-shipping-error"');
233
+ expect(html).toContain("Pay $80.00");
234
+ });
235
+
236
+ it("once the address is in: the address, the shipping line, the total with shipping, a way to change it", () => {
237
+ const html = render(
238
+ page({
239
+ link: {
240
+ isLoading: false,
241
+ error: null,
242
+ data: multi({
243
+ required: true,
244
+ set: true,
245
+ address: { address1: "1 Main St", city: "Austin", stateCode: "TX", countryCode: "US", zip: "78701" },
246
+ costCents: 1000,
247
+ }),
248
+ },
249
+ }),
250
+ );
251
+ expect(html).toContain('data-state="set"');
252
+ expect(html).toContain("1 Main St, Austin, TX, 78701, US");
253
+ expect(html).toContain('data-testid="checkout-link-shipping-cost"');
254
+ expect(html).toContain("$10.00");
255
+ expect(html).toContain("Pay $90.00");
256
+ expect(html).toContain('data-testid="checkout-link-change-address"');
257
+ expect(html).not.toMatch(/<button disabled=""[^>]*data-testid="checkout-link-pay"/);
258
+ });
259
+
260
+ it("the address cannot be changed once a payment has started", () => {
261
+ const html = render(
262
+ page({
263
+ paymentStarted: true,
264
+ clientSecret: "pi_secret",
265
+ link: {
266
+ isLoading: false,
267
+ error: null,
268
+ data: multi({
269
+ required: true,
270
+ set: true,
271
+ address: { address1: "1 Main St", city: "Austin", stateCode: "TX", countryCode: "US", zip: "78701" },
272
+ costCents: 1000,
273
+ }),
274
+ },
275
+ }),
276
+ );
277
+ expect(html).not.toContain('data-testid="checkout-link-change-address"');
278
+ });
279
+ });
280
+
196
281
  it("an unknown link says it is not valid", () => {
197
282
  const html = render(page({ link: { isLoading: false, error: new Error("404"), data: undefined } }));
198
283
  expect(html).toContain('data-state="not-found"');