Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] web: fix issue with spread operator #166111

Conversation

jaha-odoo
Copy link

Isuue

There was a problem with using the spread operator in this function when links contained multiple URLs. For example, const array = ['a', 'b', 'c']. When we use the spread operator for the first time, the result is 'a', 'b', 'c'. However ,when we try to spread it again, it doesn't work properly, it only shows single link inside notification toast

Resolution

The implementation was updated to correctly handle multiple URLs by removing the spread operator before links.

@robodoo
Copy link
Contributor

robodoo commented May 20, 2024

@C3POdoo C3POdoo added the RD research & development, internal work label May 20, 2024
@kir-odoo kir-odoo marked this pull request as ready for review May 20, 2024 13:13
@C3POdoo C3POdoo requested review from a team, kebeclibre and Iucapad and removed request for a team May 20, 2024 13:14
@kir-odoo
Copy link
Contributor

Hello @aab-odoo can you plz review this fix? It targets to correct version with the unit test.

assert.containsOnce(webClient, ".o_kanban_view");

const links = [
{ label: "test1 <R&D>", url: "#action={action.id}&id={order.id}&model=purchase.order" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this url make sense? I don't think it will be evaluated...

Copy link
Contributor

@kir-odoo kir-odoo May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aab-odoo Yes you are right url doesn't make sense, but here the goal is to check is multiple URL. i think it's doesn't matter the URL action is correct.
As we have did the same for single url test.

url: "#action={action.id}&id={order.id}&model=purchase.order",

And yes we can pass here dynamic url, but it'll just increse the line of code not very useful here.

`message test1 <R&D>,test2 <R&D>,test3 <R&D> <R&D>`,
"the notification should have the correct message"
);
assert.containsOnce(webClient, ".o_kanban_view");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this assertion is not really useful.
Instead, could you assert the links href?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jaha-odoo jaha-odoo force-pushed the 15.0-web-display_notification-fix-multiple-links-jaha branch from ced8766 to 28933a9 Compare May 21, 2024 13:32
"the notification should have the correct message"
);
const notificationLinks = notificationElement.querySelector(".o_notification_content");
links.forEach((link, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't really care about the number of lines in tests. In this case, I definitely prefer 3 assert.strictEqual lines that are easier to read that a forEach (which is also written on 3 lines btw).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aab-odoo Yeah, The Changes have been made, Thank you for your suggestion

@jaha-odoo jaha-odoo force-pushed the 15.0-web-display_notification-fix-multiple-links-jaha branch from 28933a9 to 7c1665d Compare May 22, 2024 05:13
Isuue
=====
There was a problem with using the spread operator in this function when links
contained multiple URLs. For example, const array = ['a', 'b', 'c']. When we
use the spread operator for the first time, the result is 'a', 'b', 'c'. However
,when  we try to spread it again, it doesn't work properly, it only shows single
link inside notification toast

Resolution
===========
The implementation was updated to correctly handle multiple URLs by removing
the spread operator before links.
@aab-odoo aab-odoo force-pushed the 15.0-web-display_notification-fix-multiple-links-jaha branch from 7c1665d to 0d68b5d Compare May 22, 2024 06:56
Copy link
Contributor

@aab-odoo aab-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

robodoo r+

robodoo pushed a commit that referenced this pull request May 22, 2024
Isuue
=====
There was a problem with using the spread operator in this function when links
contained multiple URLs. For example, const array = ['a', 'b', 'c']. When we
use the spread operator for the first time, the result is 'a', 'b', 'c'. However
,when  we try to spread it again, it doesn't work properly, it only shows single
link inside notification toast

Resolution
===========
The implementation was updated to correctly handle multiple URLs by removing
the spread operator before links.

closes #166111

Signed-off-by: Aaron Bohy (aab) <[email protected]>
@robodoo robodoo closed this May 22, 2024
lohwswilson pushed a commit to lohwswilson/odoo that referenced this pull request Jun 3, 2024
Isuue
=====
There was a problem with using the spread operator in this function when links
contained multiple URLs. For example, const array = ['a', 'b', 'c']. When we
use the spread operator for the first time, the result is 'a', 'b', 'c'. However
,when  we try to spread it again, it doesn't work properly, it only shows single
link inside notification toast

Resolution
===========
The implementation was updated to correctly handle multiple URLs by removing
the spread operator before links.

closes odoo#166111

Signed-off-by: Aaron Bohy (aab) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants