19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:39 +01:00
parent 38c6088dcc
commit d9452d2060
243 changed files with 30797 additions and 10815 deletions

View file

@ -1,5 +0,0 @@
/** @odoo-module **/
import { addModelNamesToFetch } from '@bus/../tests/helpers/model_definitions_helpers';
addModelNamesToFetch(['mail.test.rating']);

View file

@ -0,0 +1,61 @@
import { click, contains, start, startServer } from "@mail/../tests/mail_test_helpers";
import { test } from "@odoo/hoot";
import { defineTestMailFullModels } from "@test_mail_full/../tests/test_mail_full_test_helpers";
import { serverState } from "@web/../tests/web_test_helpers";
defineTestMailFullModels();
test("rating value displayed on the preview", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({});
const channelId = pyEnv["discuss.channel"].create({});
const messageId = pyEnv["mail.message"].create({
author_id: partnerId,
body: "non-empty",
model: "discuss.channel",
res_id: channelId,
});
pyEnv["rating.rating"].create({
consumed: true,
message_id: messageId,
partner_id: partnerId,
rating_image_url: "/rating/static/src/img/rating_5.png",
rating_text: "top",
});
await start();
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-NotificationItem-text", { text: "Rating:" });
await contains(".o-rating-preview-image[alt='top']");
await contains(".o-rating-preview-image[data-src='/rating/static/src/img/rating_5.png']");
});
test("rating value displayed on the needaction preview", async () => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({});
const ratingId = pyEnv["mail.test.rating"].create({ name: "Test rating" });
const messageId = pyEnv["mail.message"].create({
model: "mail.test.rating",
needaction: true,
res_id: ratingId,
});
pyEnv["mail.notification"].create({
mail_message_id: messageId,
notification_status: "sent",
notification_type: "inbox",
res_partner_id: serverState.partnerId,
});
pyEnv["rating.rating"].create([
{
consumed: true,
message_id: messageId,
partner_id: partnerId,
rating_image_url: "/rating/static/src/img/rating_5.png",
rating_text: "top",
},
]);
await start();
await click(".o_menu_systray i[aria-label='Messages']");
await contains(".o-mail-NotificationItem-text", { text: "Rating:" });
await contains(".o-rating-preview-image[alt='top']");
await contains(".o-rating-preview-image[data-src='/rating/static/src/img/rating_5.png']");
});

View file

@ -0,0 +1,5 @@
import { models } from "@web/../tests/web_test_helpers";
export class MailTestRating extends models.ServerModel {
_name = "mail.test.rating";
}

View file

@ -1,55 +0,0 @@
/** @odoo-module **/
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('test_mail_full', {}, function () {
QUnit.module('channel_preview_view_tests.js');
QUnit.test('rating value displayed on the thread preview', async function (assert) {
assert.expect(4);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({});
const mailChannelId1 = pyEnv['mail.channel'].create({});
const mailMessageId1 = pyEnv['mail.message'].create([
{ author_id: resPartnerId1, model: 'mail.channel', res_id: mailChannelId1 },
]);
pyEnv['rating.rating'].create({
consumed: true,
message_id: mailMessageId1,
partner_id: resPartnerId1,
rating_image_url: "/rating/static/src/img/rating_5.png",
rating_text: "top",
});
const { afterEvent, messaging } = await start();
await afterNextRender(() => afterEvent({
eventName: 'o-thread-cache-loaded-messages',
func: () => document.querySelector('.o_MessagingMenu_toggler').click(),
message: "should wait until inbox loaded initial needaction messages",
predicate: ({ threadCache }) => {
return threadCache.thread === messaging.inbox.thread;
},
}));
assert.strictEqual(
document.querySelector('.o_ChannelPreviewView_ratingText').textContent,
"Rating:",
"should display the correct content (Rating:)"
);
assert.containsOnce(
document.body,
'.o_ChannelPreviewView_ratingImage',
"should have a rating image in the body"
);
assert.strictEqual(
$('.o_ChannelPreviewView_ratingImage').attr('data-src'),
"/rating/static/src/img/rating_5.png",
"should contain the correct rating image"
);
assert.strictEqual(
$('.o_ChannelPreviewView_ratingImage').attr('data-alt'),
"top",
"should contain the correct rating text"
);
});
});

View file

