summaryrefslogtreecommitdiff
path: root/addons/website/static/tests
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-04-06 09:41:48 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit36aed81d9035f3b298eb0188ad4bdae9fbb282a8 (patch)
tree130f5e6c9deb73f2c601b860058a9ed18329ead5 /addons/website/static/tests
parente3d1abc75f5659e2bbd8ec05e5a7ce4a95d8721e (diff)
[FIX] website: update to new views
The methods overriden were not the correct one anymore.
Diffstat (limited to 'addons/website/static/tests')
-rw-r--r--addons/website/static/tests/website_tests.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/addons/website/static/tests/website_tests.js b/addons/website/static/tests/website_tests.js
new file mode 100644
index 00000000000..868e3cc4e8f
--- /dev/null
+++ b/addons/website/static/tests/website_tests.js
@@ -0,0 +1,79 @@
+odoo.define('website.tests', function (require) {
+"use strict";
+
+var FormView = require('web.FormView');
+var testUtils = require("web.test_utils");
+
+var createView = testUtils.createView;
+
+QUnit.module('website', {
+ before: function () {
+ this.data = {
+ blog_post: {
+ fields: {
+ website_published: {string: "Available on the Website", type: "boolean"},
+ },
+ records: [{
+ id: 1,
+ website_published: false,
+ }, {
+ id: 2,
+ website_published: true,
+ }]
+ }
+ };
+ },
+}, function () {
+ QUnit.test("widget website button: display false value", function (assert) {
+ assert.expect(2);
+
+ var form = createView({
+ View: FormView,
+ model: 'blog_post',
+ data: this.data,
+ arch:
+ '<form>' +
+ '<sheet>' +
+ '<div class="oe_button_box" name="button_box">' +
+ '<button class="oe_stat_button" name="website_publish_button" type="object" icon="fa-globe">' +
+ '<field name="website_published" widget="website_button"/>' +
+ '</button>' +
+ '</div>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ });
+ var selector = '.oe_button_box .oe_stat_button .o_stat_info[name="website_published"] .o_stat_text';
+ assert.strictEqual(form.$(selector).length, 2, "there should be two texts displayed");
+ selector = '.oe_button_box .oe_stat_button .o_stat_info[name="website_published"] .o_stat_text.o_value.text-danger';
+ assert.strictEqual(form.$(selector).length, 1, "there should be one text in red");
+ form.destroy();
+ });
+ QUnit.test("widget website button: display true value", function (assert) {
+ assert.expect(2);
+
+ var form = createView({
+ View: FormView,
+ model: 'blog_post',
+ data: this.data,
+ arch:
+ '<form>' +
+ '<sheet>' +
+ '<div class="oe_button_box" name="button_box">' +
+ '<button class="oe_stat_button" name="website_publish_button" type="object" icon="fa-globe">' +
+ '<field name="website_published" widget="website_button"/>' +
+ '</button>' +
+ '</div>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 2,
+ });
+ var selector = '.oe_button_box .oe_stat_button .o_stat_info[name="website_published"] .o_stat_text';
+ assert.strictEqual(form.$(selector).length, 2, "should be two texts displayed");
+ selector = '.oe_button_box .oe_stat_button .o_stat_info[name="website_published"] .o_stat_text.o_value.text-success';
+ assert.strictEqual(form.$(selector).length, 1, "there should be one text in green");
+ form.destroy();
+ });
+});
+
+});