[IMP] website_event_questions: add test tour for event questions
This commit adds a test tour that will fill up two tickets with a few questions answers and then assert that the answers are correctly saved for each attendee. This will help ensuring that the new "free text question" feature works correctly, along with existing "suggestion question". LINKS PR #45497 Task ID 2189529
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
'version': '1.1',
|
||||
'depends': ['website_event'],
|
||||
'data': [
|
||||
'views/assets.xml',
|
||||
'views/event_views.xml',
|
||||
'views/event_templates.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
odoo.define('website_event_questions.tour_test_tickets_questions', function (require) {
|
||||
'use strict';
|
||||
|
||||
var tour = require('web_tour.tour');
|
||||
tour.register('test_tickets_questions', {
|
||||
test: true,
|
||||
url: '/event'
|
||||
}, [{
|
||||
content: "Click on the Design Fair event",
|
||||
trigger: 'article:contains("Design Fair New York")',
|
||||
}, {
|
||||
content: "Click on Buy tickets button",
|
||||
trigger: 'a:contains("Tickets")',
|
||||
}, {
|
||||
content: "Select 2 'Free' tickets to buy",
|
||||
trigger: 'div.row:contains("Free") select.custom-select',
|
||||
run: 'text 2'
|
||||
}, {
|
||||
content: "Click on Register tickets button",
|
||||
trigger: 'button:contains("Register")',
|
||||
run: 'click'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #1").modal-body input[name*="name"]',
|
||||
run: 'text Attendee A'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #1").modal-body input[name*="email"]',
|
||||
run: 'text attendee-a@gmail.com'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #1").modal-body input[name*="phone"]',
|
||||
run: 'text +32499123456'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #1").modal-body select[name*="question_answer"]',
|
||||
run: 'text Vegetarian'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #1").modal-body textarea[name*="question_answer"]',
|
||||
run: 'text Fish and Nuts'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #2").modal-body input[name*="name"]',
|
||||
run: 'text Attendee B'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #2").modal-body input[name*="email"]',
|
||||
run: 'text attendee-b@gmail.com'
|
||||
}, {
|
||||
trigger: 'div:contains("Ticket #2").modal-body select[name*="question_answer"]',
|
||||
run: 'text Pastafarian'
|
||||
}, {
|
||||
trigger: 'div:contains("General questions").modal-body select[name*="question_answer"]',
|
||||
run: 'text A friend'
|
||||
}, {
|
||||
trigger: 'button:contains("Continue")',
|
||||
run: 'click'
|
||||
}]);
|
||||
|
||||
});
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
from . import common
|
||||
from . import test_event_internals
|
||||
from . import test_event_ui
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import fields, tests
|
||||
|
||||
|
||||
@tests.tagged('post_install', '-at_install')
|
||||
class TestUi(tests.HttpCase):
|
||||
|
||||
def test_01_tickets_questions(self):
|
||||
""" Will execute the tour that fills up two tickets with a few questions answers
|
||||
and then assert that the answers are correctly saved for each attendee. """
|
||||
|
||||
self.design_fair_event = self.env['event.event'].create({
|
||||
'name': 'Design Fair New York',
|
||||
'date_begin': fields.Datetime.now() - relativedelta(days=15),
|
||||
'date_end': fields.Datetime.now() + relativedelta(days=15),
|
||||
'event_ticket_ids': [(0, 0, {
|
||||
'name': 'Free',
|
||||
'start_sale_date': fields.Datetime.now() - relativedelta(days=15)
|
||||
}), (0, 0, {
|
||||
'name': 'Other',
|
||||
'start_sale_date': fields.Datetime.now() - relativedelta(days=15)
|
||||
})],
|
||||
'website_published': True,
|
||||
'question_ids': [(0, 0, {
|
||||
'title': 'Meal Type',
|
||||
'question_type': 'simple_choice',
|
||||
'answer_ids': [
|
||||
(0, 0, {'name': 'Mixed'}),
|
||||
(0, 0, {'name': 'Vegetarian'}),
|
||||
(0, 0, {'name': 'Pastafarian'})
|
||||
]
|
||||
}), (0, 0, {
|
||||
'title': 'Allergies',
|
||||
'question_type': 'text_box'
|
||||
}), (0, 0, {
|
||||
'title': 'How did you learn about this event?',
|
||||
'question_type': 'simple_choice',
|
||||
'once_per_order': True,
|
||||
'answer_ids': [
|
||||
(0, 0, {'name': 'Our website'}),
|
||||
(0, 0, {'name': 'Commercials'}),
|
||||
(0, 0, {'name': 'A friend'})
|
||||
]
|
||||
})]
|
||||
})
|
||||
|
||||
self.start_tour("/", 'test_tickets_questions', login="portal")
|
||||
|
||||
registrations = self.env['event.registration'].search([
|
||||
('email', 'in', ['attendee-a@gmail.com', 'attendee-b@gmail.com'])
|
||||
])
|
||||
self.assertEqual(len(registrations), 2)
|
||||
first_registration = registrations.filtered(lambda reg: reg.email == 'attendee-a@gmail.com')
|
||||
second_registration = registrations.filtered(lambda reg: reg.email == 'attendee-b@gmail.com')
|
||||
self.assertEqual(first_registration.name, 'Attendee A')
|
||||
self.assertEqual(first_registration.phone, '+32499123456')
|
||||
self.assertEqual(second_registration.name, 'Attendee B')
|
||||
|
||||
event_questions = registrations.mapped('event_id.question_ids')
|
||||
self.assertEqual(len(event_questions), 3)
|
||||
|
||||
first_registration_answers = first_registration.registration_answer_ids
|
||||
self.assertEqual(len(first_registration_answers), 3)
|
||||
|
||||
self.assertEqual(first_registration_answers.filtered(
|
||||
lambda answer: answer.question_id.title == 'Meal Type'
|
||||
).value_answer_id.name, 'Vegetarian')
|
||||
|
||||
self.assertEqual(first_registration_answers.filtered(
|
||||
lambda answer: answer.question_id.title == 'Allergies'
|
||||
).value_text_box, 'Fish and Nuts')
|
||||
|
||||
self.assertEqual(first_registration_answers.filtered(
|
||||
lambda answer: answer.question_id.title == 'How did you learn about this event?'
|
||||
).value_answer_id.name, 'A friend')
|
||||
|
||||
second_registration_answers = second_registration.registration_answer_ids
|
||||
self.assertEqual(len(second_registration_answers), 2)
|
||||
|
||||
self.assertEqual(second_registration_answers.filtered(
|
||||
lambda answer: answer.question_id.title == 'Meal Type'
|
||||
).value_answer_id.name, 'Pastafarian')
|
||||
|
||||
self.assertEqual(first_registration_answers.filtered(
|
||||
lambda answer: answer.question_id.title == 'How did you learn about this event?'
|
||||
).value_answer_id.name, 'A friend')
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<template id="assets_tests" name="Website Event Questions Assets Tests" inherit_id="web.assets_tests">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_event_questions/static/tests/tours/tickets_questions.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user