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
26 changes: 13 additions & 13 deletions apps/web/__tests__/ai-rule-fix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule: rule,
correctRule: null,
actualRule: rule,
expectedRule: null,
email: salesEmail,
user: getUser(),
});

console.log(result);

expect(result).toBeDefined();
expect(result.rule).toBe("matched_rule");
expect(result.rule).toBe("actual_rule");
expect(result.fixedInstructions).toContain("sales");
expect(result.fixedInstructions).not.toBe(rule.instructions);
// The new instructions should be more specific to exclude sales pitches
Expand All @@ -51,10 +51,10 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

test("should fix rules when email matched wrong rule instead of correct rule", async () => {
const incorrectRule = {
const actualRule = {
instructions: "Match emails about technical support and bug reports",
};
const correctRule = {
const expectedRule = {
instructions: "Match emails about product feedback and feature requests",
};

Expand All @@ -72,8 +72,8 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule,
correctRule,
actualRule,
expectedRule,
email: feedbackEmail,
user: getUser(),
});
Expand All @@ -90,7 +90,7 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

test("should fix rule when email matched but shouldn't match any rules", async () => {
const incorrectRule = {
const actualRule = {
instructions: "Match emails about marketing collaborations",
};

Expand All @@ -108,16 +108,16 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule,
correctRule: null,
actualRule,
expectedRule: null,
email: newsletterEmail,
user: getUser(),
});

console.log(result);

expect(result).toBeDefined();
expect(result.rule).toBe("matched_rule");
expect(result.rule).toBe("actual_rule");
expect(result.fixedInstructions).toContain("collaboration");
// The fixed rule should exclude newsletters and automated updates
expect(result.fixedInstructions.toLowerCase()).toMatch(
Expand All @@ -144,8 +144,8 @@ describe.skipIf(!isAiTest)("aiRuleFix", () => {
});

const result = await aiRuleFix({
incorrectRule: null,
correctRule,
actualRule: null,
expectedRule: correctRule,
email: priceRequestEmail,
user: getUser(),
});
Expand Down
Loading