From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/website/static/tests/website_tests.js | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 addons/website/static/tests/website_tests.js (limited to 'addons/website/static/tests/website_tests.js') diff --git a/addons/website/static/tests/website_tests.js b/addons/website/static/tests/website_tests.js new file mode 100644 index 00000000..8d43100b --- /dev/null +++ b/addons/website/static/tests/website_tests.js @@ -0,0 +1,73 @@ +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", async function (assert) { + assert.expect(2); + + var form = await createView({ + View: FormView, + model: 'blog_post', + data: this.data, + arch: '
' + + '' + + '
' + + '' + + '
' + + '
' + + '
', + res_id: 1, + }); + var selector = '.oe_button_box .oe_stat_button[name="website_published"] .o_stat_text'; + assert.containsN(form, selector, 1, "there should be one text displayed"); + selector = '.oe_button_box .oe_stat_button[name="website_published"] .o_button_icon.fa-globe.text-danger'; + assert.containsOnce(form, selector, "there should be one icon in red"); + form.destroy(); + }); + QUnit.test("widget website button: display true value", async function (assert) { + assert.expect(2); + + var form = await createView({ + View: FormView, + model: 'blog_post', + data: this.data, + arch: '
' + + '' + + '
' + + '' + + '
' + + '
' + + '
', + res_id: 2, + }); + var selector = '.oe_button_box .oe_stat_button[name="website_published"] .o_stat_text'; + assert.containsN(form, selector, 1, "should be one text displayed"); + selector = '.oe_button_box .oe_stat_button[name="website_published"] .o_button_icon.fa-globe.text-success'; + assert.containsOnce(form, selector, "there should be one text in green"); + form.destroy(); + }); +}); + +}); -- cgit v1.2.3