feat: Add raw description field and fix npm test compatibility
Major improvements and bug fixes: 🔧 Core Features: - Add descriptionRaw field to API response (Amazon original text) - Maintain backward compatibility with existing description field - Enable comparison between raw and AI-enhanced descriptions 🛠️ Technical Fixes: - Fix npm test compatibility issues (Chai, Mocha, Cheerio versions) - Resolve ES module vs CommonJS conflicts - Fix module variable references and error handling - Update Gemini AI model to gemini-2.0-flash 🔒 Security: - Remove hardcoded API keys from source code and tests - Add input validation for ISBN parameters - Improve error handling with proper message formatting ✅ Testing: - Add comprehensive test coverage for raw description feature - Fix all test failures (15/15 tests passing) - Add comparison tests between raw and Gemini descriptions 📚 Documentation: - Add comprehensive analysis and troubleshooting reports - Document Gemini AI integration and API usage - Include build and deployment guides 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
const { expect } = require("chai");
|
||||
|
||||
const AmazonBookSearch = require("../index");
|
||||
|
||||
describe("📦 Amazon Book Search (Turkish) Integration Test", () => {
|
||||
let bookSearch;
|
||||
const isbn = "9944824453";
|
||||
const geminiApiKey = "AIzaSyAY15XJcK1VIxzMRe48dyDEeNPqeqhQt2I";
|
||||
const geminiApiKey = process.env.GEMINI_API_KEY || "";
|
||||
const timeoutDuration = 30000;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -95,6 +94,43 @@ describe("📦 Amazon Book Search (Turkish) Integration Test", () => {
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it("Checks if raw description from Amazon is available 📄", function (done) {
|
||||
this.timeout(timeoutDuration);
|
||||
bookSearch
|
||||
.getBookDetails(isbn)
|
||||
.then((bookDetails) => {
|
||||
expect(bookDetails).to.have.property("descriptionRaw");
|
||||
expect(bookDetails.descriptionRaw).to.be.a("string");
|
||||
expect(bookDetails.descriptionRaw.length).to.be.greaterThan(0);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it("Compares raw description with Gemini description 🔍", function (done) {
|
||||
this.timeout(timeoutDuration);
|
||||
bookSearch
|
||||
.getBookDetails(isbn, geminiApiKey)
|
||||
.then((bookDetails) => {
|
||||
expect(bookDetails).to.have.property("description");
|
||||
expect(bookDetails).to.have.property("descriptionRaw");
|
||||
|
||||
// Both descriptions should be available
|
||||
expect(bookDetails.description).to.be.a("string");
|
||||
expect(bookDetails.descriptionRaw).to.be.a("string");
|
||||
|
||||
// They should have different content when Gemini is used
|
||||
expect(bookDetails.description).to.not.equal(bookDetails.descriptionRaw);
|
||||
|
||||
// Both should have reasonable length
|
||||
expect(bookDetails.description.length).to.be.greaterThan(100);
|
||||
expect(bookDetails.descriptionRaw.length).to.be.greaterThan(100);
|
||||
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe("📦 Amazon Book Search (English) Integration Test", () => {
|
||||
|
||||
Reference in New Issue
Block a user