commit a1a75c08f2329f87d1fb82333c0ea9e130b08f8d
parent e0d682cd27402a5cc464779a621951528f32c3e9
Author: Florian Dold <florian@dold.me>
Date: Mon, 8 Jul 2024 15:55:48 +0200
harness: fix categories test
Diffstat:
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-merchant-categories.ts b/packages/taler-harness/src/integrationtests/test-merchant-categories.ts
@@ -129,7 +129,6 @@ export async function runMerchantCategoriesTest(t: GlobalTestState) {
unit: "item",
price: "TESTKUDOS:2",
total_stock: -1,
- // FIXME: Don't hardcode
categories: [myNewCategoryId],
},
});
@@ -137,6 +136,21 @@ export async function runMerchantCategoriesTest(t: GlobalTestState) {
}
{
+ const url = new URL("private/products", merchant.makeInstanceBaseUrl());
+ const res = await harnessHttpLib.fetch(url.href, {
+ method: "POST",
+ body: {
+ product_id: "baz",
+ description: "Eggs",
+ unit: "item",
+ price: "TESTKUDOS:42",
+ total_stock: -1,
+ },
+ });
+ t.assertTrue(res.status >= 200 && res.status < 300);
+ }
+
+ {
const posUrl = new URL("private/pos", merchant.makeInstanceBaseUrl());
const res = await harnessHttpLib.fetch(posUrl.href, {
method: "GET",
@@ -145,14 +159,16 @@ export async function runMerchantCategoriesTest(t: GlobalTestState) {
console.log(j2s(posJson));
t.assertTrue(res.status >= 200 && res.status < 300);
- t.assertDeepEqual(posJson.products.length, 2);
+ t.assertDeepEqual(posJson.products.length, 3);
- const prodFoo = posJson.products.find((x: any) => (x.product_id = "foo"));
+ const prodFoo = posJson.products.find((x: any) => x.product_id == "foo");
+ console.log(`prod foo`, prodFoo);
t.assertTrue(!!prodFoo);
// Only default category
t.assertDeepEqual(prodFoo.categories, [0]);
- const prodBar = posJson.products.find((x: any) => (x.product_id = "bar"));
+ const prodBar = posJson.products.find((x: any) => x.product_id == "bar");
+ console.log(`prod bar`, prodBar);
t.assertTrue(!!prodBar);
// This should have the one we assigned to it.
t.assertDeepEqual(prodBar.categories, [myNewCategoryId]);