mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: resolve analytics data gaps and resize validation failures
- Fix resize 20% failure rate: add Zod refine requiring at least one dimension, enforce integer/max constraints, clamp percentage scaling to minimum 1px, and guard against missing metadata in withoutEnlargement - Fix PostHog init race condition: move consent check before async import so frontend events (search, pageview) are no longer silently dropped - Fix identify() passing nested $set/$set_once wrappers instead of flat properties, so version person property now appears on PostHog profiles - Add error_code and error_message to failed tool_used analytics events for debugging tool failures from PostHog
This commit is contained in:
@@ -229,13 +229,12 @@ describe("resize", () => {
|
||||
expect(meta.width).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it("percentage=1 on 1x1 yields width rounded to 0 and triggers error", async () => {
|
||||
// 1 * 1/100 = 0.01 -> Math.round -> 0
|
||||
// Then the check width <= 0 should throw
|
||||
it("percentage=1 on 1x1 clamps to 1px minimum", async () => {
|
||||
const img = sharp(png1x1);
|
||||
await expect(resize(img, { percentage: 1 })).rejects.toThrow(
|
||||
"Resize width must be greater than 0",
|
||||
);
|
||||
const result = await resize(img, { percentage: 1 });
|
||||
const meta = await result.toBuffer().then((b) => sharp(b).metadata());
|
||||
expect(meta.width).toBe(1);
|
||||
expect(meta.height).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user