| 1 |
/** @odoo-module **/ |
| 2 |
|
| 3 |
import { registerWebsitePreviewTour } from '@website/js/tours/tour_utils'; |
| 4 |
|
| 5 |
import { stepUtils } from "@web_tour/tour_utils"; |
| 6 |
/** |
| 7 |
* The purpose of these tours is to check whether Publish can or cannot be |
| 8 |
* used by the given current user. |
| 9 |
*/ |
| 10 |
|
| 11 |
registerWebsitePreviewTour('test_can_publish_partner', { |
| 12 |
edition: false, |
| 13 |
url: '/partners', |
| 14 |
}, () => [ |
| 15 |
stepUtils.waitIframeIsReady(), |
| 16 |
{ |
| 17 |
content: 'Open grade filter', |
| 18 |
trigger: ':iframe .dropdown:has(.dropdown-item:contains("Grade Test")) button.dropdown-toggle:contains("All Categories")', |
| 19 |
run: "click", |
| 20 |
}, { |
| 21 |
content: 'Filter on Grade Test', // needed if there are demo data |
| 22 |
trigger: ':iframe .dropdown a.dropdown-item:contains("Grade Test")', |
| 23 |
run: "click", |
| 24 |
}, { |
| 25 |
content: 'Go to partner', |
| 26 |
trigger: ':iframe a:contains("Agrolait")', |
| 27 |
run: "click", |
| 28 |
}, { |
| 29 |
content: 'Unpublish', |
| 30 |
trigger: '.o_menu_systray .o_menu_systray_item.o_website_publish_container:contains("Published")', |
| 31 |
run: "click", |
| 32 |
}, { |
| 33 |
content: "Wait for Unpublish", |
| 34 |
trigger: '.o_menu_systray .o_menu_systray_item.o_website_publish_container:contains("Unpublished"):not([data-processing])', |
| 35 |
}, { |
| 36 |
content: "Publish", |
| 37 |
trigger: '.o_menu_systray .o_menu_systray_item.o_website_publish_container:contains("Unpublished")', |
| 38 |
run: "click", |
| 39 |
}, { |
| 40 |
content: "Wait for Publish", |
| 41 |
trigger: '.o_menu_systray .o_menu_systray_item.o_website_publish_container:contains("Published"):not([data-processing])', |
| 42 |
}]); |
| 43 |
|
| 44 |
registerWebsitePreviewTour('test_cannot_publish_partner', { |
| 45 |
edition: false, |
| 46 |
url: '/partners', |
| 47 |
}, () => [ |
| 48 |
stepUtils.waitIframeIsReady(), |
| 49 |
{ |
| 50 |
content: 'Open grade filter', |
| 51 |
trigger: ':iframe .dropdown:has(.dropdown-item:contains("Grade Test")) button.dropdown-toggle:contains("All Categories")', |
| 52 |
run: "click", |
| 53 |
}, { |
| 54 |
content: 'Filter on Grade Test', // needed if there are demo data |
| 55 |
trigger: ':iframe .dropdown a.dropdown-item:contains("Grade Test")', |
| 56 |
run: "click", |
| 57 |
}, { |
| 58 |
content: 'Go to partner', |
| 59 |
trigger: ':iframe a:contains("Agrolait")', |
| 60 |
run: "click", |
| 61 |
}, { |
| 62 |
content: 'Wait for the "edit in backend" button to appear before checking the publish button', |
| 63 |
trigger: '.o_menu_systray .o_website_edit_in_backend > a', |
| 64 |
// Seems enough to just wait for that button presence before checking the |
| 65 |
// following step but a bit of delay seems a bit more robust to potential |
| 66 |
// code changes. At least if the rendering flow changes or the tour system |
| 67 |
// changes, this should be enough to trigger a race condition in this test. |
| 68 |
run: () => new Promise(resolve => setTimeout(resolve, 100)), |
| 69 |
}, { |
| 70 |
content: 'Check there is no Publish/Unpublish', |
| 71 |
trigger: '.o_menu_systray:has(.o_website_edit_in_backend > a):not(:has(.o_menu_systray_item.o_website_publish_container))', |
| 72 |
}]); |