Skip to content
Permalink
Browse files

regrouping some tests together (when and when not on last line)

  • Loading branch information...
svb-odoo committed Mar 15, 2019
1 parent 6e2bed6 commit 5f931f675236dcdcae071c4285bb066370cd0842
Showing with 47 additions and 46 deletions.
  1. +47 −46 addons/web/static/tests/views/list_tests.js
@@ -2950,30 +2950,8 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('navigation: moving down with keydown', async function (assert) {
assert.expect(3);

var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="bottom">' +
'<field name="foo"/>' +
'</tree>',
});

await testUtils.dom.click(list.$('td:contains(yop)'));
assert.hasClass(list.$('tr.o_data_row:eq(0)'),'o_selected_row',
"1st row should be selected");
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row input[name="foo"]'), 'down');
assert.hasClass(list.$('tr.o_data_row:eq(1)'),'o_selected_row',
"2nd row should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]')[0], document.activeElement, "foo should have focus");
list.destroy();
});

QUnit.test('navigation: moving down with keydown on last line (editable list bottom not one2many)', async function (assert) {
assert.expect(22);
QUnit.test('navigation: moving down with keydown (editable list bottom not one2many)', async function (assert) {
assert.expect(24);

this.data.foo.records.pop(); //4th record has no reference field set and we want to make the reference field required
this.data.foo.records.pop(); //3rd record has no many2many field set and we want to make the many2many field required
@@ -2999,10 +2977,17 @@ QUnit.module('Views', {
'</tree>',
});

await testUtils.dom.click(list.$('td:contains(-5)'));
await testUtils.dom.click(list.$('td:contains(9)'));
assert.hasClass(list.$('tr.o_data_row:eq(1)'),'o_selected_row',
"2nd row should be selected");
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row input[name="int_field"]'), 'down');
await concurrency.delay(0);
assert.hasClass(list.$('tr.o_data_row:eq(2)'),'o_selected_row',
"3rd row should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip", "actual line should have foo = 'blip'");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]')[0], document.activeElement,
"int_field should have focus");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip",
"actual line should have foo = 'blip'");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]').val(),"-5",
"actual line should have int_field = '-4'");
assert.strictEqual(list.$('tr.o_selected_row div[name="m2m"] span.o_badge_text').text(),"Value 1",
@@ -3019,26 +3004,39 @@ QUnit.module('Views', {
"the reference widget should have been marked required");
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row input[name="int_field"]'), 'down');
await concurrency.delay(0);
assert.hasClass(list.$('tr.o_data_row:eq(3)'),'o_selected_row',"4th row (newly created) should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]')[0], document.activeElement, "int_field should have focus");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip", "new line should have foo = blip");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]').val(),"0", "new line should have int_field = 0");
assert.strictEqual(list.$('tr.o_selected_row div[name="m2m"] span.o_badge_text').text(),"Value 1", "new line should have tag = 'Value 1'");
assert.hasClass(list.$('tr.o_data_row:eq(3)'),'o_selected_row',
"4th row (newly created) should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]')[0], document.activeElement,
"int_field should have focus");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip",
"new line should have foo = blip");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]').val(),"0",
"new line should have int_field = 0");
assert.strictEqual(list.$('tr.o_selected_row div[name="m2m"] span.o_badge_text').text(),"Value 1",
"new line should have tag = 'Value 1'");
//value of selected row difficult to obtain so we look at the previous row:
assert.strictEqual(list.$('tr.o_data_row:eq(2) td:eq(2)').text(),"Value 1", "previous line should have m2o = Value 1");
assert.strictEqual(list.$('tr.o_data_row:eq(2) td:eq(5)').text(),"USD", "previous line should have reference = USD");
assert.strictEqual(list.$('tr.o_data_row:eq(2) td:eq(2)').text(),"Value 1",
"previous line should have m2o = Value 1");
assert.strictEqual(list.$('tr.o_data_row:eq(2) td:eq(5)').text(),"USD",
"previous line should have reference = USD");
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row input[name="int_field"]'), 'down');
await concurrency.delay(0);
assert.hasClass(list.$('tr.o_data_row:eq(4)'),'o_selected_row',"5th row (newly created) should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]')[0], document.activeElement, "int_field should have focus");
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(1)').text(),"blip", "previous line should have foo = blip"); //check box in first td
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(2)').text(),"Value 1", "previous line should have m2o = Value 1 (b)"); //check box in first td
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(5)').text(),"USD", "previous line should have reference = USD");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip", "new line should have foo = blip");
assert.hasClass(list.$('tr.o_data_row:eq(4)'),'o_selected_row',
"5th row (newly created) should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="int_field"]')[0],
document.activeElement, "int_field should have focus");
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(1)').text(),"blip",
"previous line should have foo = blip"); //check box in first td
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(2)').text(),"Value 1",
"previous line should have m2o = Value 1 (b)"); //check box in first td
assert.strictEqual(list.$('tr.o_data_row:eq(3) td:eq(5)').text(),"USD",
"previous line should have reference = USD");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),
"blip", "new line should have foo = blip");
list.destroy();
});

