revamp app for more gainz
Android Release Build / build-android (push) Successful in 14m6s

This commit is contained in:
Frederik Spirgi
2026-11-18 11:55:53 +01:00
parent 7f380fef20
commit c995999823
27 changed files with 898 additions and 961 deletions
+30 -1
View File
@@ -132,7 +132,7 @@ test('stale product data refreshes online and remains usable offline', async ()
const refreshed = await lookupProductByBarcode(stale.barcode, { [stale.barcode]: stale });
assert.equal(requests, 1);
assert.equal(refreshed.product.name, 'New name');
assert.equal(refreshed.product.price, 3.5);
assert.equal(refreshed.product.price, undefined);
assert.equal(refreshed.product.sustainability.originCountry, 'Frankreich');
assert.equal(refreshed.product.sustainability.originSource, 'ingredient-origin');
assert.ok(Date.parse(refreshed.product.fetchedAt) > Date.parse(stale.fetchedAt));
@@ -155,6 +155,35 @@ test('stale product data refreshes online and remains usable offline', async ()
}
});
test('a recent cache entry from the old nutrition schema reloads carbohydrates', async () => {
const cached = off({ code: '3017620422003', product_name: 'Test', nutriments: { sugars_100g: 56.3 } });
delete cached.nutritionSchemaVersion;
cached.manualOverrides = { nutrition: { sugarPer100g: 40 } };
const originalFetch = globalThis.fetch;
let requests = 0;
try {
globalThis.fetch = async () => {
requests += 1;
return { ok: true, json: async () => ({ status: 1, product: {
code: cached.barcode, product_name: 'Test', nutriments: {
sugars_100g: 56.3, carbohydrates_100g: 57.5
}
} }) };
};
const refreshed = await lookupProductByBarcode(cached.barcode, { [cached.barcode]: cached });
assert.equal(requests, 1);
assert.equal(refreshed.product.nutrition.carbohydratesPer100g, 57.5);
assert.equal(refreshed.product.nutrition.sugarPer100g, 40);
assert.equal(refreshed.product.nutritionSchemaVersion, 2);
const offline = await lookupProductByBarcode(cached.barcode, { [cached.barcode]: cached }, true);
assert.equal(requests, 1);
assert.equal(offline.product.cacheStale, true);
} finally {
globalThis.fetch = originalFetch;
}
});
test('ADEME import failure cannot replace the last good local snapshot', async () => {
let wrote = false;
await assert.rejects(importAgribalyse({