From e783844f5b66acfc298a98f331bf432420fdbbf7 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Tue, 23 May 2017 11:37:39 +0200 Subject: [PATCH] [FIX] web: fix missing tests for discard buttons update Previously, the buttons were not updated properly after discarding from an editable list view. The user was stuck with "Discard" even though there was nothing to discard anymore, and he could not create a new record either since the "Create" button was invisible. This was fixed by 3aad756. I originally did a different fix which has since been rendered useless, but the tests I wrote are still meaningful since they are testing a different case than the commit which fixed the issue. --- addons/web/static/tests/views/list_tests.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 4346e3c2b75..c56c3ce1284 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -1432,7 +1432,7 @@ QUnit.module('Views', { }); QUnit.test('edition: create new line, then discard', function (assert) { - assert.expect(2); + assert.expect(8); var list = createView({ View: ListView, @@ -1443,10 +1443,22 @@ QUnit.module('Views', { assert.strictEqual(list.$('tr.o_data_row').length, 4, "should have 4 records"); + assert.strictEqual(list.$buttons.find('.o_list_button_add:visible').length, 1, + "create button should be visible"); + assert.strictEqual(list.$buttons.find('.o_list_button_discard:visible').length, 0, + "discard button should be hidden"); list.$buttons.find('.o_list_button_add').click(); + assert.strictEqual(list.$buttons.find('.o_list_button_add:visible').length, 0, + "create button should be hidden"); + assert.strictEqual(list.$buttons.find('.o_list_button_discard:visible').length, 1, + "discard button should be visible"); list.$buttons.find('.o_list_button_discard').click(); assert.strictEqual(list.$('tr.o_data_row').length, 4, "should still have 4 records"); + assert.strictEqual(list.$buttons.find('.o_list_button_add:visible').length, 1, + "create button should be visible again"); + assert.strictEqual(list.$buttons.find('.o_list_button_discard:visible').length, 0, + "discard button should be hidden again"); list.destroy(); });