QUnit.test('navigation: moving down with keydown on last line (editable list top not one2many)', async function (assert) {
QUnit.test('navigation: moving down with keydown (editable list top not one2many)', async function (assert) {
assert.expect(2);

var list = await createView({
@@ -3059,7 +3057,7 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('navigation: moving down with keydown on last line (editable list with several pages)', async function (assert) {
QUnit.test('navigation: moving down with keydown (editable list with several pages)', async function (assert) {
assert.expect(6);

for (var i = 0; i < 40; i++) {
@@ -3104,8 +3102,8 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('navigation: moving down with keydown on last line (editable list one2many)', async function (assert) {
assert.expect(27);
QUnit.test('navigation: moving down with keydown (editable list one2many)', async function (assert) {
assert.expect(29);
var arch = '<form string="One2Many">' +
'<field name="o2m">' +
'<tree editable="bottom">' +
@@ -3126,8 +3124,12 @@ QUnit.module('Views', {
arch: arch,
res_id: 1,
});
await testUtils.dom.click(list.$('td:contains(blip)')); //foo=blip, m2o=value2, m2m=value1-value2-value3, reference=USD, int_field=9
await testUtils.dom.click(list.$('td:contains(yop)')); //foo=blip, m2o=value2, m2m=value1-value2-value3, reference=USD, int_field=9
assert.hasClass(list.$('tr.o_data_row:eq(0)'),'o_selected_row',"1st row should be selected");
await testUtils.fields.triggerKeydown(list.$('tr.o_selected_row input[name="foo"]'), 'down');
await concurrency.delay(0);
assert.hasClass(list.$('tr.o_data_row:eq(1)'),'o_selected_row',"2nd row should be selected");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]')[0], document.activeElement, "foo should have focus");
assert.strictEqual(list.$('tr.o_selected_row input[name="foo"]').val(),"blip", "actual line should have foo = 'blip'");
assert.strictEqual(list.$('tr.o_selected_row div[name="m2m"] span.o_badge_text:eq(0)').text(),"Value 1", "actual line should have first tag = 'Value 1'");
assert.strictEqual(list.$('tr.o_selected_row div[name="m2m"] span.o_badge_text:eq(1)').text(),"Value 2", "actual line should have second tag = 'Value 2'");
@@ -3166,15 +3168,14 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('navigation: moving down with keydown on last line (inside many2one)', async function (assert) {
QUnit.test('navigation: moving down with keydown (inside many2one)', async function (assert) {
assert.expect(4);

var list = await createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="bottom"><field name="foo" required="True"/><field name="m2o" required="True"/><field name="int_field"/></tree>',
//debug: true,
});

await testUtils.dom.click(list.$('tr.o_data_row:eq(3) td:contains(Value 1)')); //int_field=-4 and foo=blip and m2o: 1 (Value 1)

0 comments on commit 5f931f6

Please sign in to comment.
You can’t perform that action at this time.