Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, it as test } from "@std/testing/bdd";
import { stub } from "@std/testing/mock";
import { handleRequest } from "#routes";
import { stripeApi } from "#shared/stripe.ts";
import { renderPaymentSuccess } from "#test/lib/payment-success-helpers.ts";
import { expectHtmlResponse, expectRedirect } from "#test-utils/assertions.ts";
import { describeWithEnv } from "#test-utils/db.ts";
import { bookAttendee } from "#test-utils/db-helpers/attendee-payments.ts";
Expand All @@ -11,7 +12,6 @@ import { withEnv } from "#test-utils/env.ts";
import { signMeta, singleItem } from "#test-utils/factories.ts";
import { mockRequest } from "#test-utils/mocks.ts";
import { setupStripe } from "#test-utils/settings.ts";
import { renderPaymentSuccess } from "./payment-success-helpers.ts";

describeWithEnv("server (payment flow: ticket success)", { db: true }, () => {
describe("payment success token verification", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { bookAttendee } from "#test-utils/db-helpers/attendee-payments.ts";
import { createTestListing } from "#test-utils/db-helpers/listings.ts";
import { setupStripe } from "#test-utils/settings.ts";

type TestListing = Awaited<ReturnType<typeof createTestListing>>;

/**
* Enables Stripe, makes a paid listing with a single spot, and fills that spot,
* so a later booking of the same listing fails as sold out. Returns the listing.
*/
export const fillSoldOutListing = async () => {
export const fillSoldOutListing = async (): Promise<TestListing> => {
await setupStripe();
const listing = await createTestListing({
maxAttendees: 1,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server/payments/replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { handleRequest } from "#routes";
import { getAttendeesRaw } from "#shared/db/attendees/queries.ts";
import { isSessionProcessed } from "#shared/db/processed-payments.ts";
import { getNoteRows } from "#shared/db/system-notes.ts";
import { fillSoldOutListing } from "#test/lib/server-payments/_shared-setup.ts";
import { fillSoldOutListing } from "#test/integration/server/payments/_shared-setup.ts";
import { expectHtmlResponse } from "#test-utils/assertions.ts";
import { describeWithEnv } from "#test-utils/db.ts";
import {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server/payments/success.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { expect } from "@std/expect";
import { describe, it as test } from "@std/testing/bdd";
import { handleRequest } from "#routes";
import { fillSoldOutListing } from "#test/lib/server-payments/_shared-setup.ts";
import { fillSoldOutListing } from "#test/integration/server/payments/_shared-setup.ts";
import { expectHtmlResponse } from "#test-utils/assertions.ts";
import { describeWithEnv } from "#test-utils/db.ts";
import {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server/webhooks/modifier-refunds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { expect } from "@std/expect";
import { it as test } from "@std/testing/bdd";
import { modifiersTable } from "#shared/db/modifiers.ts";
import { createServiceChargeScenario } from "#test/lib/server-webhooks/service-charge-scenario.ts";
import { createServiceChargeScenario } from "#test/integration/server/webhooks/service-charge-scenario.ts";
import { describeWithEnv } from "#test-utils/db.ts";
import { createTestListing } from "#test-utils/db-helpers/listings.ts";
import { singleModifierMeta } from "#test-utils/factories.ts";
Expand Down
2 changes: 1 addition & 1 deletion test/integration/server/webhooks/modifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
modifierListings,
modifiersTable,
} from "#shared/db/modifiers.ts";
import { createServiceChargeScenario } from "#test/lib/server-webhooks/service-charge-scenario.ts";
import { createServiceChargeScenario } from "#test/integration/server/webhooks/service-charge-scenario.ts";
import { describeWithEnv } from "#test-utils/db.ts";
import { createTestGroup } from "#test-utils/db-helpers/groups.ts";
import { createTestListing } from "#test-utils/db-helpers/listings.ts";
Expand Down
32 changes: 32 additions & 0 deletions test/integration/server/webhooks/service-charge-scenario.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { type ModifierRow, modifiersTable } from "#shared/db/modifiers.ts";
import { createTestListing } from "#test-utils/db-helpers/listings.ts";

type TestListing = Awaited<ReturnType<typeof createTestListing>>;

interface ServiceChargeScenario {
listing: TestListing;
modifier: ModifierRow;
}

/**
* A £10 listing plus a 10%-charge "Service charge" modifier — the base setup
* shared by `modifiers.test.ts`'s "accepts a webhook whose total includes an
* applied modifier" and `modifier-refunds.test.ts`'s "refunds a webhook whose
* total omits an applied modifier". The two are intentional parallel
* variants (total correctly includes the surcharge vs. omits it), so the
* setup is colocated here rather than duplicated across both files.
*/
export const createServiceChargeScenario =
async (): Promise<ServiceChargeScenario> => {
const listing = await createTestListing({
maxAttendees: 50,
unitPrice: 1000,
});
const modifier = await modifiersTable.insert({
calcKind: "percent",
calcValue: 10,
direction: "charge",
name: "Service charge",
});
return { listing, modifier };
};
24 changes: 0 additions & 24 deletions test/lib/server-webhooks/service-charge-scenario.ts

This file was deleted.