From 1af6dfe47baf1f42865203d0f3edafc6b50bbae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 28 Feb 2022 10:05:45 +0000 Subject: [PATCH] [IMP] website_slides: add a standard publisher tour Purpose of this commit is to add a publisher tour in standard that is not only run using external tags. Indeed external tours are not monitored and previous commits show that they can be broken since a long time. In this commit we somehow copy the publisher tour with an article-based slide instead of a video slide. That way it can be launched with other standard tours. Task-2780920 (eLearning: fix publisher tour) Part-of: odoo/odoo#74171 --- .../tours/slide_course_publisher_standard.js | 104 ++++++++++++++++++ .../src/tests/tours/slides_tour_tools.js | 3 + .../website_slides/tests/test_ui_wslides.py | 23 +++- 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 addons/website_slides/static/src/tests/tours/slide_course_publisher_standard.js diff --git a/addons/website_slides/static/src/tests/tours/slide_course_publisher_standard.js b/addons/website_slides/static/src/tests/tours/slide_course_publisher_standard.js new file mode 100644 index 00000000000..dc8ea89c266 --- /dev/null +++ b/addons/website_slides/static/src/tests/tours/slide_course_publisher_standard.js @@ -0,0 +1,104 @@ +/** @odoo-module **/ + +import tour from 'web_tour.tour'; +import slidesTourTools from '@website_slides/tests/tours/slides_tour_tools'; + +/** + * Global use case: + * a user (website publisher) creates a course; + * he updates it; + * he creates some lessons in it; + * he publishes it; + */ +tour.register('course_publisher_standard', { + url: '/slides', + test: true +}, [{ + content: 'eLearning: click on New (top-menu)', + trigger: 'div.o_new_content_menu a' +}, { + content: 'eLearning: click on New Course', + trigger: 'a:contains("Course")' +}, { + content: 'eLearning: set name', + trigger: 'input[name="name"]', + run: 'text How to Déboulonnate', +}, { + content: 'eLearning: click on tags', + trigger: 'ul.select2-choices:first', +}, { + content: 'eLearning: select gardener tag', + trigger: 'div.select2-result-label:contains("Gardener")', + in_modal: false, +}, { + content: 'eLearning: set description', + trigger: 'textarea[name="description"]', + run: 'text Déboulonnate is very common at Fleurus', +}, { + content: 'eLearning: we want reviews', + trigger: 'input[name="allow_comment"]', +}, { + content: 'eLearning: seems cool, create it', + trigger: 'button:contains("Create")', +}, { + content: 'eLearning: launch course edition', + trigger: 'div[id="edit-page-menu"] a', +}, { + content: 'eLearning: double click image to edit it', + trigger: 'img.o_wslides_course_pict', + run: 'dblclick', +}, { + content: 'eLearning: click "Add URL" to trigger URL box', + trigger: '.o_upload_media_url_button', +}, { + content: 'eLearning: add a bioutifoul URL', + trigger: 'input.o_we_url_input', + run: 'text https://upload.wikimedia.org/wikipedia/commons/thumb/1/12/ThreeTimeAKCGoldWinnerPembrookeWelshCorgi.jpg/800px-ThreeTimeAKCGoldWinnerPembrookeWelshCorgi.jpg' +}, { + content: 'eLearning: click "Add URL" really adding image', + trigger: '.o_upload_media_url_button', +}, { + content: 'eLearning: is the Corgi set ?', + trigger: 'img.o_wslides_course_pict', + run: function () { + if ($('img.o_wslides_course_pict').attr('src').endsWith('GoldWinnerPembrookeWelshCorgi.jpg')) { + $('img.o_wslides_course_pict').addClass('o_wslides_tour_success'); + } + }, +}, { + content: 'eLearning: the Corgi is set !', + trigger: 'img.o_wslides_course_pict.o_wslides_tour_success', +}, { + content: 'eLearning: save course edition', + trigger: 'button[data-action="save"]', +}, { + content: 'eLearning: course create with current member', + extra_trigger: 'body:not(.editor_enable)', // wait for editor to close + trigger: '.o_wslides_js_course_join:contains("You\'re enrolled")', + run: function () {} // check membership +} +].concat( + slidesTourTools.addExistingCourseTag(), + slidesTourTools.addNewCourseTag('The Most Awesome Course'), + slidesTourTools.addSection('Introduction'), + slidesTourTools.addArticleToSection('Introduction', 'MyArticle'), + [{ + content: "eLearning: check editor is loaded for article", + trigger: 'body.editor_enable', + timeout: 30000, + run: () => null, // it's a check +}, { + content: "eLearning: save article", + trigger: '.o_we_website_top_actions button.btn-primary:contains("Save")', +}, { + content: "eLearning: use breadcrumb to go back to channel", + trigger: '.o_wslides_course_nav a:contains("Déboulonnate")', +}] +// [ +// { +// content: 'eLearning: move new course inside introduction', +// trigger: 'div.o_wslides_slides_list_drag', +// // run: 'drag_and_drop div.o_wslides_slides_list_drag ul.ui-sortable:first', +// run: 'drag_and_drop div.o_wslides_slides_list_drag a.o_wslides_js_slide_section_add', +// }] +)); diff --git a/addons/website_slides/static/src/tests/tours/slides_tour_tools.js b/addons/website_slides/static/src/tests/tours/slides_tour_tools.js index 9a3a5059d6d..6c8ae37ade4 100644 --- a/addons/website_slides/static/src/tests/tours/slides_tour_tools.js +++ b/addons/website_slides/static/src/tests/tours/slides_tour_tools.js @@ -79,6 +79,9 @@ var addArticleToSection = function (sectionName, pageName) { content: 'eLearning: fill article completion time', trigger: 'input[name=duration]', run: 'text 4', +}, { + content: 'eLearning: create and publish slide', + trigger: 'footer.modal-footer button:contains("Publish")', }]; }; diff --git a/addons/website_slides/tests/test_ui_wslides.py b/addons/website_slides/tests/test_ui_wslides.py index bc5fa4bf21f..2062a788ac1 100644 --- a/addons/website_slides/tests/test_ui_wslides.py +++ b/addons/website_slides/tests/test_ui_wslides.py @@ -152,8 +152,29 @@ class TestUi(TestUICommon): login=user_demo.login) +@tests.common.tagged('post_install', '-at_install') +class TestUiPublisher(HttpCaseWithUserDemo): + + def test_course_publisher_elearning_manager(self): + user_demo = self.user_demo + user_demo.flush() + user_demo.write({ + 'groups_id': [ + (5, 0), + (4, self.env.ref('base.group_user').id), + (4, self.env.ref('website_slides.group_website_slides_manager').id) + ], + }) + + self.browser_js( + '/slides', + 'odoo.__DEBUG__.services["web_tour.tour"].run("course_publisher_standard")', + 'odoo.__DEBUG__.services["web_tour.tour"].tours.course_publisher_standard.ready', + login=user_demo.login) + + @tests.common.tagged('external', 'post_install', '-standard', '-at_install') -class TestUiYoutube(HttpCaseWithUserDemo): +class TestUiPublisherYoutube(HttpCaseWithUserDemo): def test_course_member_yt_employee(self): # remove membership because we need to be able to join the course during the tour