slides_certification_member.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. odoo.define('test_website_slides_full.tour.slide.certification.member', function (require) {
  2. "use strict";
  3. var tour = require('web_tour.tour');
  4. const tourUtils = require('website_sale.tour_utils');
  5. /**
  6. * The purpose of this tour is to check the whole certification flow:
  7. *
  8. * -> student (= demo user) checks 'on payment' course content
  9. * -> clicks on "buy course"
  10. * -> is redirected to webshop on the product page
  11. * -> buys the course
  12. * -> fails 3 times, exhausting their attempts
  13. * -> is removed to the members of the course
  14. * -> buys the course again
  15. * -> succeeds the certification
  16. * -> has the course marked as completed
  17. * -> has the certification in their user profile
  18. *
  19. */
  20. var initTourSteps = [{
  21. content: 'eLearning: go to certification course',
  22. trigger: 'a:contains("DIY Furniture - TEST")'
  23. }, {
  24. content: 'eLearning: does not have access to certification',
  25. trigger: '.o_wslides_course_main',
  26. run: function () {
  27. // check that user doesn't have access to course content
  28. if ($('.o_wslides_slides_list_slide .o_wslides_js_slides_list_slide_link').length === 0) {
  29. $('.o_wslides_course_main').addClass('empty-content-success');
  30. }
  31. }
  32. }, {
  33. content: 'eLearning: previous step check',
  34. trigger: '.o_wslides_course_main.empty-content-success',
  35. run: function () {} // check that previous step succeeded
  36. }];
  37. var buyCertificationSteps = [{
  38. content: 'eLearning: try to buy course',
  39. trigger: 'a:contains("Add to Cart")'
  40. },
  41. tourUtils.goToCart(),
  42. {
  43. content: 'eCommerce: Process Checkout',
  44. trigger: 'a:contains("Process Checkout")'
  45. }, {
  46. content: 'eCommerce: select Test payment provider',
  47. trigger: '.o_payment_option_card:contains("Demo")'
  48. }, {
  49. content: 'eCommerce: add card number',
  50. trigger: 'input[name="customer_input"]',
  51. run: 'text 4242424242424242'
  52. }, {
  53. content: 'eCommerce: pay',
  54. trigger: 'button[name="o_payment_submit_button"]'
  55. }, {
  56. content: 'eCommerce: check that the payment is successful',
  57. trigger: '.oe_website_sale_tx_status:contains("Your payment has been successfully processed.")',
  58. run: function () {}
  59. }, {
  60. content: 'eCommerce: go back to e-learning home page',
  61. trigger: '.nav-link:contains("Courses")'
  62. }, {
  63. content: 'eLearning: go into bought course',
  64. trigger: 'a:contains("DIY Furniture")'
  65. }, {
  66. content: 'eLearning: user should be enrolled',
  67. trigger: '.o_wslides_js_course_join:contains("You\'re enrolled")',
  68. run: function () {}
  69. }, {
  70. content: 'eLearning: start course',
  71. trigger: '.o_wslides_js_slides_list_slide_link'
  72. }];
  73. var failCertificationSteps = [{
  74. content: 'eLearning: start certification',
  75. trigger: 'button:contains("Start Certification")'
  76. }, { // Question: What type of wood is the best for furniture?
  77. content: 'Survey: selecting answer "Fir"',
  78. trigger: 'div.js_question-wrapper:contains("What type of wood is the best for furniture") label:contains("Fir")'
  79. }, { // Question: Select all the furniture shown in the video
  80. content: 'Survey: ticking answer "Table"',
  81. trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Table")'
  82. }, {
  83. content: 'Survey: ticking answer "Bed"',
  84. trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Bed")'
  85. }, {
  86. content: 'Survey: submitting the certification with wrong answers',
  87. trigger: 'button:contains("Submit")'
  88. }];
  89. var retrySteps = [{
  90. content: 'Survey: retry certification',
  91. trigger: 'a:contains("Retry")'
  92. }];
  93. var succeedCertificationSteps = [{
  94. content: 'eLearning: start certification',
  95. trigger: 'button:contains("Start Certification")'
  96. }, { // Question: What type of wood is the best for furniture?
  97. content: 'Survey: selecting answer "Oak"',
  98. trigger: 'div.js_question-wrapper:contains("What type of wood is the best for furniture") label:contains("Oak")',
  99. }, { // Question: Select all the furniture shown in the video
  100. content: 'Survey: ticking answer "Chair"',
  101. trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Chair")'
  102. }, {
  103. content: 'Survey: ticking answer "Shelve"',
  104. trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Shelve")'
  105. }, {
  106. content: 'Survey: ticking answer "Desk"',
  107. trigger: 'div.js_question-wrapper:contains("Select all the furniture shown in the video") label:contains("Desk")'
  108. }, {
  109. content: 'Survey: submitting the certification with correct answers',
  110. trigger: 'button:contains("Submit")'
  111. }];
  112. var certificationCompletionSteps = [{
  113. content: 'Survey: check certification successful',
  114. trigger: 'div:contains("Congratulations, you have passed the test")',
  115. run: function () {}
  116. }, { // Sharing the certification
  117. trigger: 'a:contains("Share your certification")'
  118. }, {
  119. trigger: '.oe_slide_js_share_email input',
  120. run: 'text friend@example.com'
  121. }, {
  122. trigger: '.oe_slide_js_share_email button',
  123. }, {
  124. trigger: '.oe_slide_js_share_email .alert:not(.d-none):contains("Sharing is caring")',
  125. run: function () {} // check email has been sent
  126. }, {
  127. trigger: 'button.btn-close', // close sharing modal
  128. }, {
  129. content: 'Survey: back to course home page',
  130. trigger: 'a:contains("Go back to course")'
  131. }, {
  132. content: 'eLearning: back to e-learning home page',
  133. trigger: '.nav-link:contains("Courses")'
  134. }, {
  135. content: 'eLearning: course should be completed',
  136. trigger: '.o_wslides_course_card:contains("DIY Furniture") .rounded-pill:contains("Completed")',
  137. run: function () {}
  138. }];
  139. var profileSteps = [{
  140. content: 'eLearning: access user profile',
  141. trigger: '.o_wslides_home_aside_loggedin a:contains("View")'
  142. }, {
  143. content: 'eLearning: check that the user profile certifications include the new certification',
  144. trigger: '.o_wprofile_slides_course_card_body:contains("Furniture Creation Certification")',
  145. run: function () {}
  146. }];
  147. tour.register('certification_member', {
  148. url: '/slides',
  149. test: true
  150. }, [].concat(
  151. initTourSteps,
  152. buyCertificationSteps,
  153. failCertificationSteps,
  154. retrySteps,
  155. failCertificationSteps,
  156. retrySteps,
  157. failCertificationSteps,
  158. [{trigger: 'a:contains("Go back to course")'}],
  159. buyCertificationSteps,
  160. succeedCertificationSteps,
  161. certificationCompletionSteps,
  162. profileSteps
  163. )
  164. );
  165. });