[FIX] test_new_api,web: tests 9.0 adjustments

Rev e37ba61 forward-ported 8.0 revision f02b230 from PR #12379.
This patch introduces extra tests and views for o2m onchange behavior,
including new fields in the test models.

In 9.0 a new convert_to_onchange() mechanism had been
introduced at 9f81c6d

The combination of both requires some adaptation to the
expected results of the new tests and adaptation of existing tests.

The test models in `test_new_api` have an implicit depencies between
models which cannot be express on ORM:
    messages depends on participants of their discussion.

So, when editing a discussion, the field `participants` should be
processed before field `messages`. This is not always done because
field processing order depends of the iteration order of a `dict` (which
is undefined in python).
The testing tour `widget_x2many` worked by chance until now.
Adapt the tour to save the participants before the messages.
This commit is contained in:
Christophe Simonis
2016-06-21 11:23:18 +02:00
parent 6101b856f0
commit 0a2317d303
2 changed files with 55 additions and 11 deletions
+37 -7
View File
@@ -69,7 +69,42 @@ Tour.register({
waitFor: '.tab-pane:last tr:has(.oe_list_field_cell):not(:has(.oe_list_record_selector)):contains(user_test)',
},
// add ourself as participant
{
title: "change tab to Participants",
element: '[data-toggle="tab"]:contains(Participants)'
},
{
title: "click to add participants",
element: '.tab-pane:eq(2).active .oe_form_field_x2many_list_row_add a'
},
{
title: "select Admin",
element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]'
},
{
title: "save selected participants",
waitFor: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]:propChecked',
element: '.o_selectcreatepopup_search_select'
},
// save
{
title: "save discussion",
waitFor: '.oe_form_field_many2many tbody tr td.oe_list_field_char:containsExact(Administrator)',
element: 'button.oe_form_button_save'
},
// edit
{
title: "edit discussion",
element: 'button.oe_form_button_edit'
},
// add message a
{
title: "Select First Tab",
element: 'a[role=tab]:first',
},
{
title: "create new message a",
element: '.oe_form_field_x2many_list_row_add:first a'
@@ -167,15 +202,10 @@ Tour.register({
},
{
title: "click to add participants",
element: '.tab-pane:eq(1).active .oe_form_field_x2many_list_row_add a'
},
{
title: "select Admin",
element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]'
element: '.tab-pane:eq(2).active .oe_form_field_x2many_list_row_add a'
},
{
title: "select Demo User",
waitFor: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Administrator)) .oe_list_record_selector input[type="checkbox"]:propChecked',
element: '.modal .oe_list_content tr:has(td[data-field="name"]:containsExact(Demo User)) .oe_list_record_selector input[type="checkbox"]'
},
{
@@ -214,7 +244,7 @@ Tour.register({
element: 'button.oe_form_button_edit'
},
{
title: "change tab to Participants",
title: "change tab to Messages",
waitFor: '.oe_form_editable',
element: '[data-toggle="tab"]:contains(Messages)'
},
@@ -89,7 +89,7 @@ class TestOnChange(common.TransactionCase):
self.assertEqual(field_onchange.get('messages'), '1')
self.assertItemsEqual(
strip_prefix('messages.', field_onchange),
['author', 'body', 'name', 'size'],
['author', 'body', 'name', 'size', 'important'],
)
# modify discussion name
@@ -105,6 +105,7 @@ class TestOnChange(common.TransactionCase):
'body': BODY,
'author': USER.id,
'size': len(BODY),
'important': False,
}),
],
}
@@ -118,12 +119,14 @@ class TestOnChange(common.TransactionCase):
'body': message.body,
'author': message.author.name_get()[0],
'size': message.size,
'important': message.important,
}),
(0, 0, {
'name': "[%s] %s" % ("Foo", USER.name),
'body': BODY,
'author': USER.name_get()[0],
'size': len(BODY),
'important': False,
}),
])
@@ -248,6 +251,7 @@ class TestOnChange(common.TransactionCase):
'body': BODY,
'author': USER.id,
'important': False,
'email_to': demo.email,
})
# check if server-side cache is working correctly
@@ -276,8 +280,18 @@ class TestOnChange(common.TransactionCase):
# When one2many domain contains non-computed field, things are ok
self.assertEqual(result['value']['important_messages'],
[(1, email.message.id, {'name': u'[Foo Bar] %s' % USER.name})])
[(5,)] + [(4, msg.id) for msg in discussion.important_messages])
# But here with commit 5676d81, we get value of: [(2, email.id)]
self.assertEqual(result['value']['important_emails'],
[(1, email.id, {'name': u'[Foo Bar] %s' % USER.name})])
self.assertEqual(
result['value']['important_emails'],
[(5,),
(1, email.id, {
'name': u'[Foo Bar] %s' % USER.name,
'body': email.body,
'author': USER.name_get()[0],
'important': True,
'email_to': demo.email,
'size': email.size,
})]
)