aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-07-08 15:55:48 +0200
committerFlorian Dold <florian@dold.me>2024-07-08 15:55:48 +0200
commita1a75c08f2329f87d1fb82333c0ea9e130b08f8d (patch)
tree822deb46513e8379955f1ce9b959ab9805823bee
parente0d682cd27402a5cc464779a621951528f32c3e9 (diff)
harness: fix categories test
-rw-r--r--packages/taler-harness/src/integrationtests/test-merchant-categories.ts24
1 files 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
index f4c985a08..87d94c583 100644
--- 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]);