fix(amazon-shopping): enforce rating filters in chat output
This commit is contained in:
@@ -35,6 +35,22 @@ describe("parseNaturalLanguageRequest", () => {
|
||||
assert.equal(parsed.filters.minRating, 4);
|
||||
});
|
||||
|
||||
it("extracts rating filters without requiring the word of", () => {
|
||||
const parsed = parseNaturalLanguageRequest(
|
||||
"sofa bed, 77 inches or wider, over 50 reviews, rating 4.0 or better, Prime delivery only, sort by price low to high"
|
||||
);
|
||||
|
||||
assert.equal(parsed.query, "sofa bed");
|
||||
assert.equal(parsed.filters.minWidthInches, 77);
|
||||
assert.equal(parsed.filters.widthComparison, "gte");
|
||||
assert.equal(parsed.filters.minReviews, 50);
|
||||
assert.equal(parsed.filters.reviewCountComparison, "gt");
|
||||
assert.equal(parsed.filters.minRating, 4);
|
||||
assert.equal(parsed.filters.ratingComparison, "gte");
|
||||
assert.equal(parsed.filters.requirePrime, true);
|
||||
assert.equal(parsed.filters.sortBy, "price");
|
||||
});
|
||||
|
||||
it("extracts limit and max product price phrases", () => {
|
||||
const parsed = parseNaturalLanguageRequest("return 5 wireless mouse under $30");
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ describe("report", () => {
|
||||
assert.match(markdown, /https:\/\/www\.amazon\.com\/dp\/B0TEST0001/);
|
||||
});
|
||||
|
||||
it("creates a table template with constraint status markers", () => {
|
||||
it("creates a chat-safe template with direct product links and constraint status markers", () => {
|
||||
const markdown = createMarkdownReport(createResponse({
|
||||
query: "sofa bed beige",
|
||||
filters: {
|
||||
@@ -87,11 +87,13 @@ describe("report", () => {
|
||||
}));
|
||||
|
||||
assert.match(markdown, /## Best Matches/);
|
||||
assert.match(markdown, /\| # \| Product \| Price \| Rating \| Reviews \| Width \| Prime \| Delivery \| Link \|/);
|
||||
assert.doesNotMatch(markdown, /\| # \| Product \| Price \| Rating \| Reviews \| Width \| Prime \| Delivery \| Link \|/);
|
||||
assert.doesNotMatch(markdown, /\[Amazon\]\(https:\/\/www\.amazon\.com\/dp\/B0SOFABED1\)/);
|
||||
assert.match(markdown, /HONBAY Modular Sectional Sleeper/);
|
||||
assert.match(markdown, /Link: https:\/\/www\.amazon\.com\/dp\/B0SOFABED1/);
|
||||
assert.match(markdown, /83\.4" OK/);
|
||||
assert.match(markdown, /Prime OK/);
|
||||
assert.match(markdown, /Tomorrow OK/);
|
||||
assert.match(markdown, /\[Amazon\]\(https:\/\/www\.amazon\.com\/dp\/B0SOFABED1\)/);
|
||||
assert.match(markdown, /Price: \$539\.99/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user