@ -1,64 +0,0 @@
/** @odoo-module **/
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('test_mail_full', {}, function () {
QUnit.module('thread_needaction_preview_tests.js');
QUnit.test('rating value displayed on the thread needaction preview', async function (assert) {
assert.expect(4);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({});
const mailTestRating1 = pyEnv['mail.test.rating'].create({});
const mailMessageId1 = pyEnv['mail.message'].create({
model: 'mail.test.rating',
needaction: true,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: mailTestRating1,
});
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
});
pyEnv['rating.rating'].create([{
consumed: true,
message_id: mailMessageId1,
partner_id: resPartnerId1,
rating_image_url: "/rating/static/src/img/rating_5.png",
rating_text: "top",
}]);
const { afterEvent, messaging } = await start();
await afterNextRender(() => afterEvent({
eventName: 'o-thread-cache-loaded-messages',
func: () => document.querySelector('.o_MessagingMenu_toggler').click(),
message: "should wait until inbox loaded initial needaction messages",
predicate: ({ threadCache }) => {
return threadCache.thread === messaging.inbox.thread;
},
}));
assert.strictEqual(
document.querySelector('.o_ThreadNeedactionPreview_ratingText').textContent,
"Rating:",
"should display the correct content (Rating:)"
);
assert.containsOnce(
document.body,
'.o_ThreadNeedactionPreview_ratingImage',
"should have a rating image in the body"
);
assert.strictEqual(
$('.o_ThreadNeedactionPreview_ratingImage').attr('data-src'),
"/rating/static/src/img/rating_5.png",
"should contain the correct rating image"
);
assert.strictEqual(
$('.o_ThreadNeedactionPreview_ratingImage').attr('data-alt'),
"top",
"should contain the correct rating text"
);
});
});

View file

@ -0,0 +1,9 @@
import { ratingModels } from "@rating/../tests/rating_test_helpers";
import { MailTestRating } from "@test_mail_full/../tests/mock_server/models/mail_test_rating";
import { defineModels } from "@web/../tests/web_test_helpers";
export const testMailFullModels = { ...ratingModels, MailTestRating };
export function defineTestMailFullModels() {
defineModels(testMailFullModels);
}

View file

@ -0,0 +1,19 @@
import { registry } from "@web/core/registry";
import { contains } from "@web/../tests/utils";
registry.category("web_tour.tours").add("load_more_tour", {
steps: () => [
{
trigger: "#chatterRoot:shadow .o-mail-Thread .o-mail-Message",
run: async function () {
await contains(".o-mail-Thread .o-mail-Message", {
count: 30,
target: document.querySelector("#chatterRoot").shadowRoot,
});
},
},
{
trigger: "#chatterRoot:shadow .o-mail-Thread button:contains(Load More):not(:visible)",
},
],
});

View file

@ -0,0 +1,87 @@
import { registry } from "@web/core/registry";
import { contains } from "@web/../tests/utils";
registry.category("web_tour.tours").add("star_message_tour", {
steps: () => [
{
trigger:
"#chatterRoot:shadow .o-mail-Message:not([data-starred]):contains(Test Message)",
run: "hover && click #chatterRoot:shadow [title='Add Star']",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message[data-starred]:contains(Test Message)",
},
],
});
registry.category("web_tour.tours").add("message_actions_tour", {
steps: () => [
{
trigger: "#chatterRoot:shadow .o-mail-Thread .o-mail-Message",
run: async function () {
await contains(".o-mail-Thread .o-mail-Message", {
count: 1,
target: document.querySelector("#chatterRoot").shadowRoot,
});
},
},
{
trigger: "#chatterRoot:shadow .o-mail-Composer-input",
run: "edit New message",
},
{
trigger: "#chatterRoot:shadow .o-mail-Composer button:contains(Send):enabled",
run: "click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Thread .o-mail-Message",
run: async function () {
await contains(".o-mail-Thread .o-mail-Message", {
count: 2,
target: document.querySelector("#chatterRoot").shadowRoot,
});
},
},
{
trigger: "#chatterRoot:shadow .o-mail-Message[data-persistent]:contains(New message)",
run: "hover && click #chatterRoot:shadow button[title='Add a Reaction']",
},
{
trigger: "#chatterRoot:shadow .o-mail-QuickReactionMenu-emoji span:contains(❤️)",
run: "click",
},
{
trigger:
"#chatterRoot:shadow .o-mail-Message:contains(New message) .o-mail-MessageReaction:contains(❤️)",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message:contains(New message)",
run: "hover && click #chatterRoot:shadow button[title='Edit']",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message .o-mail-Composer-input",
run: "edit Message content changed",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message button:contains(save)",
run: "click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message:contains(Message content changed)",
run: "hover && click #chatterRoot:shadow button[title='Delete']",
},
{
trigger: "#chatterRoot:shadow button:contains(Delete)",
run: "click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Thread .o-mail-Message",
run: async function () {
await contains(".o-mail-Thread .o-mail-Message", {
count: 1,
target: document.querySelector("#chatterRoot").shadowRoot,
});
},
},
],
});

