diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/tests/views/kanban_benchmarks.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web/static/tests/views/kanban_benchmarks.js')
| -rw-r--r-- | addons/web/static/tests/views/kanban_benchmarks.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/kanban_benchmarks.js b/addons/web/static/tests/views/kanban_benchmarks.js new file mode 100644 index 00000000..020067cb --- /dev/null +++ b/addons/web/static/tests/views/kanban_benchmarks.js @@ -0,0 +1,92 @@ +odoo.define('web.kanban_benchmarks', function (require) { + "use strict"; + + const KanbanView = require('web.KanbanView'); + const { createView } = require('web.test_utils'); + + QUnit.module('Kanban View', { + beforeEach: function () { + this.data = { + foo: { + fields: { + foo: {string: "Foo", type: "char"}, + bar: {string: "Bar", type: "boolean"}, + int_field: {string: "int_field", type: "integer", sortable: true}, + qux: {string: "my float", type: "float"}, + }, + records: [ + { id: 1, bar: true, foo: "yop", int_field: 10, qux: 0.4}, + {id: 2, bar: true, foo: "blip", int_field: 9, qux: 13}, + ] + }, + }; + this.arch = null; + this.run = function (assert) { + const data = this.data; + const arch = this.arch; + return new Promise(resolve => { + new Benchmark.Suite({}) + .add('kanban', { + defer: true, + fn: async (deferred) => { + const kanban = await createView({ + View: KanbanView, + model: 'foo', + data, + arch, + }); + kanban.destroy(); + deferred.resolve(); + }, + }) + .on('cycle', event => { + assert.ok(true, String(event.target)); + }) + .on('complete', resolve) + .run({ async: true }); + }); + }; + } + }, function () { + QUnit.test('simple kanban view with 2 records', function (assert) { + assert.expect(1); + + this.arch = ` + <kanban> + <templates> + <t t-name="kanban-box"> + <div> + <t t-esc="record.foo.value"/> + <field name="foo"/> + </div> + </t> + </templates> + </kanban>`; + return this.run(assert); + }); + + QUnit.test('simple kanban view with 200 records', function (assert) { + assert.expect(1); + + for (let i = 2; i < 200; i++) { + this.data.foo.records.push({ + id: i, + foo: `automated data ${i}`, + }); + } + + this.arch = ` + <kanban> + <templates> + <t t-name="kanban-box"> + <div> + <t t-esc="record.foo.value"/> + <field name="foo"/> + </div> + </t> + </templates> + </kanban>`; + return this.run(assert); + }); + }); +}); |
