Integrate market audit with shared calibration and catalog
This commit is contained in:
+39
-1
@@ -1,6 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
combineRects,
|
||||
isCalibrationReady,
|
||||
isRectInside,
|
||||
parseFieldValue,
|
||||
@@ -29,6 +30,16 @@ test("moves calibrated fields together with the detected anchor", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("combines the calibrated name and price rows into one OCR window", () => {
|
||||
assert.deepEqual(
|
||||
combineRects(
|
||||
{ x: 100, y: 40, width: 220, height: 18 },
|
||||
{ x: 120, y: 90, width: 160, height: 18 },
|
||||
),
|
||||
{ x: 100, y: 40, width: 220, height: 68 },
|
||||
);
|
||||
});
|
||||
|
||||
test("parses formatted prices and rejects empty numeric OCR", () => {
|
||||
assert.equal(parseFieldValue("price", "1 250,000 adena"), 1250000);
|
||||
assert.equal(parseFieldValue("quantity", "not found"), null);
|
||||
@@ -60,7 +71,7 @@ test("parses a hovered item tooltip", () => {
|
||||
parseTooltipText("Tears of Eva\nPrice : 3,000,000 Adena\n(3 Million Adena)"),
|
||||
{
|
||||
name: "Tears of Eva",
|
||||
quantity: null,
|
||||
quantity: 1,
|
||||
priceAdena: 3000000,
|
||||
rawText: "Tears of Eva\nPrice : 3,000,000 Adena\n(3 Million Adena)",
|
||||
},
|
||||
@@ -74,6 +85,33 @@ test("parses a hovered item tooltip", () => {
|
||||
assert.equal(parseTooltipText("Animal Skin (18)\n400")?.priceAdena, 400);
|
||||
assert.equal(parseTooltipText("Animal Skin (18)\nPrice : 400")?.priceAdena, 400);
|
||||
assert.equal(parseTooltipText("Blessed Spiritshot D (5,600)\nFor Each 56 Adena")?.quantity, 5600);
|
||||
assert.deepEqual(parseTooltipText("Sword of Valhalla\nPrice :\nFor Each 56 Adena"), {
|
||||
name: "Sword of Valhalla",
|
||||
quantity: 1,
|
||||
priceAdena: 56,
|
||||
rawText: "Sword of Valhalla\nPrice :\nFor Each 56 Adena",
|
||||
});
|
||||
assert.deepEqual(parseTooltipText("Animal Skin (18)\nWeight 0\nPrice :\nFor Each 400 Adena"), {
|
||||
name: "Animal Skin",
|
||||
quantity: 18,
|
||||
priceAdena: 400,
|
||||
rawText: "Animal Skin (18)\nWeight 0\nPrice :\nFor Each 400 Adena",
|
||||
});
|
||||
assert.deepEqual(
|
||||
parseTooltipText("Blessed Spiritshot: D-Grade (D) (5,600)\nFor Each 56 Adena"),
|
||||
{
|
||||
name: "Blessed Spiritshot: D-Grade (D)",
|
||||
quantity: 5600,
|
||||
priceAdena: 56,
|
||||
rawText: "Blessed Spiritshot: D-Grade (D) (5,600)\nFor Each 56 Adena",
|
||||
},
|
||||
);
|
||||
assert.deepEqual(parseTooltipText("Animal Skin (18),,.\nFor Each 400 Adena"), {
|
||||
name: "Animal Skin ,,.",
|
||||
quantity: 18,
|
||||
priceAdena: 400,
|
||||
rawText: "Animal Skin (18),,.\nFor Each 400 Adena",
|
||||
});
|
||||
assert.equal(parseTooltipText("Purchase List\nAdena 5,403,160"), null);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user