diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/test_website_slides_full | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/test_website_slides_full')
7 files changed, 404 insertions, 0 deletions
diff --git a/addons/test_website_slides_full/__init__.py b/addons/test_website_slides_full/__init__.py new file mode 100644 index 00000000..67dee8c6 --- /dev/null +++ b/addons/test_website_slides_full/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. diff --git a/addons/test_website_slides_full/__manifest__.py b/addons/test_website_slides_full/__manifest__.py new file mode 100644 index 00000000..e59c86fd --- /dev/null +++ b/addons/test_website_slides_full/__manifest__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': 'Test Full eLearning Flow', + 'version': '1.0', + 'category': 'Hidden/Tests', + 'description': """ +This module will test the main certification flow of Odoo. +It will install the e-learning, survey and e-commerce apps and make a complete +certification flow including purchase, certification, failure and success. +""", + 'depends': [ + 'website_sale_product_configurator', + 'website_sale_slides', + 'website_slides_forum', + 'website_slides_survey', + 'payment_test' + ], + 'demo': [ + 'data/product_demo.xml', + ], + 'data': [ + 'views/assets.xml', + ], + 'installable': True, + 'license': 'LGPL-3', +} diff --git a/addons/test_website_slides_full/data/product_demo.xml b/addons/test_website_slides_full/data/product_demo.xml new file mode 100644 index 00000000..8673b4f9 --- /dev/null +++ b/addons/test_website_slides_full/data/product_demo.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo><data noupdate="1"> + <record id="product_course_channel_1_option_0" model="product.product"> + <field name="name">Water can</field> + <field name="standard_price">12.0</field> + <field name="list_price">12.0</field> + <field name="type">consu</field> + <field name="is_published" eval="True"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/water_can.jpg"/> + </record> + + <record id="product_course_channel_1_option_1" model="product.product"> + <field name="name">Flower pot</field> + <field name="standard_price">4.5</field> + <field name="list_price">4.5</field> + <field name="type">consu</field> + <field name="is_published" eval="True"/> + <field name="image_1920" type="base64" file="website_sale_slides/static/img/flower_pot.jpg"/> + </record> + + <record id="website_sale_slides.product_course_channel_1_product_template" model="product.template"> + <field name="optional_product_ids" eval="[ + (6, 0, [ref('test_website_slides_full.product_course_channel_1_option_0_product_template'), + ref('test_website_slides_full.product_course_channel_1_option_1_product_template')] + )]"/> + </record> +</data></odoo> diff --git a/addons/test_website_slides_full/tests/__init__.py b/addons/test_website_slides_full/tests/__init__.py new file mode 100644 index 00000000..5e6934d5 --- /dev/null +++ b/addons/test_website_slides_full/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_ui_wslides diff --git a/addons/test_website_slides_full/tests/test_ui_wslides.py b/addons/test_website_slides_full/tests/test_ui_wslides.py new file mode 100644 index 00000000..c3e999db --- /dev/null +++ b/addons/test_website_slides_full/tests/test_ui_wslides.py @@ -0,0 +1,163 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from dateutil.relativedelta import relativedelta +from odoo.fields import Datetime +from odoo import tests +from odoo.addons.website_slides.tests.test_ui_wslides import TestUICommon + +@tests.common.tagged('post_install', '-at_install') +class TestUi(TestUICommon): + + def test_course_certification_employee(self): + user_demo = self.user_demo + user_demo.flush() + # Avoid Billing/Shipping address page + user_demo.write({ + 'groups_id': [(5, 0), (4, self.env.ref('base.group_user').id)], + 'street': '215 Vine St', + 'city': 'Scranton', + 'zip': '18503', + 'country_id': self.env.ref('base.us').id, + 'state_id': self.env.ref('base.state_us_39').id, + 'phone': '+1 555-555-5555', + 'email': 'admin@yourcompany.example.com', + }) + + # Specify Accounting Data + cash_journal = self.env['account.journal'].create({'name': 'Cash - Test', 'type': 'cash', 'code': 'CASH - Test'}) + self.env['payment.acquirer'].search([('journal_id', '=', False)]).journal_id = cash_journal + a_recv = self.env['account.account'].create({ + 'code': 'X1012', + 'name': 'Debtors - (test)', + 'reconcile': True, + 'user_type_id': self.env.ref('account.data_account_type_receivable').id, + }) + a_pay = self.env['account.account'].create({ + 'code': 'X1111', + 'name': 'Creditors - (test)', + 'user_type_id': self.env.ref('account.data_account_type_payable').id, + 'reconcile': True, + }) + + Property = self.env['ir.property'] + Property._set_default('property_account_receivable_id', 'res.partner', a_recv, self.env.company) + Property._set_default('property_account_payable_id', 'res.partner', a_pay, self.env.company) + + product_course_channel_6 = self.env['product.product'].create({ + 'name': 'DIY Furniture Course', + 'list_price': 100.0, + 'type': 'service', + 'is_published': True, + }) + + furniture_survey = self.env['survey.survey'].create({ + 'title': 'Furniture Creation Certification', + 'access_token': '5632a4d7-48cf-aaaa-8c52-2174d58cf50b', + 'state': 'open', + 'access_mode': 'public', + 'users_can_go_back': True, + 'users_login_required': True, + 'scoring_type': 'scoring_with_answers', + 'certification': True, + 'certification_mail_template_id': self.env.ref('survey.mail_template_certification').id, + 'is_attempts_limited': True, + 'attempts_limit': 3, + 'description': "<p>Test your furniture knowledge!</p>", + 'question_and_page_ids': [ + (0, 0, { + 'title': 'Furniture', + 'sequence': 1, + 'is_page': True, + 'description': "<p>Test your furniture knowledge!</p>", + }), (0, 0, { + 'title': 'What type of wood is the best for furniture?', + 'sequence': 2, + 'question_type': 'simple_choice', + 'constr_mandatory': True, + 'suggested_answer_ids': [ + (0, 0, { + 'value': 'Fir', + 'sequence': 1, + }), (0, 0, { + 'value': 'Oak', + 'sequence': 2, + 'is_correct': True, + 'answer_score': 2.0, + }), (0, 0, { + 'value': 'Ash', + 'sequence': 3, + }), (0, 0, { + 'value': 'Beech', + 'sequence': 4, + }) + ] + }), (0, 0, { + 'title': 'Select all the furniture shown in the video', + 'sequence': 3, + 'question_type': 'multiple_choice', + 'column_nb': '4', + 'suggested_answer_ids': [ + (0, 0, { + 'value': 'Chair', + 'sequence': 1, + 'is_correct': True, + 'answer_score': 1.0, + }), (0, 0, { + 'value': 'Table', + 'sequence': 2, + 'answer_score': -1.0, + }), (0, 0, { + 'value': 'Desk', + 'sequence': 3, + 'is_correct': True, + 'answer_score': 1.0, + }), (0, 0, { + 'value': 'Shelve', + 'sequence': 4, + 'is_correct': True, + 'answer_score': 1.0, + }), (0, 0, { + 'value': 'Bed', + 'sequence': 5, + 'answer_score': -1.0, + }) + ] + }), (0, 0, { + 'title': 'What do you think about the content of the course? (not rated)', + 'sequence': 4, + 'question_type': 'text_box', + }) + ] + }) + + slide_channel_demo_6_furn3 = self.env['slide.channel'].create({ + 'name': 'DIY Furniture - TEST', + 'user_id': self.env.ref('base.user_admin').id, + 'enroll': 'payment', + 'product_id': product_course_channel_6.id, + 'channel_type': 'training', + 'allow_comment': True, + 'promote_strategy': 'most_voted', + 'is_published': True, + 'description': 'So much amazing certification.', + 'create_date': Datetime.now() - relativedelta(days=2), + 'slide_ids': [ + (0, 0, { + 'name': 'DIY Furniture Certification', + 'sequence': 1, + 'slide_type': 'certification', + 'category_id': False, + 'is_published': True, + 'is_preview': False, + 'description': "It's time to test your knowledge!", + 'survey_id': furniture_survey.id, + }) + ] + }) + + self.browser_js( + '/slides', + 'odoo.__DEBUG__.services["web_tour.tour"].run("certification_member")', + 'odoo.__DEBUG__.services["web_tour.tour"].tours.certification_member.ready', + login=user_demo.login) diff --git a/addons/test_website_slides_full/tests/tours/slides_certification_member.js b/addons/test_website_slides_full/tests/tours/slides_certification_member.js new file mode 100644 index 00000000..eec5f0b7 --- /dev/null +++ b/addons/test_website_slides_full/tests/tours/slides_certification_member.js @@ -0,0 +1,173 @@ +odoo.define('test_website_slides_full.tour.slide.certification.member', function (require) { +"use strict"; + +var tour = require('web_tour.tour'); + +/** + * The purpose of this tour is to check the whole certification flow: + * + * -> student (= demo user) checks 'on payment' course content + * -> clicks on "buy course" + * -> is redirected to webshop on the product page + * -> buys the course + * -> fails 3 times, exhausting his attempts + * -> is removed to the members of the course + * -> buys the course again + * -> succeeds the certification + * -> has the course marked as completed + * -> has the certification in his user profile + * + */ + +var initTourSteps = [{ + content: 'eLearning: go to certification course', + trigger: 'a:contains("DIY Furniture - TEST")' +}, { + content: 'eLearning: does not have access to certification', + trigger: '.o_wslides_course_main', + run: function () { + // check that user doesn't have access to course content + if ($('.o_wslides_slides_list_slide .o_wslides_js_slides_list_slide_link').length === 0) { + $('.o_wslides_course_main').addClass('empty-content-success'); + } + } +}, { + content: 'eLearning: previous step check', + trigger: '.o_wslides_course_main.empty-content-success', + run: function () {} // check that previous step succeeded +}]; + +var buyCertificationSteps = [{ + content: 'eLearning: try to buy course', + trigger: 'a:contains("Add to Cart")' +}, { + content: 'eCommerce: Process Checkout', + trigger: 'a:contains("Process Checkout")' +}, { + content: 'eCommerce: select Test payment acquirer', + trigger: '.o_payment_acquirer_select:contains("Test")' +}, { + content: 'eCommerce: add card number', + trigger: 'input[name="cc_number"]', + run: 'text 4242424242424242' +}, { + content: 'eCommerce: add card holder name', + trigger: 'input[name="cc_holder_name"]', + run: 'text Marc Demo' +}, { + content: 'eCommerce: add card expiry date', + trigger: 'input[name="cc_expiry"]', + run: 'text 11 / 50' +}, { + content: 'eCommerce: add card cvc', + trigger: 'input[name="cvc"]', + run: 'text 999' +}, { + content: 'eCommerce: pay', + trigger: '#o_payment_form_pay' +}, { + content: 'eCommerce: check that the payment is successful', + trigger: '.oe_website_sale_tx_status:contains("Your payment has been successfully processed")', + run: function () {} +}, { + content: 'eCommerce: go back to e-learning home page', + trigger: '.nav-link:contains("Courses")' +}, { + content: 'eLearning: go into bought course', + trigger: 'a:contains("DIY Furniture")' +}, { + content: 'eLearning: user should be enrolled', + trigger: '.o_wslides_js_course_join:contains("You\'re enrolled")', + run: function () {} +}, { + content: 'eLearning: start course', + trigger: '.o_wslides_js_slides_list_slide_link' +}]; + +var failCertificationSteps = [{ + content: 'eLearning: start certification', + trigger: 'button:contains("Start Certification")' +}, { // Question: What type of wood is the best for furniture? + content: 'Survey: selecting answer "Fir"', + trigger: 'div.js_question-wrapper:contains("What type of wood is the best for furniture") label:contains("Fir")' +}, { // Question: Select all the furniture shown in the video + content: 'Survey: ticking answer "Table"', + trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Table")' +}, { + content: 'Survey: ticking answer "Bed"', + trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Bed")' +}, { + content: 'Survey: submitting the certification with wrong answers', + trigger: 'button:contains("Submit")' +}]; + +var retrySteps = [{ + content: 'Survey: retry certification', + trigger: 'a:contains("Retry")' +}]; + +var succeedCertificationSteps = [{ + content: 'eLearning: start certification', + trigger: 'button:contains("Start Certification")' +}, { // Question: What type of wood is the best for furniture? + content: 'Survey: selecting answer "Oak"', + trigger: 'div.js_question-wrapper:contains("What type of wood is the best for furniture") label:contains("Oak")', +}, { // Question: Select all the furniture shown in the video + content: 'Survey: ticking answer "Chair"', + trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Chair")' +}, { + content: 'Survey: ticking answer "Shelve"', + trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Shelve")' +}, { + content: 'Survey: ticking answer "Desk"', + trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Desk")' +}, { + content: 'Survey: submitting the certification with correct answers', + trigger: 'button:contains("Submit")' +}]; + +var certificationCompletionSteps = [{ + content: 'Survey: check certification successful', + trigger: 'div:contains("Congratulations, you have passed the test")', + run: function () {} +}, { + content: 'Survey: back to course home page', + trigger: 'a:contains("Go back to course")' +}, { + content: 'eLearning: back to e-learning home page', + trigger: '.nav-link:contains("Courses")' +}, { + content: 'eLearning: course should be completed', + trigger: '.o_wslides_course_card:contains("DIY Furniture") .badge-pill:contains("Completed")', + run: function () {} +}]; + +var profileSteps = [{ + content: 'eLearning: access user profile', + trigger: '.o_wslides_home_aside_loggedin a:contains("View")' +}, { + content: 'eLearning: check that the user profile certifications include the new certification', + trigger: '.o_wprofile_slides_course_card_body:contains("Furniture Creation Certification")', + run: function () {} +}]; + +tour.register('certification_member', { + url: '/slides', + test: true +}, [].concat( + initTourSteps, + buyCertificationSteps, + failCertificationSteps, + retrySteps, + failCertificationSteps, + retrySteps, + failCertificationSteps, + [{trigger: 'a:contains("Go back to course")'}], + buyCertificationSteps, + succeedCertificationSteps, + certificationCompletionSteps, + profileSteps + ) +); + +}); diff --git a/addons/test_website_slides_full/views/assets.xml b/addons/test_website_slides_full/views/assets.xml new file mode 100644 index 00000000..f73482d3 --- /dev/null +++ b/addons/test_website_slides_full/views/assets.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" ?> +<odoo><data> + <template id="assets_tests" inherit_id="web.assets_tests" name="Full Slides Tests Assets"> + <xpath expr="." position="inside"> + <script type="text/javascript" src="/test_website_slides_full/tests/tours/slides_certification_member.js"/> + </xpath> + </template> +</data></odoo> |
