[IMP] survey: Adapt tests to work with/without demo data

This commit is contained in:
Yannick Tivisse
2019-11-05 16:18:10 +01:00
parent 39a19ff54e
commit 3c90d09be3
8 changed files with 424 additions and 36 deletions
@@ -82,7 +82,7 @@ var lastSteps = [{
tour.register('test_certification_failure', {
test: true,
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8ddb95ac'
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8daaaaac'
}, [].concat(failSteps, retrySteps, failSteps, lastSteps));
});
@@ -5,7 +5,7 @@ var tour = require('web_tour.tour');
tour.register('test_certification_success', {
test: true,
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8ddb95ac'
url: '/survey/start/4ead4bc8-b8f2-4760-a682-1fde8daaaaac'
},
[{ // Page-1
content: "Clicking on Start Certification",
+1 -1
View File
@@ -5,7 +5,7 @@ var tour = require('web_tour.tour');
tour.register('test_survey', {
test: true,
url: '/survey/start/b137640d-14d4-4748-9ef6-344ca256531e',
url: '/survey/start/b137640d-14d4-4748-9ef6-344caaaaaae',
}, [
// Page-1
{
@@ -5,7 +5,7 @@ var tour = require('web_tour.tour');
tour.register('test_survey_prefill', {
test: true,
url: '/survey/start/b137640d-14d4-4748-9ef6-344ca256531e'
url: '/survey/start/b137640d-14d4-4748-9ef6-344caaaaaae'
},
[{ // Page-1
trigger: 'a.btn.btn-primary.btn-lg:contains("Start Survey")',
@@ -17,7 +17,10 @@ tour.register('test_survey_prefill', {
run: 'text 05/05/1980',
}, { // Question: How frequently do you buy products online ?
trigger: 'div.js_question-wrapper:contains("How frequently do you buy products online ?") select',
run: 'text 2', // value 2 = 'Once a week'
run: function() {
var optionID = $('option:contains("Once a week")').val();
$('div.js_question-wrapper:contains("How frequently do you buy products online ?") select').val(optionID);
},
}, { // Question: How many times did you order products on our website ?
trigger: 'div.js_question-wrapper:contains("How many times did you order products on our website ?") input',
run: 'text 42',
+2 -1
View File
@@ -8,6 +8,7 @@ from . import test_certification_flow
from . import test_survey_invite
from . import test_survey_security
from . import test_survey_randomize
from . import test_survey_ui
from . import test_survey_ui_certification
from . import test_survey_ui_feedback
from . import test_survey_compute_pages_questions
from . import test_certification_badge
-30
View File
@@ -1,30 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo.tests
@odoo.tests.common.tagged('post_install','-at_install')
class TestUi(odoo.tests.HttpCase):
def test_01_admin_survey_tour(self):
access_token = self.env.ref('survey.survey_feedback').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey', login="admin")
def test_02_demo_survey_tour(self):
access_token = self.env.ref('survey.survey_feedback').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey', login="demo")
def test_03_public_survey_tour(self):
access_token = self.env.ref('survey.survey_feedback').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey')
def test_04_certification_success_tour(self):
access_token = self.env.ref('survey.vendor_certification').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_certification_success', login="demo")
def test_05_certification_failure_tour(self):
access_token = self.env.ref('survey.vendor_certification').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_certification_failure', login="demo")
def test_06_survey_prefill(self):
access_token = self.env.ref('survey.survey_feedback').access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey_prefill')
@@ -0,0 +1,245 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo.tests
from odoo.addons.base.tests.common import HttpCaseWithUserDemo
@odoo.tests.common.tagged('post_install', '-at_install')
class TestUiCertification(HttpCaseWithUserDemo):
def setUp(self):
super(TestUiCertification, self).setUp()
self.survey_certification = self.env['survey.survey'].create({
'title': 'MyCompany Vendor Certification',
'access_token': '4ead4bc8-b8f2-4760-a682-1fde8daaaaac',
'state': 'open',
'access_mode': 'public',
'users_can_go_back': True,
'users_login_required': True,
'scoring_type': 'scoring_with_answers',
'certificate': True,
'certification_mail_template_id': self.env.ref('survey.mail_template_certification').id,
'is_time_limited': 'limited',
'time_limit': 10.0,
'is_attempts_limited': True,
'attempts_limit': 2,
'description': """<p>Test your vendor skills!.</p>""",
'thank_you_message': """<p></p>""",
'question_and_page_ids': [
(0, 0, {
'title': 'Products',
'sequence': 1,
'is_page': True,
'question_type': False,
'description': '<p>Test your knowledge of your products!</p>',
}), (0, 0, {
'title': 'Do we sell Acoustic Bloc Screens?',
'sequence': 2,
'question_type': 'simple_choice',
'display_mode': 'dropdown',
'constr_mandatory': True,
'labels_ids': [
(0, 0, {
'value': 'No',
'sequence': 1,
}), (0, 0, {
'value': 'Yes',
'sequence': 2,
'is_correct': True,
'answer_score': 2,
})
],
}), (0, 0, {
'title': 'Select all the existing products',
'sequence': 3,
'question_type': 'multiple_choice',
'column_nb': '4',
'labels_ids': [
(0, 0, {
'value': 'Chair floor protection',
'sequence': 1,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Fanta',
'sequence': 2,
'answer_score': -1,
}), (0, 0, {
'value': 'Conference chair',
'sequence': 3,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Drawer',
'sequence': 4,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Customizable Lamp',
'sequence': 5,
'answer_score': -1,
})
]
}), (0, 0, {
'title': 'Select all the available customizations for our Customizable Desk',
'sequence': 4,
'question_type': 'multiple_choice',
'column_nb': '4',
'labels_ids': [
(0, 0, {
'value': 'Color',
'sequence': 1,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Height',
'sequence': 2,
'answer_score': -1,
}), (0, 0, {
'value': 'Width',
'sequence': 3,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Legs',
'sequence': 4,
'is_correct': True,
'answer_score': 1,
}), (0, 0, {
'value': 'Number of drawers',
'sequence': 5,
'answer_score': -1,
})
]
}), (0, 0, {
'title': 'How many versions of the Corner Desk do we have?',
'sequence': 5,
'question_type': 'simple_choice',
'display_mode': 'dropdown',
'constr_mandatory': True,
'labels_ids': [
(0, 0, {
'value': 1,
'sequence': 1,
}), (0, 0, {
'value': 2,
'sequence': 2,
'is_correct': True,
'answer_score': 2,
}), (0, 0, {
'value': 3,
'sequence': 3,
}), (0, 0, {
'value': 4,
'sequence': 4,
})
]
}), (0, 0, {
'title': 'Do you think we have missing products in our catalog? (not rated)',
'sequence': 6,
'question_type': 'free_text',
}), (0, 0, {
'title': 'Prices',
'sequence': 7,
'is_page': True,
'question_type': False,
'description': """<p>Test your knowledge of our prices.</p>""",
}), (0, 0, {
'title': 'How much do we sell our Cable Management Box?',
'sequence': 8,
'question_type': 'simple_choice',
'display_mode': 'dropdown',
'constr_mandatory': True,
'labels_ids': [
(0, 0, {
'value': '20$',
'sequence': 1,
}), (0, 0, {
'value': '50$',
'sequence': 2,
}), (0, 0, {
'value': '80$',
'sequence': 3,
}), (0, 0, {
'value': '100$',
'sequence': 4,
'is_correct': True,
'answer_score': 2,
}), (0, 0, {
'value': '200$',
'sequence': 5,
}), (0, 0, {
'value': '300$',
'sequence': 6,
})
]
}), (0, 0, {
'title': 'Select all the the products that sell for 100$ or more',
'sequence': 9,
'question_type': 'multiple_choice',
'column_nb': '2',
'labels_ids': [
(0, 0, {
'value': 'Corner Desk Right Sit',
'sequence': 1,
'answer_score': 1,
'is_correct': True,
}), (0, 0, {
'value': 'Desk Combination',
'sequence': 2,
'answer_score': 1,
'is_correct': True,
}), (0, 0, {
'value': 'Cabinet with Doors',
'sequence': 3,
'answer_score': -1,
}), (0, 0, {
'value': 'Large Desk',
'sequence': 4,
'answer_score': 1,
'is_correct': True,
}), (0, 0, {
'value': 'Letter Tray',
'sequence': 5,
'answer_score': -1,
}), (0, 0, {
'value': 'Office Chair Black',
'sequence': 6,
'answer_score': -1,
}),
]
}), (0, 0, {
'title': 'What do you think about our prices (not rated)?',
'sequence': 10,
'question_type': 'simple_choice',
'display_mode': 'dropdown',
'constr_mandatory': True,
'labels_ids': [
(0, 0, {
'value': 'Very underpriced',
'sequence': 1,
}), (0, 0, {
'value': 'Underpriced',
'sequence': 2,
}), (0, 0, {
'value': 'Correctly priced',
'sequence': 3,
}), (0, 0, {
'value': 'A little bit overpriced',
'sequence': 4,
}), (0, 0, {
'value': 'A lot overpriced',
'sequence': 5,
})
]
})
]
})
def test_04_certification_success_tour(self):
access_token = self.survey_certification.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_certification_success', login="demo")
def test_05_certification_failure_tour(self):
access_token = self.survey_certification.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_certification_failure', login="demo")
@@ -0,0 +1,169 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo.tests
from odoo.addons.base.tests.common import HttpCaseWithUserDemo
@odoo.tests.common.tagged('post_install', '-at_install')
class TestUiFeedback(HttpCaseWithUserDemo):
def setUp(self):
super(TestUiFeedback, self).setUp()
self.survey_feedback = self.env['survey.survey'].create({
'title': 'User Feedback Form',
'access_token': 'b137640d-14d4-4748-9ef6-344caaaaaae',
'state': 'open',
'access_mode': 'public',
'users_can_go_back': True,
'questions_layout': 'page_per_section',
'description': """<p>This survey allows you to give a feedback about your experience with our eCommerce solution.
Filling it helps us improving your experience.</p></field>""",
'thank_you_message': """&lt;p&gt;&lt;/p&gt;""",
'question_and_page_ids': [
(0, 0, {
'title': 'General information',
'sequence': 1,
'question_type': False,
'is_page': True,
'description': """<p>This section is about general informations about you. Answering them helps qualifying your answers.</p>""",
}), (0, 0, {
'title': 'Where do you live ?',
'sequence': 2,
'question_type': 'textbox',
'constr_mandatory': False,
}), (0, 0, {
'title': 'When is your date of birth ?',
'sequence': 3,
'question_type': 'date',
'description': False,
}), (0, 0, {
'title': 'How frequently do you buy products online ?',
'sequence': 4,
'question_type': 'simple_choice',
'display_mode': 'dropdown',
'comments_allowed': True,
'comment_count_as_answer': True,
'constr_mandatory': True,
'labels_ids': [
(0, 0, {
'value': 'Once a day',
'sequence': 1,
}), (0, 0, {
'value': 'Once a week',
'sequence': 2,
}), (0, 0, {
'value': 'Once a month',
'sequence': 3,
}), (0, 0, {
'value': 'Once a year',
'sequence': 4,
}), (0, 0, {
'value': 'Other (answer in comment)',
'sequence': 5,
})],
}), (0, 0, {
'title': 'How many times did you order products on our website ?',
'sequence': 5,
'question_type': 'numerical_box',
'constr_mandatory': True,
}), (0, 0, {
'title': 'About our ecommerce',
'sequence': 6,
'is_page': True,
'question_type': False,
'description': """<p>This section is about our eCommerce experience itself.</p>""",
}), (0, 0, {
'title': 'Which of the following words would you use to describe our products ?',
'sequence': 7,
'question_type': 'multiple_choice',
'constr_mandatory': True,
'comments_allowed': True,
'comment_count_as_answer': False,
'labels_ids': [
(0, 0, {
'value': 'High quality',
'sequence': 1,
}), (0, 0, {
'value': 'Useful',
'sequence': 2,
}), (0, 0, {
'value': 'Unique',
'sequence': 3,
}), (0, 0, {
'value': 'Good value for money',
'sequence': 4,
}), (0, 0, {
'value': 'Overpriced',
'sequence': 5,
}), (0, 0, {
'value': 'Impractical',
'sequence': 6,
}), (0, 0, {
'value': 'Ineffective',
'sequence': 7,
}), (0, 0, {
'value': 'Poor quality',
'sequence': 8,
}), (0, 0, {
'value': 'Other',
'sequence': 9,
})],
}), (0, 0, {
'title': 'What do your think about our new eCommerce ?',
'sequence': 8,
'question_type': 'matrix',
'matrix_subtype': 'multiple',
'constr_mandatory': True,
'labels_ids': [(0, 0, {
'value': 'Totally disagree',
'sequence': 1
}), (0, 0, {
'value': 'Disagree',
'sequence': 2,
}), (0, 0, {
'value': 'Agree',
'sequence': 3,
}), (0, 0, {
'value': 'Totally agree',
'sequence': 4,
})],
'labels_ids_2': [(0, 0, {
'value': 'The new layout and design is fresh and up-to-date',
'sequence': 1,
}), (0, 0, {
'value': 'It is easy to find the product that I want',
'sequence': 2,
}), (0, 0, {
'value': 'The tool to compare the products is useful to make a choice',
'sequence': 3,
}), (0, 0, {
'value': 'The checkout process is clear and secure',
'sequence': 4,
}), (0, 0, {
'value': 'I have added products to my wishlist',
'sequence': 5,
})],
}), (0, 0, {
'title': 'Do you have any other comments, questions, or concerns ?',
'sequence': 9,
'question_type': 'free_text',
'constr_mandatory': False,
})
],
})
def test_01_admin_survey_tour(self):
access_token = self.survey_feedback.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey', login="admin")
def test_02_demo_survey_tour(self):
access_token = self.survey_feedback.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey', login="demo")
def test_03_public_survey_tour(self):
access_token = self.survey_feedback.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey')
def test_06_survey_prefill(self):
access_token = self.survey_feedback.access_token
self.start_tour("/survey/start/%s" % access_token, 'test_survey_prefill')