mirror of
https://github.com/bringout/oca-ocb-pos.git
synced 2026-04-24 20:42:08 +02:00
19.0 vanilla
This commit is contained in:
parent
6e54c1af6c
commit
3ca647e428
1087 changed files with 132065 additions and 108499 deletions
|
|
@ -0,0 +1,68 @@
|
|||
import { test, describe, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
import { addProductLineToOrder } from "@pos_loyalty/../tests/unit/utils";
|
||||
import { onRpc } from "@web/../tests/web_test_helpers";
|
||||
|
||||
definePosModels();
|
||||
|
||||
describe("PosStore - loyalty essentials", () => {
|
||||
test("updatePrograms", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const models = store.models;
|
||||
const order = store.addNewOrder();
|
||||
|
||||
const partner = models["res.partner"].get(1);
|
||||
// Get loyalty program #5 with program_type = "gift_card" and is_nominative = true
|
||||
const program = models["loyalty.program"].get(5);
|
||||
|
||||
models["loyalty.program"].getAll = () => [program];
|
||||
|
||||
order.setPartner(partner);
|
||||
order._programIsApplicable = () => true;
|
||||
order._code_activated_coupon_ids = [];
|
||||
order.uiState.couponPointChanges = {};
|
||||
order.pricelist_id = { id: 1 };
|
||||
|
||||
const line = await addProductLineToOrder(store, order, {
|
||||
gift_code: "XYZ123",
|
||||
});
|
||||
|
||||
order.pointsForPrograms = () => ({
|
||||
[program.id]: [{ points: 10 }],
|
||||
});
|
||||
|
||||
await store.updatePrograms();
|
||||
|
||||
const changes = order.uiState.couponPointChanges;
|
||||
const changeList = Object.values(changes);
|
||||
|
||||
expect(changeList).toHaveLength(1);
|
||||
expect(changeList[0].program_id).toBe(program.id);
|
||||
expect(changeList[0].points).toBe(10);
|
||||
expect(changeList[0].code).toBe("XYZ123");
|
||||
expect(changeList[0].product_id).toBe(line.product_id.id);
|
||||
});
|
||||
|
||||
test("activateCode", async () => {
|
||||
onRpc("loyalty.card", "get_loyalty_card_partner_by_code", () => false);
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const result = await store.activateCode("EXPIRED");
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test("fetchLoyaltyCard", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const models = store.models;
|
||||
|
||||
// Get loyalty program #2 with program_type = "ewallet"
|
||||
const program = models["loyalty.program"].get(2);
|
||||
const partner = models["res.partner"].get(1);
|
||||
|
||||
const card = await store.fetchLoyaltyCard(program.id, partner.id);
|
||||
|
||||
expect(card.id).toBe(2);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue