Skip to content

[19.0][FIX] project_task_description_template: make tests robust to HTML field wrapping#1739

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
ledoent:19.0-fix-description_template-tests-robust
May 29, 2026
Merged

[19.0][FIX] project_task_description_template: make tests robust to HTML field wrapping#1739
OCA-git-bot merged 1 commit into
OCA:19.0from
ledoent:19.0-fix-description_template-tests-robust

Conversation

@dnplkndll
Copy link
Copy Markdown

TestDescriptionTemplate fails on 19.0, and the failure oscillates: the two
onchange assertions pin the exact HTML wrapper of the appended template text,
but that wrapper is not stable across Odoo nightlies.

Root cause

The Html field runs core's html_sanitize() (odoo/tools/mail.py) on write.
For tagless input its fromstring() returns the element libxml2 auto-creates
when it wraps the loose text in a <p>, and otherwise falls back to tagging the
body <span>. Whether libxml2 auto-wraps tagless text drifts between
Odoo/lxml builds — the assertions were flipped <p><span> only days ago and
are failing again now that core emits <p>. The module input
(" - Sample Description") never changed; only the sanitiser output moved.

Fix

Compare the result against the template's own stored Html value rather than
a hard-coded string. Both sides pass through the same sanitiser, so they agree
regardless of which branch of that code runs — no more tag flip-flop. Module
behaviour is unchanged, and the only remaining literal (<p>Existing Description</p>) is a block element, stable across both regimes.

Verified on a clean odoo:19.0 (--test-enable --without-demo=all): both tests
pass (0 failed, 0 error(s) of 2 tests).

…eld wrapping

The two onchange tests pinned the exact wrapper tag of the appended template
text. Odoo core flips that wrapper between releases (<span> <-> <p>), so the
hard-coded assertions break on every change. Compare against the template's own
stored Html value instead, so both sides track whatever core produces.
@leemannd
Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot
Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 19.0-ocabot-merge-pr-1739-by-leemannd-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e364e49 into OCA:19.0 May 29, 2026
7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at dbc4fef. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants