fixing combined interval stuff

This commit is contained in:
John Yeo
2025-08-16 07:17:52 -07:00
parent f3ef6e1596
commit 42c3e73334
136 changed files with 3170 additions and 2043 deletions

View File

@@ -6,7 +6,7 @@ import Stripe from "stripe";
import { DrizzleCli } from "@/db/initDrizzle.js";
import { setupBefore } from "tests/before.js";
import { createProducts } from "tests/utils/productUtils.js";
import { addPrefixToProducts, replaceItems, runAttachTest } from "../utils.js";
import { addPrefixToProducts, replaceItems } from "../utils.js";
import { constructArrearItem } from "@/utils/scriptUtils/constructItem.js";
import { TestFeature } from "tests/setup/v2Features.js";
import { constructProduct } from "@/utils/scriptUtils/createTestProducts.js";
@@ -17,6 +17,7 @@ import { hoursToFinalizeInvoice } from "tests/utils/constants.js";
import runUpdateEntsTest from "./expectUpdateEnts.js";
import { timeout } from "@/utils/genUtils.js";
import { getExpectedInvoiceTotal } from "tests/utils/expectUtils/expectInvoiceUtils.js";
import { attachAndExpectCorrect } from "tests/utils/expectUtils/expectAttach.js";
const testCase = "updateEnts1";
@@ -76,7 +77,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing inclu
});
it("should attach pro product", async function () {
await runAttachTest({
await attachAndExpectCorrect({
autumn,
customerId,
product: pro,
@@ -168,7 +169,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing inclu
const invoice = customer.invoices![0];
expect(invoice.total).to.equal(
invoiceTotal,
"invoice total after 1 cycle should be correct",
"invoice total after 1 cycle should be correct"
);
});
});

View File

@@ -6,7 +6,7 @@ import Stripe from "stripe";
import { DrizzleCli } from "@/db/initDrizzle.js";
import { setupBefore } from "tests/before.js";
import { createProducts } from "tests/utils/productUtils.js";
import { addPrefixToProducts, replaceItems, runAttachTest } from "../utils.js";
import { addPrefixToProducts, replaceItems } from "../utils.js";
import { constructArrearItem } from "@/utils/scriptUtils/constructItem.js";
import { TestFeature } from "tests/setup/v2Features.js";
import { constructProduct } from "@/utils/scriptUtils/createTestProducts.js";
@@ -17,6 +17,7 @@ import { hoursToFinalizeInvoice } from "tests/utils/constants.js";
import runUpdateEntsTest from "./expectUpdateEnts.js";
import { timeout } from "@/utils/genUtils.js";
import { getExpectedInvoiceTotal } from "tests/utils/expectUtils/expectInvoiceUtils.js";
import { attachAndExpectCorrect } from "tests/utils/expectUtils/expectAttach.js";
const testCase = "updateEnts2";
@@ -88,7 +89,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing inclu
});
it("should attach pro annual product", async function () {
await runAttachTest({
await attachAndExpectCorrect({
autumn,
customerId,
product: pro,
@@ -186,7 +187,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing inclu
const invoice = customer.invoices![0];
expect(invoice.total).to.equal(
invoiceTotal,
"invoice total after 1 cycle should be correct",
"invoice total after 1 cycle should be correct"
);
});
});

View File

@@ -8,13 +8,14 @@ import { APIVersion, AppEnv, Organization } from "@autumn/shared";
import { DrizzleCli } from "@/db/initDrizzle.js";
import { setupBefore } from "tests/before.js";
import { createProducts } from "tests/utils/productUtils.js";
import { addPrefixToProducts, replaceItems, runAttachTest } from "../utils.js";
import { addPrefixToProducts, replaceItems } from "../utils.js";
import { constructArrearItem } from "@/utils/scriptUtils/constructItem.js";
import { TestFeature } from "tests/setup/v2Features.js";
import { constructProduct } from "@/utils/scriptUtils/createTestProducts.js";
import { advanceTestClock } from "tests/utils/stripeUtils.js";
import { addWeeks } from "date-fns";
import { constructFeatureItem } from "@/internal/products/product-items/productItemUtils.js";
import { attachAndExpectCorrect } from "tests/utils/expectUtils/expectAttach.js";
const testCase = "updateEnts3";
@@ -85,7 +86,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing featu
});
it("should attach pro annual product", async function () {
await runAttachTest({
await attachAndExpectCorrect({
autumn,
customerId,
product: pro,
@@ -177,7 +178,7 @@ describe(`${chalk.yellowBright(`${testCase}: Testing update ents (changing featu
it("should attach custom pro product with removed feature item", async function () {
const customItems2 = customItems.filter(
(item) => item.feature_id != TestFeature.Messages,
(item) => item.feature_id != TestFeature.Messages
);
const customProduct = {

View File

@@ -13,12 +13,9 @@ import Stripe from "stripe";
import { DrizzleCli } from "@/db/initDrizzle.js";
import { setupBefore } from "tests/before.js";
import { createProducts } from "tests/utils/productUtils.js";
import { addPrefixToProducts, replaceItems, runAttachTest } from "../utils.js";
import {
constructArrearItem,
constructArrearProratedItem,
constructPrepaidItem,
} from "@/utils/scriptUtils/constructItem.js";
import { addPrefixToProducts } from "../utils.js";
import { constructArrearItem } from "@/utils/scriptUtils/constructItem.js";
import { attachAndExpectCorrect } from "tests/utils/expectUtils/expectAttach.js";
import { TestFeature } from "tests/setup/v2Features.js";
import { constructProduct } from "@/utils/scriptUtils/createTestProducts.js";
import { expect } from "chai";
@@ -82,7 +79,7 @@ describe(`${chalk.yellowBright(`${testCase}: Checking price changes don't result
});
it("should attach pro annual product", async function () {
await runAttachTest({
await attachAndExpectCorrect({
autumn,
customerId,
product: pro,