Steps 1-11, still need to do 12

This commit is contained in:
2025-08-07 15:29:23 -05:00
parent b66a516d20
commit 4019e921d3
15 changed files with 3731 additions and 55 deletions

View File

@@ -14,6 +14,7 @@ describe("Environment Configuration", () => {
delete process.env.TARGET_TAG;
delete process.env.PRICE_ADJUSTMENT_PERCENTAGE;
delete process.env.OPERATION_MODE;
delete process.env.SCHEDULED_EXECUTION_TIME;
});
afterAll(() => {
@@ -37,6 +38,8 @@ describe("Environment Configuration", () => {
targetTag: "sale",
priceAdjustmentPercentage: 10,
operationMode: "update",
scheduledExecutionTime: null,
isScheduled: false,
});
});
@@ -379,6 +382,8 @@ describe("Environment Configuration", () => {
targetTag: "sale",
priceAdjustmentPercentage: 10,
operationMode: "rollback",
scheduledExecutionTime: null,
isScheduled: false,
});
});
@@ -408,5 +413,58 @@ describe("Environment Configuration", () => {
expect(config.priceAdjustmentPercentage).toBe(-20);
});
});
describe("Scheduled Execution Time", () => {
beforeEach(() => {
// Set up valid base environment variables
process.env.SHOPIFY_SHOP_DOMAIN = "test-shop.myshopify.com";
process.env.SHOPIFY_ACCESS_TOKEN = "shpat_1234567890abcdef";
process.env.TARGET_TAG = "sale";
process.env.PRICE_ADJUSTMENT_PERCENTAGE = "10";
});
test("should handle missing SCHEDULED_EXECUTION_TIME (backward compatibility)", () => {
// SCHEDULED_EXECUTION_TIME is not set
const config = loadEnvironmentConfig();
expect(config.scheduledExecutionTime).toBeNull();
expect(config.isScheduled).toBe(false);
});
test("should handle empty SCHEDULED_EXECUTION_TIME", () => {
process.env.SCHEDULED_EXECUTION_TIME = "";
const config = loadEnvironmentConfig();
expect(config.scheduledExecutionTime).toBeNull();
expect(config.isScheduled).toBe(false);
});
test("should accept valid ISO 8601 datetime with Z timezone", () => {
const futureTime = "2030-01-15T12:00:00Z";
process.env.SCHEDULED_EXECUTION_TIME = futureTime;
const config = loadEnvironmentConfig();
expect(config.scheduledExecutionTime).toEqual(new Date(futureTime));
expect(config.isScheduled).toBe(true);
});
test("should throw error for invalid datetime format", () => {
process.env.SCHEDULED_EXECUTION_TIME = "2024-01-15 12:00:00";
expect(() => loadEnvironmentConfig()).toThrow(
"Invalid SCHEDULED_EXECUTION_TIME format"
);
});
test("should throw error for past datetime", () => {
const pastTime = "2020-01-15T09:00:00Z"; // Clearly in the past
process.env.SCHEDULED_EXECUTION_TIME = pastTime;
expect(() => loadEnvironmentConfig()).toThrow("must be in the future");
});
});
});
});