Files
odoo_source/addons/website_slides/tests/test_ui_wslides.py
T
Thibault Delavallée 1af6dfe47b [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
2022-02-28 11:07:41 +00:00

206 lines
8.1 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base64
from dateutil.relativedelta import relativedelta
from odoo import tests
from odoo.fields import Datetime
from odoo.modules.module import get_module_resource
from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal
class TestUICommon(HttpCaseWithUserDemo, HttpCaseWithUserPortal):
def setUp(self):
super(TestUICommon, self).setUp()
# Load pdf and img contents
pdf_path = get_module_resource('website_slides', 'static', 'src', 'img', 'presentation.pdf')
pdf_content = base64.b64encode(open(pdf_path, "rb").read())
img_path = get_module_resource('website_slides', 'static', 'src', 'img', 'slide_demo_gardening_1.jpg')
img_content = base64.b64encode(open(img_path, "rb").read())
self.env['slide.channel'].create({
'name': 'Basics of Gardening - Test',
'user_id': self.env.ref('base.user_admin').id,
'enroll': 'public',
'channel_type': 'training',
'allow_comment': True,
'promote_strategy': 'most_voted',
'is_published': True,
'description': 'Learn the basics of gardening !',
'create_date': Datetime.now() - relativedelta(days=8),
'slide_ids': [
(0, 0, {
'name': 'Gardening: The Know-How',
'sequence': 1,
'binary_content': pdf_content,
'slide_category': 'document',
'is_published': True,
'is_preview': True,
}), (0, 0, {
'name': 'Home Gardening',
'sequence': 2,
'image_1920': img_content,
'slide_category': 'infographic',
'is_published': True,
}), (0, 0, {
'name': 'Mighty Carrots',
'sequence': 3,
'image_1920': img_content,
'slide_category': 'infographic',
'is_published': True,
}), (0, 0, {
'name': 'How to Grow and Harvest The Best Strawberries | Basics',
'sequence': 4,
'binary_content': pdf_content,
'slide_category': 'document',
'is_published': True,
}), (0, 0, {
'name': 'Test your knowledge',
'sequence': 5,
'slide_category': 'quiz',
'is_published': True,
'question_ids': [
(0, 0, {
'question': 'What is a strawberry ?',
'answer_ids': [
(0, 0, {
'text_value': 'A fruit',
'is_correct': True,
'sequence': 1,
}), (0, 0, {
'text_value': 'A vegetable',
'sequence': 2,
}), (0, 0, {
'text_value': 'A table',
'sequence': 3,
})
]
}), (0, 0, {
'question': 'What is the best tool to dig a hole for your plants ?',
'answer_ids': [
(0, 0, {
'text_value': 'A shovel',
'is_correct': True,
'sequence': 1,
}), (0, 0, {
'text_value': 'A spoon',
'sequence': 2,
})
]
})
]
})
]
})
@tests.common.tagged('post_install', '-at_install')
class TestUi(TestUICommon):
def test_course_member_employee(self):
user_demo = self.user_demo
user_demo.flush()
user_demo.write({
'karma': 1,
'groups_id': [(6, 0, self.env.ref('base.group_user').ids)]
})
self.browser_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("course_member")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_member.ready',
login=user_demo.login)
def test_course_member_elearning_officer(self):
user_demo = self.user_demo
user_demo.flush()
user_demo.write({
'karma': 1,
'groups_id': [(6, 0, (self.env.ref('base.group_user') | self.env.ref('website_slides.group_website_slides_officer')).ids)]
})
self.browser_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("course_member")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_member.ready',
login=user_demo.login)
def test_course_member_portal(self):
user_portal = self.user_portal
user_portal.flush()
user_portal.karma = 1
self.browser_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("course_member")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_member.ready',
login=user_portal.login)
def test_full_screen_edition_website_publisher(self):
# group_website_designer
user_demo = self.env.ref('base.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.group_website_publisher').id)]
})
self.browser_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("full_screen_web_editor")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.full_screen_web_editor.ready',
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 TestUiPublisherYoutube(HttpCaseWithUserDemo):
def test_course_member_yt_employee(self):
# remove membership because we need to be able to join the course during the tour
user_demo = self.user_demo
user_demo.flush()
user_demo.write({
'groups_id': [(5, 0), (4, self.env.ref('base.group_user').id)]
})
self.env.ref('website_slides.slide_channel_demo_3_furn0')._remove_membership(self.env.ref('base.partner_demo').ids)
self.browser_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("course_member_youtube")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_member_youtube.ready',
login=user_demo.login)
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")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_publisher.ready',
login=user_demo.login)