初始提交
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { click } from "@odoo/hoot-dom";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import { mountWithCleanup, defineModels } from "@web/../tests/web_test_helpers";
|
||||
import { mailModels } from "@mail/../tests/mail_test_helpers";
|
||||
|
||||
import { BankRecButton } from "@account_accountant/components/bank_reconciliation/button/button";
|
||||
|
||||
// Due to dependency with mail module, we have to define their models for our tests.
|
||||
defineModels(mailModels);
|
||||
|
||||
describe.current.tags("desktop");
|
||||
|
||||
test("can display a button", async () => {
|
||||
await mountWithCleanup(BankRecButton, {
|
||||
props: {
|
||||
label: "A label",
|
||||
action: () => {},
|
||||
count: null,
|
||||
primary: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(".btn.btn-secondary").toHaveText("A label");
|
||||
});
|
||||
|
||||
test("can display a button with a count", async () => {
|
||||
await mountWithCleanup(BankRecButton, {
|
||||
props: {
|
||||
label: "Another label",
|
||||
action: () => {},
|
||||
count: 10,
|
||||
primary: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(".btn span:first").toHaveText("Another label");
|
||||
expect(".btn span:last").toHaveText("10");
|
||||
});
|
||||
|
||||
test("can display a button with primary class", async () => {
|
||||
await mountWithCleanup(BankRecButton, {
|
||||
props: {
|
||||
label: "A label with primary class",
|
||||
action: () => {},
|
||||
count: null,
|
||||
primary: true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(".btn.btn-primary").toHaveText("A label with primary class");
|
||||
});
|
||||
|
||||
test("can call function when button is clicked", async () => {
|
||||
let counter = 0;
|
||||
|
||||
await mountWithCleanup(BankRecButton, {
|
||||
props: {
|
||||
label: "A button with an action",
|
||||
action: () => counter++,
|
||||
count: null,
|
||||
primary: false,
|
||||
},
|
||||
});
|
||||
|
||||
await click(".btn");
|
||||
await animationFrame();
|
||||
expect(counter).toBe(1);
|
||||
});
|
||||
@@ -0,0 +1,289 @@
|
||||
import { mailModels } from "@mail/../tests/mail_test_helpers";
|
||||
import { beforeEach, describe, expect, test } from "@odoo/hoot";
|
||||
import { click, queryAll, queryAllTexts, queryOne } from "@odoo/hoot-dom";
|
||||
import { animationFrame, mockDate } from "@odoo/hoot-mock";
|
||||
import {
|
||||
contains,
|
||||
defineModels,
|
||||
fields,
|
||||
getService,
|
||||
models,
|
||||
mountWithCleanup,
|
||||
} from "@web/../tests/web_test_helpers";
|
||||
import { WebClient } from "@web/webclient/webclient";
|
||||
|
||||
import { BankRecSelectCreateDialog } from "@account_accountant/components/bank_reconciliation/search_dialog/search_dialog";
|
||||
|
||||
class AccountMoveLine extends models.Model {
|
||||
name = fields.Char({ string: "Name" });
|
||||
date = fields.Date({ string: "Date" });
|
||||
partner_id = fields.Many2one({ string: "Partner", relation: "partner" });
|
||||
amount_residual = fields.Float({ string: "Amount Residual" });
|
||||
|
||||
amount_residual_currency = fields.Float({ string: "Amount Residual Currency" });
|
||||
|
||||
currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
|
||||
|
||||
company_currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
|
||||
|
||||
_records = [
|
||||
{
|
||||
id: 1,
|
||||
name: "INV/2025/0001",
|
||||
date: "2025-01-11",
|
||||
partner_id: 1,
|
||||
amount_residual: -230,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "INV/2025/0002",
|
||||
date: "2025-01-12",
|
||||
partner_id: 1,
|
||||
amount_residual: -150,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "INV/2025/0003",
|
||||
date: "2025-01-13",
|
||||
partner_id: 1,
|
||||
amount_residual: -50,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "INV/2025/0004",
|
||||
date: "2025-01-14",
|
||||
partner_id: 2,
|
||||
amount_residual: -100,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "INV/2025/0005",
|
||||
date: "2025-01-15",
|
||||
partner_id: 3,
|
||||
amount_residual: -125,
|
||||
currency_id: 1,
|
||||
},
|
||||
];
|
||||
|
||||
_views = {
|
||||
list: /* xml */ `
|
||||
<list js_class="bank_rec_dialog_list" string="Journal Items">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="amount_residual"/>
|
||||
<field name="amount_residual_currency"/>
|
||||
<field name="currency_id"/>
|
||||
</list>
|
||||
`,
|
||||
search: /* xml */ `
|
||||
<search>
|
||||
<field name="partner_id"/>
|
||||
</search>
|
||||
`,
|
||||
kanban: /* xml */ `
|
||||
<kanban>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<templates>
|
||||
<t t-name="card"/>
|
||||
</templates>
|
||||
</kanban>
|
||||
`,
|
||||
form: /* xml */ `
|
||||
<form/>
|
||||
`,
|
||||
};
|
||||
}
|
||||
|
||||
class Partner extends models.Model {
|
||||
name = fields.Char({ string: "Name" });
|
||||
|
||||
_records = [
|
||||
{ id: 1, name: "Jean Pierre" },
|
||||
{ id: 2, name: "Pierre Jean" },
|
||||
{ id: 3, name: "JB Pokie" },
|
||||
];
|
||||
}
|
||||
|
||||
// Due to dependency with mail module, we have to define their models for our tests.
|
||||
defineModels({ ...mailModels, AccountMoveLine, Partner });
|
||||
|
||||
beforeEach(() => {
|
||||
mockDate("2025-04-22 00:00:00");
|
||||
});
|
||||
|
||||
describe.current.tags("desktop");
|
||||
|
||||
test("BankRecSelectCreateDialog footer with right information", async () => {
|
||||
await mountWithCleanup(WebClient);
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 233.33,
|
||||
currency_id: { id: 1 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
date: luxon.DateTime.now(),
|
||||
reference: "A cool reference to display",
|
||||
context: { search_default_partner_id: 1 },
|
||||
domain: [],
|
||||
});
|
||||
await animationFrame();
|
||||
|
||||
const bankReconciliationInfoNode = queryOne("div[name='bank_reconciliation_info']").children;
|
||||
const bankReconciliationInfo = queryAllTexts(bankReconciliationInfoNode);
|
||||
expect(bankReconciliationInfo[0]).toBe("Apr 22");
|
||||
expect(bankReconciliationInfo[1]).toBe("A cool reference to display");
|
||||
expect(bankReconciliationInfo[2]).toBe("Balance: $ 233.33");
|
||||
});
|
||||
|
||||
test("BankRecSelectCreateDialog list view single currency", async () => {
|
||||
await mountWithCleanup(WebClient);
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 100,
|
||||
currency_id: { id: 1 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
reference: "A useless reference",
|
||||
date: luxon.DateTime.now(),
|
||||
context: { search_default_partner_id: 1 },
|
||||
domain: [],
|
||||
});
|
||||
await animationFrame();
|
||||
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
|
||||
expect("div.o_facet_values > small.o_facet_value").toHaveText("Jean Pierre");
|
||||
// Check that we have 4 checkboxes (Select all + 3 elements)
|
||||
let checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
|
||||
expect(checkboxes.length).toBe(4);
|
||||
// Select an element already fetch
|
||||
await click(checkboxes[2]);
|
||||
await animationFrame();
|
||||
// Unselect this element
|
||||
await click(checkboxes[2]);
|
||||
await animationFrame();
|
||||
|
||||
await click("div.o_facet_values > button.o_facet_remove");
|
||||
await animationFrame();
|
||||
// Check that we have 6 checkboxes (Select all + 5 elements)
|
||||
checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
|
||||
expect(checkboxes.length).toBe(6);
|
||||
|
||||
await click(checkboxes[4]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
// Check that the balance is correctly affected by the selection
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 0.00");
|
||||
|
||||
await click(checkboxes[4]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
|
||||
|
||||
await click(".o_pager_value");
|
||||
await animationFrame();
|
||||
expect(".o_pager_counter .o_pager_value").toHaveValue("1-5");
|
||||
|
||||
await contains("input.o_pager_value").edit("1-2");
|
||||
await click(document.body);
|
||||
await animationFrame();
|
||||
|
||||
checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
|
||||
expect(checkboxes.length).toBe(3);
|
||||
await click(checkboxes[0]);
|
||||
await animationFrame();
|
||||
|
||||
await contains(`.o_select_domain`).click();
|
||||
await animationFrame();
|
||||
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ -555.00");
|
||||
});
|
||||
|
||||
test("BankRecSelectCreateDialog list view multi currencies", async () => {
|
||||
AccountMoveLine._records.push({
|
||||
id: 6,
|
||||
name: "INV/2025/0006",
|
||||
date: "2025-01-15",
|
||||
partner_id: 3,
|
||||
amount_residual: -100,
|
||||
amount_residual_currency: -200,
|
||||
currency_id: 2,
|
||||
});
|
||||
AccountMoveLine._records.push({
|
||||
id: 7,
|
||||
name: "INV/2025/0007",
|
||||
date: "2025-01-15",
|
||||
partner_id: 3,
|
||||
amount_residual: -100,
|
||||
amount_residual_currency: -150,
|
||||
currency_id: 2,
|
||||
});
|
||||
AccountMoveLine._records.push({
|
||||
id: 8,
|
||||
name: "INV/2025/0008",
|
||||
date: "2025-01-15",
|
||||
partner_id: 3,
|
||||
amount_residual: -100,
|
||||
amount_residual_currency: -100,
|
||||
currency_id: 1,
|
||||
});
|
||||
await mountWithCleanup(WebClient);
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 100,
|
||||
currency_id: { id: 2 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
reference: "A useless reference",
|
||||
date: luxon.DateTime.now(),
|
||||
context: { search_default_partner_id: 3 },
|
||||
domain: [],
|
||||
});
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
|
||||
|
||||
const checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
|
||||
expect(checkboxes.length).toBe(5);
|
||||
|
||||
await click(checkboxes[2]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: -100.00 €");
|
||||
|
||||
await click(checkboxes[3]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: -250.00 €");
|
||||
|
||||
await click(checkboxes[2]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: -50.00 €");
|
||||
|
||||
await click(checkboxes[3]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
|
||||
|
||||
// Different currencies cannot be computed together
|
||||
await click(checkboxes[4]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: /");
|
||||
|
||||
await click(checkboxes[4]);
|
||||
await animationFrame();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
|
||||
});
|
||||
@@ -0,0 +1,258 @@
|
||||
import { mailModels } from "@mail/../tests/mail_test_helpers";
|
||||
import { beforeEach, describe, expect, test } from "@odoo/hoot";
|
||||
import { click, keyDown, queryAll, queryAllTexts, queryOne } from "@odoo/hoot-dom";
|
||||
import { animationFrame, mockDate } from "@odoo/hoot-mock";
|
||||
import {
|
||||
contains,
|
||||
defineModels,
|
||||
fields,
|
||||
getService,
|
||||
models,
|
||||
mountWithCleanup,
|
||||
} from "@web/../tests/web_test_helpers";
|
||||
import { WebClient } from "@web/webclient/webclient";
|
||||
|
||||
import { BankRecSelectCreateDialog } from "@account_accountant/components/bank_reconciliation/search_dialog/search_dialog";
|
||||
|
||||
class AccountMoveLine extends models.Model {
|
||||
move_name = fields.Char({ string: "Move Name" });
|
||||
ref = fields.Char({ string: "Ref" });
|
||||
date = fields.Date({ string: "Date" });
|
||||
partner_id = fields.Many2one({ string: "Partner", relation: "partner" });
|
||||
amount_residual = fields.Float({ string: "Amount Residual" });
|
||||
amount_residual_currency = fields.Float({ string: "Amount Residual Currency" });
|
||||
currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
|
||||
company_currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
|
||||
|
||||
_records = [
|
||||
{
|
||||
id: 1,
|
||||
move_name: "INV/2025/0001",
|
||||
ref: "Customer Reference invoice 1",
|
||||
date: "2025-01-11",
|
||||
partner_id: 1,
|
||||
amount_residual: -230,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
move_name: "INV/2025/0002",
|
||||
ref: "Customer Reference invoice 2",
|
||||
date: "2025-01-12",
|
||||
partner_id: 1,
|
||||
amount_residual: -150,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
move_name: "INV/2025/0003",
|
||||
ref: "Customer Reference invoice 3",
|
||||
date: "2025-01-13",
|
||||
partner_id: 1,
|
||||
amount_residual: -50,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
move_name: "INV/2025/0004",
|
||||
ref: "Customer Reference invoice 4",
|
||||
date: "2025-01-14",
|
||||
partner_id: 2,
|
||||
amount_residual: -100,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
move_name: "INV/2025/0005",
|
||||
ref: "Customer Reference invoice 5",
|
||||
date: "2025-01-15",
|
||||
partner_id: 2,
|
||||
amount_residual: 100,
|
||||
currency_id: 1,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
move_name: "INV/2025/0006",
|
||||
ref: "Customer Reference invoice 6",
|
||||
date: "2025-01-15",
|
||||
partner_id: 3,
|
||||
amount_residual: -125,
|
||||
currency_id: 1,
|
||||
},
|
||||
];
|
||||
|
||||
_views = {
|
||||
kanban: /* xml */ `
|
||||
<kanban js_class="bank_rec_dialog_kanban">
|
||||
<field name="currency_id"/>
|
||||
<field name="company_currency_id"/>
|
||||
<templates>
|
||||
<t t-name="card">
|
||||
<field name="move_name"/>
|
||||
<field name="ref"/>
|
||||
<field name="date"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="amount_residual"/>
|
||||
<field name="amount_residual_currency"/>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
`,
|
||||
search: /* xml */ `
|
||||
<search>
|
||||
<field name="partner_id"/>
|
||||
</search>
|
||||
`,
|
||||
};
|
||||
}
|
||||
|
||||
class Partner extends models.Model {
|
||||
name = fields.Char({ string: "Name" });
|
||||
|
||||
_records = [
|
||||
{ id: 1, name: "Jean Pierre" },
|
||||
{ id: 2, name: "Pierre Jean" },
|
||||
{ id: 3, name: "JB Pokie" },
|
||||
];
|
||||
}
|
||||
|
||||
defineModels({ ...mailModels, AccountMoveLine, Partner });
|
||||
|
||||
beforeEach(() => {
|
||||
mockDate("2025-04-22 00:00:00");
|
||||
});
|
||||
|
||||
describe.current.tags("mobile");
|
||||
|
||||
test("BankRecSelectCreateDialog header with right information", async () => {
|
||||
await mountWithCleanup(WebClient);
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 233.33,
|
||||
currency_id: { id: 1 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
date: luxon.DateTime.now(),
|
||||
reference: "A cool reference to display",
|
||||
context: {},
|
||||
domain: [],
|
||||
});
|
||||
await animationFrame();
|
||||
|
||||
const bankReconciliationInfoNode = queryOne("div[name='bank_reconciliation_info']").children;
|
||||
const bankReconciliationInfo = queryAllTexts(bankReconciliationInfoNode);
|
||||
expect(bankReconciliationInfo[0]).toBe("Apr 22");
|
||||
expect(bankReconciliationInfo[1]).toBe("A cool reference to display");
|
||||
expect(bankReconciliationInfo[2]).toBe("Balance: $ 233.33");
|
||||
});
|
||||
|
||||
test("BankRecSelectCreateDialog kanban view single currency", async () => {
|
||||
await mountWithCleanup(WebClient);
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 100,
|
||||
currency_id: { id: 1 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
reference: "A useless reference",
|
||||
date: luxon.DateTime.now(),
|
||||
context: { search_default_partner_id: 1 },
|
||||
domain: [],
|
||||
});
|
||||
await animationFrame();
|
||||
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
|
||||
await click("div.o_control_panel_navigation > button > i[data-icon='search']");
|
||||
await animationFrame();
|
||||
expect("div.o_facet_values > small.o_facet_value").toHaveText("Jean Pierre");
|
||||
let articles = queryAll("article.o_kanban_record");
|
||||
expect(articles.length).toBe(3);
|
||||
|
||||
await click("button.o_facet_remove");
|
||||
await animationFrame();
|
||||
articles = queryAll("article.o_kanban_record");
|
||||
expect(articles.length).toBe(6);
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[3]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 0.00");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[3]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[4]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 200.00");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[4]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[0]).click();
|
||||
await animationFrame();
|
||||
await contains(`.o_select_domain`).click();
|
||||
await animationFrame();
|
||||
expect("div.o_selection_box").toHaveText("All 6 selected");
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: $ -455.00");
|
||||
});
|
||||
|
||||
test("BankRecSelectCreateDialog kanban view multiple currencies", async () => {
|
||||
AccountMoveLine._records.push({
|
||||
id: 7,
|
||||
move_name: "INV/2025/0007",
|
||||
ref: "Customer Reference invoice 7",
|
||||
date: "2025-01-17",
|
||||
partner_id: 3,
|
||||
amount_residual: -100,
|
||||
amount_residual_currency: -200,
|
||||
currency_id: 2,
|
||||
company_currency_id: 1,
|
||||
});
|
||||
|
||||
await mountWithCleanup(WebClient);
|
||||
|
||||
getService("dialog").add(BankRecSelectCreateDialog, {
|
||||
noCreate: true,
|
||||
resModel: "account.move.line",
|
||||
suspenseAccountLine: {
|
||||
amount_currency: 100,
|
||||
currency_id: { id: 2 },
|
||||
company_currency_id: { id: 1 },
|
||||
},
|
||||
reference: "A useless reference",
|
||||
date: luxon.DateTime.now(),
|
||||
context: {},
|
||||
domain: [],
|
||||
});
|
||||
|
||||
await animationFrame();
|
||||
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
|
||||
const articles = queryAll("article.o_kanban_record");
|
||||
expect(articles.length).toBe(7);
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[6]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: -100.00 €");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[6]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
|
||||
|
||||
await keyDown("Alt");
|
||||
await contains(articles[3]).click();
|
||||
await animationFrame();
|
||||
expect("div[name='remaining_amount']").toHaveText("Balance: /");
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { click, queryOne } from "@odoo/hoot-dom";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import { mountWithCleanup, defineModels } from "@web/../tests/web_test_helpers";
|
||||
import { mailModels } from "@mail/../tests/mail_test_helpers";
|
||||
|
||||
import { BankRecStatementSummary } from "@account_accountant/components/bank_reconciliation/statement_summary/statement_summary";
|
||||
|
||||
// Due to dependency with mail module, we have to define their models for our tests.
|
||||
defineModels(mailModels);
|
||||
|
||||
describe.current.tags("desktop");
|
||||
|
||||
test("can display a BankRecStatementSummary", async () => {
|
||||
let counter = 0;
|
||||
await mountWithCleanup(BankRecStatementSummary, {
|
||||
props: {
|
||||
label: "A label",
|
||||
action: () => {
|
||||
counter++;
|
||||
},
|
||||
amount: "$1,000.00",
|
||||
},
|
||||
});
|
||||
const elements = queryOne("div.o_statement_summary").children;
|
||||
await click(elements[1]);
|
||||
await animationFrame();
|
||||
expect(counter).toBe(1);
|
||||
expect(elements[0]).toHaveText("A label");
|
||||
expect(elements[1]).toHaveText("$1,000.00");
|
||||
});
|
||||
|
||||
test("no amount displayed if no amount in props", async () => {
|
||||
await mountWithCleanup(BankRecStatementSummary, {
|
||||
props: {
|
||||
label: "A label",
|
||||
action: () => {},
|
||||
},
|
||||
});
|
||||
const elements = queryOne("div.o_statement_summary").children;
|
||||
expect(elements).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("label in text danger when isValid set to False", async () => {
|
||||
await mountWithCleanup(BankRecStatementSummary, {
|
||||
props: {
|
||||
label: "A label",
|
||||
isValid: false,
|
||||
action: () => {},
|
||||
amount: "$1,000.00",
|
||||
},
|
||||
});
|
||||
expect("div.o_statement_summary > div > h4").toHaveClass("text-danger");
|
||||
});
|
||||
Reference in New Issue
Block a user