Mathias Markl 6 years ago
parent
commit
f843094c97
  1. 1
      muk_web_preview/__manifest__.py
  2. BIN
      muk_web_preview/demo/data/sample.pdf
  3. 12
      muk_web_preview/demo/preview_demo.xml
  4. 51
      muk_web_preview/static/test/test.js
  5. 6
      muk_web_preview/template/assets.xml
  6. 23
      muk_web_preview/tests/__init__.py
  7. 46
      muk_web_preview/tests/test_preview.py

1
muk_web_preview/__manifest__.py

@ -45,6 +45,7 @@
"template/assets.xml",
],
"demo": [
"demo/preview_demo.xml",
],
"qweb": [
"static/src/xml/*.xml",

BIN
muk_web_preview/demo/data/sample.pdf

12
muk_web_preview/demo/preview_demo.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="pdf_attachment_demo" model="ir.attachment">
<field name="name">sample.pdf</field>
<field name="datas_fname">sample.pdf</field>
<field name="datas" type="base64" file="muk_web_preview/demo/data/sample.pdf"/>
</record>
</data>
</odoo>

51
muk_web_preview/static/test/test.js

@ -0,0 +1,51 @@
odoo.define('muk_web_preview.tour', function (require) {
'use strict';
var core = require("web.core");
var tour = require("web_tour.tour");
var base = require("web_editor.base");
var _t = core._t;
var name = 'preview';
var options = {
test: true,
url: '/web',
wait_for: base.ready()
}
var setps = [
{
trigger: 'a.oe_menu_toggler[data-menu-xmlid="base.menu_administration"]',
run: 'click',
},{
trigger: 'a.oe_menu_toggler[data-menu-xmlid="base.next_id_9"]',
run: 'click',
},{
trigger: 'a.oe_menu_leaf[data-menu-xmlid="base.menu_action_attachment"]',
run: 'click',
},{
trigger: 'input.o_searchview_input',
extra_trigger: 'div.o_main_content > div.o_control_panel li.active:contains("Attachment")',
run: 'text sample.pdf',
},{
trigger: 'ul.o_searchview_autocomplete li a',
extra_trigger: 'div.o_main_content > div.o_control_panel li.active:contains("Attachment")',
run: 'click',
},{
trigger: 'td.o_data_cell:contains("sample.pdf")',
extra_trigger: 'div.o_main_content > div.o_control_panel li.active:contains("Attachment")',
run: 'click',
},{
trigger: 'button.o_binary_preview',
run: 'click',
},{
trigger: 'div.preview-body iframe',
run: function (actions) {},
}
];
tour.register(name, options, setps);
});

6
muk_web_preview/template/assets.xml

@ -31,4 +31,10 @@
<script type="text/javascript" src="/muk_web_preview/static/src/js/preview_dialog.js"/>
</xpath>
</template>
<template id="assets_test" inherit_id="web.js_tests_assets">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_preview/static/test/test.js"/>
</xpath>
</template>
</odoo>

23
muk_web_preview/tests/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import test_preview

46
muk_web_preview/tests/test_preview.py

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# Copyright (C) 2017 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import os
import base64
import logging
import unittest
from odoo import _
from odoo.tests import common
class PreviewTestCase(common.HttpCase):
at_install = False
post_install = True
def setUp(self):
super(PreviewTestCase, self).setUp()
def tearDown(self):
super(PreviewTestCase, self).tearDown()
def test_preview(self):
self.phantom_js("/web",
"odoo.__DEBUG__.services['web_tour.tour'].run('preview')",
"odoo.__DEBUG__.services['web_tour.tour'].tours.preview.ready",
login="admin")
Loading…
Cancel
Save