-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
405dee1
commit 007d36c
Showing
10 changed files
with
53 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,17 @@ import { OrderConfirmedFragment } from "../graphql/subscriptions/OrderConfirmed" | |
|
||
export const defaultOrder: ResultOf<typeof OrderConfirmedFragment> = { | ||
id: "T3JkZXI6ZTUzZTBlM2MtMjk5Yi00OWYxLWIyZDItY2Q4NWExYTgxYjY2", | ||
userEmail: "", | ||
user: { | ||
avataxCustomerCode: null, | ||
id: "VXNlcjoyMDg0NTEwNDEw", | ||
email: "[email protected]", | ||
}, | ||
number: "1234", | ||
avataxEntityCode: null, | ||
avataxCustomerCode: null, | ||
avataxDocumentCode: null, | ||
avataxTaxCalculationDate: null, | ||
created: "2023-05-25T09:18:55.203440+00:00", | ||
status: "UNFULFILLED", | ||
channel: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import { ResultOf } from "@/graphql"; | ||
import { SaleorOrderConfirmedEvent } from "@/modules/saleor"; | ||
|
||
import { OrderConfirmedFragment } from "../../../../graphql/subscriptions/OrderConfirmed"; | ||
import { OrderConfirmedPayload } from "../../webhooks/payloads/order-confirmed-payload"; | ||
import { SaleorOrderLineMockFactory } from "../order-line-mocks"; | ||
import { SaleorOrderConfirmedEvent } from "./event"; | ||
|
||
export class SaleorOrderConfirmedEventMockFactory { | ||
private static _getGraphqlPayload = (): { | ||
order: NonNullable<OrderConfirmedPayload["order"]>; | ||
__typename: "OrderConfirmed"; | ||
} => ({ | ||
order: { | ||
private static _getGraphqlPayload = () => { | ||
const o = { | ||
userEmail: "", | ||
avataxDocumentCode: null, | ||
avataxEntityCode: null, | ||
avataxCustomerCode: null, | ||
avataxTaxCalculationDate: null, | ||
user: { | ||
id: "id", | ||
avataxCustomerCode: null, | ||
email: "[email protected]", | ||
}, | ||
id: "order-id", | ||
|
@@ -33,9 +39,16 @@ export class SaleorOrderConfirmedEventMockFactory { | |
}, | ||
}, | ||
shippingAddress: { | ||
__typename: "Address", | ||
city: "Krakow", | ||
country: { code: "PL", __typename: "CountryDisplay" }, | ||
country: { code: "PL" }, | ||
countryArea: "Malopolskie", | ||
postalCode: "12345", | ||
streetAddress1: "Jana Pawla 2", | ||
streetAddress2: "2137", | ||
}, | ||
billingAddress: { | ||
city: "Krakow", | ||
country: { code: "PL" }, | ||
countryArea: "Malopolskie", | ||
postalCode: "12345", | ||
streetAddress1: "Jana Pawla 2", | ||
|
@@ -51,15 +64,18 @@ export class SaleorOrderConfirmedEventMockFactory { | |
currency: "USD", | ||
}, | ||
lines: [SaleorOrderLineMockFactory.getGraphqlPayload()], | ||
__typename: "Order" as const, | ||
}, | ||
__typename: "OrderConfirmed" as const, | ||
}); | ||
} satisfies NonNullable<ResultOf<typeof OrderConfirmedFragment>>; | ||
|
||
return { | ||
order: o, | ||
} as const; | ||
}; | ||
|
||
static create( | ||
graphqlPayload: OrderConfirmedPayload = SaleorOrderConfirmedEventMockFactory._getGraphqlPayload(), | ||
) { | ||
const possibleOrderLine = SaleorOrderConfirmedEvent.createFromGraphQL(graphqlPayload); | ||
static create(graphqlPayload?: OrderConfirmedPayload) { | ||
const possibleOrderLine = SaleorOrderConfirmedEvent.createFromGraphQL( | ||
graphqlPayload ?? | ||
(SaleorOrderConfirmedEventMockFactory._getGraphqlPayload() as OrderConfirmedPayload), | ||
); | ||
|
||
if (possibleOrderLine.isErr()) { | ||
throw possibleOrderLine.error; | ||
|
5 changes: 1 addition & 4 deletions
5
apps/avatax/src/modules/webhooks/payloads/order-confirmed-payload.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters