Skip to content

Commit

Permalink
[REF] hr_holidays: convert tests to hoot
Browse files Browse the repository at this point in the history
This commit aims to convert QUnit tests which rely on mail/test_utils to hoot.

Part of task-3818666

closes odoo#171035

X-original-commit: 06d2cdc
Signed-off-by: Didier Debondt (did) <[email protected]>
  • Loading branch information
jayp-odoo committed Jun 27, 2024
1 parent 9a849ef commit c05d7b2
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 73 deletions.
10 changes: 5 additions & 5 deletions addons/hr_holidays/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
"web.assets_web_dark": [
'hr_holidays/static/src/**/*.dark.scss',
],
'web.tests_assets': [
'hr_holidays/static/tests/helpers/**/*',
'web.assets_unit_tests': [
'hr_holidays/static/tests/**/*',
('remove', 'hr_holidays/static/tests/tours/**/*'),
('remove', 'hr_holidays/static/tests/legacy/**/*'),
],
'web.qunit_suite_tests': [
'hr_holidays/static/tests/**/*.js',
('remove', 'hr_holidays/static/tests/tours/**/*'),
('remove', 'hr_holidays/static/tests/helpers/**/*'),
'hr_holidays/static/tests/legacy/**/*',
],
'web.assets_tests': [
'/hr_holidays/static/tests/tours/**/*'
Expand Down

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions addons/hr_holidays/static/tests/hr_holidays_test_helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { defineModels } from "@web/../tests/web_test_helpers";
import { ResPartner } from "./mock_server/mock_models/res_partner";
import { HrEmployee } from "./mock_server/mock_models/hr_employee";

export function defineHrHolidaysModels() {
return defineModels(hrHolidaysModels);
}

export const hrHolidaysModels = { ...mailModels, ResPartner, HrEmployee };
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/* @odoo-module */
import { describe, test } from "@odoo/hoot";
import { Command, serverState } from "@web/../tests/web_test_helpers";
import { startServer, start, openDiscuss, contains } from "@mail/../tests/mail_test_helpers";
import { defineHrHolidaysModels } from "@hr_holidays/../tests/hr_holidays_test_helpers";

import { serverState, startServer } from "@bus/../tests/helpers/mock_python_environment";
describe.current.tags("desktop");
defineHrHolidaysModels();

import { Command } from "@mail/../tests/helpers/command";
import { openDiscuss, start } from "@mail/../tests/helpers/test_utils";

import { contains } from "@web/../tests/utils";

QUnit.module("im_status");

QUnit.test("on leave & online", async () => {
test("on leave & online", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_online" });
const channelId = pyEnv["discuss.channel"].create({
Expand All @@ -24,7 +21,7 @@ QUnit.test("on leave & online", async () => {
await contains(".o-mail-ImStatus i.fa-plane[title='Online']");
});

QUnit.test("on leave & away", async () => {
test("on leave & away", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_away" });
const channelId = pyEnv["discuss.channel"].create({
Expand All @@ -39,7 +36,7 @@ QUnit.test("on leave & away", async () => {
await contains(".o-mail-ImStatus i.fa-plane[title='Idle']");
});

QUnit.test("on leave & offline", async () => {
test("on leave & offline", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "leave_offline" });
const channelId = pyEnv["discuss.channel"].create({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { models } from "@web/../tests/web_test_helpers";

export class HrEmployee extends models.ServerModel {
_name = "hr.employee";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { fields } from "@web/../tests/web_test_helpers";

export class ResPartner extends mailModels.ResPartner {
out_of_office_date_end = fields.Date();

/**
* Overrides to add out of office to employees.
* @override
* @type {typeof mailModels.ResPartner["prototype"]["mail_partner_format"]}
*/
mail_partner_format(ids) {
const partnerFormats = super.mail_partner_format(...arguments);
const partners = this._filter([["id", "in", ids]], {
active_test: false,
});
for (const partner of partners) {
// Not a real field but ease the testing
partnerFormats[partner.id].out_of_office_date_end = partner.out_of_office_date_end;
}
return partnerFormats;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/* @odoo-module */
import { describe, test } from "@odoo/hoot";
import { Command, serverState } from "@web/../tests/web_test_helpers";
import { startServer, start, openDiscuss, contains } from "@mail/../tests/mail_test_helpers";
import { defineHrHolidaysModels } from "@hr_holidays/../tests/hr_holidays_test_helpers";

import { serverState, startServer } from "@bus/../tests/helpers/mock_python_environment";
describe.current.tags("desktop");
defineHrHolidaysModels();

import { Command } from "@mail/../tests/helpers/command";
import { openDiscuss, start } from "@mail/../tests/helpers/test_utils";

import { contains } from "@web/../tests/utils";

QUnit.module("thread_icon");

QUnit.test("thread icon of a chat when correspondent is on leave & online", async () => {
test("thread icon of a chat when correspondent is on leave & online", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
im_status: "leave_online",
Expand All @@ -30,7 +27,7 @@ QUnit.test("thread icon of a chat when correspondent is on leave & online", asyn
});
});

QUnit.test("thread icon of a chat when correspondent is on leave & away", async () => {
test("thread icon of a chat when correspondent is on leave & away", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
im_status: "leave_away",
Expand All @@ -51,7 +48,7 @@ QUnit.test("thread icon of a chat when correspondent is on leave & away", async
});
});

QUnit.test("thread icon of a chat when correspondent is on leave & offline", async () => {
test("thread icon of a chat when correspondent is on leave & offline", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
im_status: "leave_offline",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
/* @odoo-module */
import { describe, test } from "@odoo/hoot";
import { Command, serverState } from "@web/../tests/web_test_helpers";
import { startServer, start, openDiscuss, contains } from "@mail/../tests/mail_test_helpers";
import { defineHrHolidaysModels } from "@hr_holidays/../tests/hr_holidays_test_helpers";

import { serverState, startServer } from "@bus/../tests/helpers/mock_python_environment";
describe.current.tags("desktop");
defineHrHolidaysModels();

import { Command } from "@mail/../tests/helpers/command";
import { openDiscuss, start } from "@mail/../tests/helpers/test_utils";

import { contains } from "@web/../tests/utils";

QUnit.module("thread");

QUnit.test("out of office message on direct chat with out of office partner", async () => {
test("out of office message on direct chat with out of office partner", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({
name: "Demo",
Expand Down

0 comments on commit c05d7b2

Please sign in to comment.