8000 [FIX] website_payment: split test to avoid iframe issue · odoo-dev/odoo@41f192a · GitHub
[go: up one dir, main page]

Skip to content

Commit 41f192a

Browse files
alessandro-caldonazziqsm-odoo
authored andcommitted
[FIX] website_payment: split test to avoid iframe issue
On slow networks, users or runbot may click checkboxes before the JavaScript is fully loaded by the lazy loader, causing event handlers to not be attached. While test tours are supposed to be robust enough to wait for that, it was decided to split the test into two separate tours, as testing the donation form use from a non-admin is also better. So: one part while logged in as admin for donation configuration, and another while logged in as portal user to test it (we use a portal user so that the form still autocompletes with base user information). runbot-77224 X-original-commit: c4418cd Part-of: odoo#210494 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: qsm-odoo <qsm@odoo.com>
1 parent 1e8bbea commit 41f192a

File tree

2 files changed

+65
-44
lines changed

2 files changed

+65
-44
lines changed
Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { registry } from "@web/core/registry";
12
import {
2-
clickOnEditAndWaitEditMode,
33
clickOnSave,
44
registerWebsitePreviewTour,
55
insertSnippet,
@@ -19,94 +19,103 @@ registerWebsitePreviewTour(
1919
groupName: "Contact & Forms",
2020
}),
2121
...clickOnSave(),
22+
],
23+
);
24+
25+
registry.category('web_tour.tours').add('donation_snippet_use', {
26+
url: '/',
27+
steps: () => [
2228
// -- Testing the minimum amount --
2329
{
2430
content: "Enter a negative custom amount, testing the minimum amount",
25-
trigger: ":iframe #s_donation_amount_input",
31+
trigger: "#s_donation_amount_input",
2632
run: "edit 1",
2733
},
2834
{
2935
content: "Donate with custom amount set",
30-
trigger: ":iframe .s_donation_donate_btn",
36+
trigger: ".s_donation_donate_btn",
3137
run: "click",
3238
},
3339
{
3440
content: "Check if alert-danger element exists",
35-
trigger: ":iframe p.alert-danger",
41+
trigger: "p.alert-danger",
3642
},
3743
// -- End of testing the minimum amount --
3844
{
3945
content: "Enter a custom amount",
40-
trigger: ":iframe #s_donation_amount_input",
46+
trigger: "#s_donation_amount_input",
4147
run: "edit 55",
4248
},
4349
{
4450
content: "Donate with custom amount set",
45-
trigger: ":iframe .s_donation_donate_btn",
51+
trigger: ".s_donation_donate_btn",
4652
run: "click",
4753
},
4854
{
4955
content: "Check if custom amount radio input is selected",
50-
trigger: ":iframe input#other_amount:checked",
56+
trigger: "input#other_amount:checked",
5157
},
5258
{
5359
content: "Check if custom amount radio input has value 55",
54-
trigger: ':iframe input#other_amount[value="55.0"]',
60+
trigger: 'input#other_amount[value="55.0"]',
5561
},
5662
{
5763
content: "Select the amount of 25",
58-
trigger: ":iframe input#amount_1",
64+
trigger: "input#amount_1",
5965
run: "click",
6066
},
6167
{
6268
content: "Verify that amount_1 is checked",
63-
trigger: ":iframe input#amount_1:checked",
69+
trigger: "input#amount_1:checked",
6470
},
6571
{
6672
content: "Verify that other_amount is not checked",
67-
trigger: ":iframe input#other_amount:not(:checked)",
73+
trigger: "input#other_amount:not(:checked)",
6874
},
6975
{
7076
content: "Click on the custom amount radio button",
71-
trigger: ":iframe input#other_amount",
77+
trigger: "input#other_amount",
7278
run: "click",
7379
},
7480
{
7581
content: "Submit the donation form",
76-
trigger: ":iframe button[name='o_payment_submit_button']",
82+
trigger: "button[name='o_payment_submit_button']",
7783
run: "click",
7884
},
7985
{
8086
content: "Check if the warning message is displayed",
81-
trigger: ":iframe .o_donation_payment_form:has(small#warning_message_id)",
87+
trigger: ".o_donation_payment_form:has(small#warning_message_id)",
8288
},
8389
{
8490
content: "Enter an amount less than the minimum value",
85-
trigger: ":iframe input#other_amount_value",
91+
trigger: "input#other_amount_value",
8692
run: "edit 1",
8793
},
8894
{
8995
content:
9096
"Verify whether the minimum value warning message is displayed while other warning messages remain hidden",
9197
trigger:
92-
":iframe small#warning_min_message_id:contains('The minimum donation amount is $5.'), :iframe .o_donation_payment_form:has(small#warning_message_id.d-none)",
98+
"small#warning_min_message_id:contains('The minimum donation amount is $5.'), .o_donation_payment_form:has(small#warning_message_id.d-none)",
9399
},
94100
{
95101
content: "Click on the first radio button",
96-
trigger: ":iframe input[name='o_donation_amount']:first-child",
102+
trigger: "input[name='o_donation_amount']:first-child",
97103
run: "click",
98104
},
99105
{
100106
content: "Ensure the custom amount value is cleared",
101-
trigger:
102-
":iframe input#other_amount_value:empty, :iframe #warning_min_message_id.d-none",
107+
trigger: "input#other_amount_value:empty, #warning_min_message_id.d-none",
103108
},
104-
{
105-
content: "Go to home page",
106-
trigger: ":iframe a[href='/'].nav-link",
107-
run: "click",
108-
},
109-
...clickOnEditAndWaitEditMode(),
109+
],
110+
});
111+
112+
registerWebsitePreviewTour(
113+
"donation_snippet_edition_2",
114+
{
115+
url: "/",
116+
edition: true,
117+
},
118+
() => [
110119
{
111120
content: "Click on 'Custom Amount' button",
112121
trigger: ":iframe .s_donation_donate_btn",
@@ -115,45 +124,51 @@ registerWebsitePreviewTour(
115124
changeOption("Donation", "we-toggler"),
116125
changeOption("Donation", '[data-name="slider_opt"]'),
117126
...clickOnSave(),
127+
],
128+
);
129+
130+
registry.category('web_tour.tours').add('donation_snippet_use_2', {
131+
url: '/',
132+
steps: () => [
118133
{
119134
content: "Click on $10 button",
120-
trigger: ":iframe .s_donation_btn_description button",
135+
trigger: ".s_donation_btn_description button",
121136
run: "click",
122137
},
123138
{
124139
content: "Donate using the selected amount",
125-
trigger: ":iframe .s_donation_donate_btn",
140+
trigger: ".s_donation_donate_btn",
126141
run: "click",
127142
},
128143
{
129144
content: "Click on the 'Amount to donate' input field",
130-
trigger: ":iframe input#other_amount_value",
145+
trigger: "input#other_amount_value",
131146
run: "click",
132147
},
133148
{
134149
content: "Change custom amount to 67",
135-
trigger: ":iframe input[name='o_donation_amount'][type='number']",
150+
trigger: "input[name='o_donation_amount'][type='number']",
136151
run: "edit 67",
137152
},
138153
{
139154
content: "Select the custom amount radio button",
140-
trigger: ":iframe input#other_amount",
155+
trigger: "input#other_amount",
141156
run: "click",
142157
},
143158
{
144159
content: "Submit the donation form",
145-
trigger: ":iframe button[name='o_payment_submit_button']",
160+
trigger: "button[name='o_payment_submit_button']",
146161
run: "click",
147162
},
148163
{
149-
trigger: ":iframe body:contains(Your payment has been processed.)",
164+
trigger: "body:contains(Your payment has been processed.)",
150165
},
151166
{
152167
content: "Verify that the amount displayed is 67",
153-
trigger: ':iframe span.oe_currency_value:contains("67.00")',
168+
trigger: 'span.oe_currency_value:contains("67.00")',
154169
},
155170
{
156-
trigger: ":iframe [name=o_payment_status_alert]:contains(thank you!)",
171+
trigger: "[name=o_payment_status_alert]:contains(thank you!)",
157172
},
158-
]
159-
);
173+
],
174+
});
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import odoo
2-
import odoo.tests
3-
import logging
1+
from odoo.tests.common import tagged
2+
from odoo.addons.base.tests.common import HttpCaseWithUserPortal
43

