saleor-apps-redis_apl/apps/taxes/scripts/migrations/app-webhook-repository.test.ts

61 lines
1.6 KiB
TypeScript
Raw Normal View History

feat: change the flow from OrderCreated to OrderConfirmed (#826) * refactor: :recycle: extract order-metadata-manager * feat: :construction: add basic boilerplate * feat: :sparkles: add readExternalIdFromOrderMetadata * Revert "feat: :sparkles: add readExternalIdFromOrderMetadata" This reverts commit a78d9d4597672f8605cf998a9f784aebaab27de1. * feat: :sparkles: add order-cancelled avatax adapter * test: :white_check_mark: add tests for AvataxOrderCancelledPayloadTransformer * refactor: avataxId instead of externalId * refactor: :recycle: split up webhook response * build: :arrow_up: upgrade avatax * refactor: :recycle: extend logging in webhook response errors * fix: :bug: split privateMetadata and publicMetadata * fix: :bug: use "DEFAULT" value of companyCode for commit to work * fix: :alembic: fix voidTransaction type * refactor: :truck: order_created -> order_confirmed * fix: :bug: change voidReason * build: :construction_worker: add changeset * refactor: :fire: order_fulfilled webhook * feat: Avatax metadata tax calculation date (#843) * feat: :sparkles: add metadata tax calculation date * build: :construction_worker: add changeset * feat: Avatax metadata document code (#844) * feat: :sparkles: provide document code through metadata field * build: :construction_worker: add changeset * refactor: :recycle: fallback to default company code for migration * refactor: :recycle: patch order-created files and add deprecation note * Revert "refactor: :fire: order_fulfilled webhook" This reverts commit fd098642735ae9d62e3a876088226bd0f108afd6. * refactor: :recycle: patch order-fulfilled files and add deprecation note * fix: :bug: bring back deprecated webhooks to manifest * feat: :alembic: add AppWebhookMigrator (#850) * refactor: :truck: order_created -> order_confirmed * refactor: :fire: order_fulfilled webhook * feat: :alembic: add AppWebhookMigrator * feat: :sparkles: add mode to migrator * feat: :sparkles: add draft of run-report and migrateWebhook method * refactor: :recycle: address feedback * feat: :sparkles: add tests and new structure * refactor: :fire: util * feat: :sparkles: add enable/disable webhook rollback flow * refactor: :recycle: modify the taxes-migration flow * refactor: :recycle: generalize document code & date resolver * chore: :card_file_box: add run-migration * chore: :bulb: update comments about migration flow * fix: :bug: slice document code * refactor: :recycle: try/catch at the top level * chore: :bulb: add comments * Update shiny-meals-wait.md * Update soft-steaks-know.md * Update soft-steaks-know.md * fix: :white_check_mark: fix test * feat: :sparkles: change createTransaction to createOrAdjustTransaction this feature grants idempotency of the transaction flow * feat: :sparkles: add number field to OrderConfirmed payload * chore: :bulb: add deprecation comment to metadata method * docs: :memo: add todo comment to refactor sumPayloadLines * feat: :sparkles: add resolveStringOrThrow and use it for email * fix: :bug: add missing number to mock
2023-08-10 11:08:20 +00:00
import { Client } from "urql";
import { AppWebhookRepository } from "./app-webhook-repository";
import { expect, describe, it } from "vitest";
import { CreateAppWebhookMutationVariables } from "../../generated/graphql";
describe("AppWebhookRepository", () => {
describe("getAll", () => {
it("throws error when error returned", async () => {
const client = {
query: () => ({
toPromise: () => ({
error: {
message: "error",
},
}),
}),
} as unknown as Client;
const appWebhookRepository = new AppWebhookRepository(client);
await expect(appWebhookRepository.getAll()).rejects.toThrow();
});
});
describe("delete", () => {
it("throws error when error returned", async () => {
const client = {
mutation: () => ({
toPromise: () => ({
error: {
message: "error",
},
}),
}),
} as unknown as Client;
const appWebhookRepository = new AppWebhookRepository(client);
await expect(appWebhookRepository.delete("id")).rejects.toThrow();
});
});
describe("create", () => {
it("throws error when error returned", async () => {
const client = {
mutation: () => ({
toPromise: () => ({
error: {
message: "error",
},
}),
}),
} as unknown as Client;
const appWebhookRepository = new AppWebhookRepository(client);
await expect(
appWebhookRepository.create({} as unknown as CreateAppWebhookMutationVariables)
).rejects.toThrow();
});
});
});