diff options
| author | Jeremy Kersten <jke@odoo.com> | 2020-03-06 16:10:23 +0000 |
|---|---|---|
| committer | Jeremy Kersten <jke@odoo.com> | 2020-03-06 21:39:14 +0000 |
| commit | 614c9baae412020ac9d23c81a2650c9e86046e32 (patch) | |
| tree | 1ebce847e2b74655b212c181cabc209a9d2a967d /addons/website/static/tests | |
| parent | 121c73246dfe455cfd0a86af7515d28bc0a79661 (diff) | |
[REF] website: refactor reset_password tour
Previous implementation crashes randomly in chrome headless due to timeout.
Avoid to do web action, while we just want to check reset_password feature.
+ add one test that reset password on partner from website 2 to check that
link match the domauin from website 2.
closes odoo/odoo#47136
X-original-commit: d8019f25a5cd6ed611295e9b93111402f4cad04a
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website/static/tests')
| -rw-r--r-- | addons/website/static/tests/tours/reset_password.js | 132 |
1 files changed, 2 insertions, 130 deletions
diff --git a/addons/website/static/tests/tours/reset_password.js b/addons/website/static/tests/tours/reset_password.js index a0e04ccae90..ef9fc1d0586 100644 --- a/addons/website/static/tests/tours/reset_password.js +++ b/addons/website/static/tests/tours/reset_password.js @@ -6,137 +6,9 @@ var rpc = require('web.rpc'); var tour = require('web_tour.tour'); require('web.dom_ready'); -var currentDomain = window.location.protocol + '//' + window.location.hostname; -var emailsUrl = '/web#action=mail.action_view_mail_mail&view_type=list'; -var usersUrl = '/web#action=base.action_res_users&view_type=list'; -var resetLinkKey = 'website.tour_reset_password.resetLink'; - tour.register('website_reset_password', { test: true, - url: '/web', -}, -[ - { - content: "Change the domain of the websites and go to users page", - trigger: '.oe_topbar_name:contains("Admin")', - run: function () { - // We could do it with the UI but this is not the goal of this test, - // so we just make an RPC to be faster. - - // We change the domain of the website to test that the email that - // will be sent uses the correct domain for its links. - var def1 = rpc.query({ - 'model': 'website', - 'method': 'write', - 'args': [[1], { - 'domain': "my-test-domain.com", - }], - }); - // We need to change the domain of all the websites otherwise the - // website selector will return the website 2 since the domain we - // set on website 1 doesn't actually match our test server. - var def2 = rpc.query({ - 'model': 'website', - 'method': 'write', - 'args': [[2], { - 'domain': "https://domain-not-used.fr", - }], - }); - // Set a website on "Admin" partner to test the URL of the website. - var def3 = rpc.query({ - model: 'ir.model.data', - method: 'xmlid_to_res_id', - args: ['base.partner_admin'], - }).then(function (res_id) { - return rpc.query({ - 'model': 'res.partner', - 'method': 'write', - 'args': [[res_id], { - 'website_id': 1, - }], - }); - }); - - return Promise.all([def1, def2, def3]).then(function () { - window.location.href = usersUrl; - }); - }, - }, - { - content: "click on Admin", - trigger: '.o_data_cell:contains("Admin")', - }, - { - content: "click on reset password", - trigger: '.btn[name="action_reset_password"]', - }, - { - content: "wait mail to be sent, and go see it", - trigger: 'a[name="signup_url"][href^="http://my-test-domain.com"]', - run: function () { - window.location.href = emailsUrl; - }, - }, - { - content: "click on the first email", - trigger: '.o_data_cell:contains("Password reset"):eq(0)', - }, - { - content: "check email has the button", - trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")', - run: function () {}, - }, - { - content: "check the URL is correct too", - trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")[href^="http://my-test-domain.com"]', - run: function () { - // reset the domain of the websites, go to users page - return rpc.query({ - 'model': 'website', - 'method': 'write', - 'args': [[1, 2], { - 'domain': "", - }], - }).then(function () { - window.location.href = usersUrl; - }); - }, - }, - { - content: "click on Admin", - trigger: '.o_data_cell:contains("Admin")', - }, - { - content: "click on reset password", - trigger: '.btn[name="action_reset_password"]', - }, - { - content: "wait mail to be sent, and go see it", - trigger: 'a[name="signup_url"][href^="' + currentDomain + '"]', - run: function () { - window.location.href = emailsUrl; - }, - }, - { - content: "click on the first email", - trigger: '.o_data_cell:contains("Password reset"):eq(0)', - }, - { - content: "check the link has the current host, save the link, logout", - trigger: 'div.oe_form_field_html[name="body_html"] a:contains("Change password")[href^="' + currentDomain + '"]', - run: function () { - var link = $('div.oe_form_field_html[name="body_html"] a:contains("Change password")').attr('href'); - localStorage.setItem(resetLinkKey, link); - window.location.href = "/web/session/logout?redirect=/"; - }, - }, - { - content: "go to the reset link", - trigger: 'a[href="/web/login"]', - run: function () { - window.location.href = localStorage.getItem(resetLinkKey); - }, - }, +}, [ { content: "fill new password", trigger: '.oe_reset_password_form input[name="password"]', @@ -153,7 +25,7 @@ tour.register('website_reset_password', { }, { content: "check that we're logged in", - trigger: '.oe_topbar_name:contains("Admin")', + trigger: '.oe_topbar_name:contains("The King")', run: function () {} }, { |