5-
_logger = logging.getLogger(__name__)
64

7-
8-
@odoo.tests.common.tagged('post_install', '-at_install')
9-
class TestSnippets(odoo.tests.HttpCase):
5+
@tagged('post_install', '-at_install')
6+
class TestSnippets(HttpCaseWithUserPortal):
107

118
def test_01_donation(self):
129
payment_demo = self.env['ir.module.module']._get('payment_demo')
@@ -15,11 +12,20 @@ def test_01_donation(self):
1512

1613
demo_provider = self.env['payment.provider'].search([('code', '=', "demo")])
1714
demo_provider.write({'state': 'test'})
15+
16+
belgium = self.env.ref('base.be')
17+
1818
self.env.ref('base.user_admin').write({
19-
'country_id': self.env.ref('base.be').id,
19+
'country_id': belgium.id,
2020
'email': 'mitchell.admin@example.com',
2121
})
2222
self.env.company.write({
2323
'email': 'no-reply@company.com',
2424
})
25+
26+
self.user_portal.country_id = belgium.id
27+
2528
self.start_tour("/?enable_editor=1", "donation_snippet_edition", login='admin')
29+
self.start_tour("/", "donation_snippet_use", login="portal")
30+
self.start_tour("/?enable_editor=1", "donation_snippet_edition_2", login='admin')
31+
self.start_tour("/", "donation_snippet_use_2", login="portal")

0 commit comments

Comments
 (0)
0