View file

@ -0,0 +1,34 @@
import { registry } from "@web/core/registry";
const cannedResponseButtonSelector = "button[title='Insert a Canned response']";
registry.category("web_tour.tours").add("portal_composer_actions_tour_internal_user", {
steps: () => [
{
trigger: `#chatterRoot:shadow .o-mail-Composer ${cannedResponseButtonSelector}`,
run: "click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Composer-input",
run() {
if (this.anchor.value !== "::") {
console.error(
"Clicking on the canned response button should insert the '::' into the composer."
);
}
},
},
{
trigger:
"#chatterRoot:shadow .o-mail-Composer-suggestion:contains(Hello, how may I help you?)",
},
],
});
registry.category("web_tour.tours").add("portal_composer_actions_tour_portal_user", {
steps: () => [
{
trigger: `#chatterRoot:shadow .o-mail-Composer:not(:has(${cannedResponseButtonSelector}))`,
},
],
});

View file

@ -0,0 +1,22 @@
import { messageActionsRegistry } from "@mail/core/common/message_actions";
import { registry } from "@web/core/registry";
import { patch } from "@web/core/utils/patch";
registry.category("web_tour.tours").add("portal_copy_link_tour", {
steps: () => [
{
trigger: "#chatterRoot:shadow .o-mail-Message",
run: () => {
const copyLinkAction = messageActionsRegistry.get("copy-link");
patch(copyLinkAction, { sequence: 1 }); // make sure the action is visible without expanding
}
},
{
trigger: "#chatterRoot:shadow .o-mail-Message:contains(Test Message)",
run: "hover && click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message-actions [title='Copy Link']",
},
],
});

View file

@ -0,0 +1,28 @@
import { messageActionsRegistry } from "@mail/core/common/message_actions";
import { registry } from "@web/core/registry";
import { patch } from "@web/core/utils/patch";
registry.category("web_tour.tours").add("portal_no_copy_link_tour", {
steps: () => [
{
trigger: "#chatterRoot:shadow .o-mail-Message",
run: () => {
const copyLinkAction = messageActionsRegistry.get("copy-link");
patch(copyLinkAction, { sequence: 1 }); // make sure the action is visible without expanding
}
},
{
trigger: "#chatterRoot:shadow .o-mail-Message:contains(Test Message)",
run: "hover && click",
},
{
trigger: "#chatterRoot:shadow .o-mail-Message-actions",
run: async () => {
const copyLinkButton = document.querySelector('#chatterRoot').shadowRoot.querySelector("[title='Copy Link']");
if (copyLinkButton) {
throw new Error("Users without read access should not be able to copy the link to a message");
}
},
},
],
});

View file

@ -0,0 +1,46 @@
import { registry } from "@web/core/registry";
const ratingCardSelector = ".o_website_rating_card_container";
registry.category("web_tour.tours").add("portal_rating_tour", {
steps: () => [
{
// Ensure that the rating data has been fetched before making a negative assertion for rating cards.
trigger: "#chatterRoot:shadow .o-mail-Message-body:text(Message without rating)",
},
{
trigger: `#chatterRoot:shadow .o-mail-Chatter-top:not(:has(${ratingCardSelector}))`,
},
{
trigger: "#chatterRoot:shadow .o-mail-Composer-input",
run: "edit Excellent service!",
},
{
trigger: "#chatterRoot:shadow .o-mail-Composer-send:enabled",
run: "click",
},
{
trigger: `#chatterRoot:shadow .o-mail-Chatter-top ${ratingCardSelector} .o_website_rating_table_row[data-star='4']:has(:text(100%))`,
},
],
});
registry.category("web_tour.tours").add("portal_display_rating_tour", {
steps: () => [
{
trigger: `#chatterRoot:shadow .o-mail-Chatter-top ${ratingCardSelector}`,
},
],
});
registry.category("web_tour.tours").add("portal_not_display_rating_tour", {
steps: () => [
{
// Ensure that the rating data has been fetched before making a negative assertion for rating cards.
trigger: "#chatterRoot:shadow .o-mail-Message-body:text(Message with rating)",
},
{
trigger: `#chatterRoot:shadow .o-mail-Chatter-top:not(:has(${ratingCardSelector}))`,
},
],
});