From dbd36f318c2651a76bc55c859e8b7d5b00866b33 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Wed, 26 Mar 2014 09:46:46 +0100 Subject: [PATCH 1/2] [FIX] Rem old merged code (SHOULD NOT BE MERGED INTO TRUNK) bzr revid: rim@openerp.com-20140326084646-0vutq1anyeju3w2y --- .../website/tests/ui_suite/ui_test_runner.js | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 addons/website/tests/ui_suite/ui_test_runner.js diff --git a/addons/website/tests/ui_suite/ui_test_runner.js b/addons/website/tests/ui_suite/ui_test_runner.js deleted file mode 100644 index 9a36d372f10..00000000000 --- a/addons/website/tests/ui_suite/ui_test_runner.js +++ /dev/null @@ -1,103 +0,0 @@ -function waitFor (ready, callback, timeout, timeoutMessageCallback) { - timeout = timeout || 10000; - var start = new Date().getTime(); - var condition = ready(); - var interval = setInterval(function() { - if ((new Date().getTime() - start < timeout) && !condition ) { - condition = ready(); - } else { - if(!condition) { - var message = timeoutMessageCallback ? timeoutMessageCallback() : "Timeout after "+timeout+" ms"; - console.log('{ "event": "error", "message": "'+message+'" }'); - console.log("Waiting for...\n"+ready); - phantom.exit(1); - } else { - clearInterval(interval); - callback(); - } - } - }, 100); -} - -function run (test) { - var options = JSON.parse(phantom.args); - - var timeout = options.timeout ? Math.round(parseFloat(options.timeout)*1000) : 60000; - - var scheme = options.scheme ? options.scheme+'://' : 'http://'; - var host = options.host ? options.host : 'localhost'; - var port = options.port ? ':'+options.port : ''; - var path = options.path ? options.path : '/login'; - - var queryParams = []; - if (options.db) queryParams.push('db='+options.db); - if (options.user) queryParams.push('login='+options.user); - if (options.password) queryParams.push('key='+options.password); - if (options.redirect) queryParams.push('redirect='+options.redirect); - var query = queryParams.length > 0 ? '?'+queryParams.join('&') : ''; - - var hashParams = []; - if (options.action) hashParams.push('action='+options.action); - var hash = hashParams.length > 0 ? '#'+hashParams.join('&') : ''; - - var url = scheme+host+port+path+query+hash; - - var page = require('webpage').create(); - - page.viewportSize = { width: 1440, height: 900 }; - - page.onError = function(message, trace) { - console.log('{ "event": "error", "message": "'+message+'"}'); - phantom.exit(1); - }; - page.onAlert = function(message) { - console.log(message); - phantom.exit(1); - }; - page.onConsoleMessage = function(message) { - console.log(message); - try { - var result = JSON.parse(message); - if (result.event === 'success') { - phantom.exit(0); - } else { - phantom.exit(1); - } - } catch (exception) { - phantom.exit(1); - } - }; - - page.onCallback = function(data) { - if (data.event && data.event === 'start') { - test(page, timeout); - } - }; - - var maxRetries = 10; - var retryDelay = 1000; // ms - var tries = 0; - page.open(url, function openPage (status) { - if (status !== 'success') { - tries++; - if (tries < maxRetries) { - setTimeout(function () { - page.open(url, openPage); - }, retryDelay); - } else { - console.log('{ "event": "error", "message": "'+url+' failed to load '+tries+' times ('+status+')"}'); - phantom.exit(1); - } - } else { - page.evaluate(function () { - window.callPhantom({ event: 'start' }); - }); - } - - }); -} - -module.exports = { - waitFor: waitFor, - run: run -} From fd6973dcd9561f4f413cbe547d764b17b52babc3 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Wed, 26 Mar 2014 10:03:35 +0100 Subject: [PATCH 2/2] [DIRTY FIX] Fixing bizarre merge, this file should not be merged into trunk bzr revid: rim@openerp.com-20140326090335-lm6ew2r2cx19niuz --- .../static/src/js/website.tour.shop.js | 195 +++++------------- 1 file changed, 52 insertions(+), 143 deletions(-) diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js index b2106dda9e7..adb4a9e556c 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -2,234 +2,143 @@ 'use strict'; var website = openerp.website; + var _t = openerp._t; website.EditorBar.include({ start: function () { - this.registerTour(new website.EditorShopTour(this)); - var res = this._super(); - return res; + this.registerTour(new website.Tour.Shop(this)); + return this._super(); }, }); - website.EditorShopTour = website.Tour.extend({ + website.Tour.Shop = website.Tour.extend({ id: 'shop', name: "Create a product", testPath: '/shop', - init: function (editor) { + init: function () { var self = this; self.steps = [ { - title: "Welcome to your shop", - content: "You successfully installed the e-commerce. This guide will help you to create your product and promote your sales.", - template: self.popover({ next: "Start Tutorial", end: "Skip It" }), + title: _t("Welcome to your shop"), + content: _t("You successfully installed the e-commerce. This guide will help you to create your product and promote your sales."), + popover: { next: _t("Start Tutorial"), end: _t("Skip It") }, }, { element: '#content-menu-button', placement: 'left', - title: "Create your first product", - content: "Click here to add a new product.", - template: self.popover({ fixed: true }), + title: _t("Create your first product"), + content: _t("Click here to add a new product."), + popover: { fixed: true }, }, { element: 'a[data-action=new_product]', placement: 'left', - title: "Create a new product", - content: "Select 'New Product' to create it and manage its properties to boost your sales.", - template: self.popover({ fixed: true }), + title: _t("Create a new product"), + content: _t("Select 'New Product' to create it and manage its properties to boost your sales."), + popover: { fixed: true }, }, { - element: '.modal:contains("New Product") input[type=text]', + element: '.modal #editor_new_product input[type=text]', sampleText: 'New Product', placement: 'right', - title: "Choose name", - content: "Enter a name for your new product then click 'Continue'.", + title: _t("Choose name"), + content: _t("Enter a name for your new product then click 'Continue'."), }, { waitNot: '.modal input[type=text]:not([value!=""])', element: '.modal button.btn-primary', placement: 'right', - title: "Create Product", - content: "Click Continue to create the product.", + title: _t("Create Product"), + content: _t("Click Continue to create the product."), }, { - waitFor: '#website-top-navbar button[data-action="save"]:visible', - title: "New product created", - content: "This page contains all the information related to the new product.", - template: self.popover({ next: "Continue" }), + waitFor: 'body:has(button[data-action=save]:visible):has(.js_sale)', + title: _t("New product created"), + content: _t("This page contains all the information related to the new product."), + popover: { next: _t("Continue") }, }, { element: '.product_price .oe_currency_value', sampleText: '20.50', placement: 'left', - title: "Change the price", - content: "Edit the price of this product by clicking on the amount.", + title: _t("Change the price"), + content: _t("Edit the price of this product by clicking on the amount."), }, { waitNot: '.product_price .oe_currency_value:containsExact(1.00)', element: '#wrap img.img:first', placement: 'top', - title: "Update image", - content: "Click here to set an image describing your product.", + title: _t("Update image"), + content: _t("Click here to set an image describing your product."), }, { element: 'button.hover-edition-button:visible', placement: 'top', - title: "Update image", - content: "Click here to set an image describing your product.", + title: _t("Update image"), + content: _t("Click here to set an image describing your product."), }, { wait: 500, element: '.well a.pull-right', placement: 'bottom', - title: "Select an Image", - content: "Let's select an existing image.", - template: self.popover({ fixed: true }), + title: _t("Select an Image"), + content: _t("Let's select an existing image."), + popover: { fixed: true }, }, { element: 'img[alt=imac]', placement: 'bottom', - title: "Select an Image", - content: "Let's select an imac image.", - template: self.popover({ fixed: true }), + title: _t("Select an Image"), + content: _t("Let's select an imac image."), + popover: { fixed: true }, }, { waitNot: 'img[alt=imac]', element: '.modal-content button.save', placement: 'bottom', - title: "Select this Image", - content: "Click to add the image to the product decsription.", - template: self.popover({ fixed: true }), + title: _t("Select this Image"), + content: _t("Click to add the image to the product decsription."), + popover: { fixed: true }, }, { waitNot: '.modal-content:visible', element: 'button[data-action=snippet]', placement: 'bottom', - title: "Describe the Product", - content: "Insert blocks like text-image, or gallery to fully describe the product.", - template: self.popover({ fixed: true }), + title: _t("Describe the Product"), + content: _t("Insert blocks like text-image, or gallery to fully describe the product."), + popover: { fixed: true }, }, { snippet: '#snippet_structure .oe_snippet:eq(7)', placement: 'bottom', - title: "Drag & Drop a block", - content: "Drag the 'Big Picture' block and drop it in your page.", - template: self.popover({ fixed: true }), + title: _t("Drag & Drop a block"), + content: _t("Drag the 'Big Picture' block and drop it in your page."), + popover: { fixed: true }, }, { element: 'button[data-action=save]', placement: 'right', - title: "Save your modifications", - content: "Once you click on save, your product is updated.", - template: self.popover({ fixed: true }), + title: _t("Save your modifications"), + content: _t("Once you click on save, your product is updated."), + popover: { fixed: true }, }, { waitFor: '#website-top-navbar button[data-action="edit"]:visible', element: '.js_publish_management button.js_publish_btn.btn-danger', placement: 'top', - title: "Publish your product", - content: "Click to publish your product so your customers can see it.", + title: _t("Publish your product"), + content: _t("Click to publish your product so your customers can see it."), }, { waitFor: '.js_publish_management button.js_publish_btn.btn-success:visible', - title: "Congratulations", - content: "Congratulations! You just created and published your first product.", - template: self.popover({ next: "Close Tutorial" }), + title: _t("Congratulations"), + content: _t("Congratulations! You just created and published your first product."), + popover: { next: _t("Close Tutorial") }, }, ]; return this._super(); } }); - website.EditorShopTest = website.Tour.extend({ - id: 'shop_buy_product', - name: "Try to buy products", - path: '/shop', - testPath: '/shop', - init: function (editor) { - var self = this; - self.steps = [ - { - title: 'begin-test', - template: self.popover({ next: "Start Test"}), - backdrop: true, - }, - { - title: "select ipod", - element: '.oe_product_cart a:contains("iPod")', - }, - { - title: "select ipod 32Go", - element: 'input[name="product_id"]:not([checked])', - }, - { - title: "click on add to cart", - waitFor: 'input[name="product_id"]:eq(1)[checked]', - element: 'form[action="/shop/add_cart/"] button', - }, - { - title: "add suggested", - element: 'form[action="/shop/add_cart/"] button.btn-link:contains("Add to Cart")', - }, - { - title: "add one more iPod", - waitFor: '.my_cart_quantity:contains(2)', - element: '#mycart_products tr:contains("iPod: 32 Gb") a.js_add_cart_json:eq(1)', - }, - { - title: "remove Headphones", - waitFor: '#mycart_products tr:contains("iPod: 32 Gb") input.js_quantity[value=2]', - element: '#mycart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first', - }, - { - title: "set one iPod", - waitNot: '#mycart_products tr:contains("Apple In-Ear Headphones")', - element: '#mycart_products input.js_quantity', - sampleText: '1', - }, - { - title: "go to checkout", - waitFor: '#mycart_products input.js_quantity[value=1]', - element: 'a[href="/shop/checkout/"]', - }, - { - title: "test with input error", - element: 'form[action="/shop/confirm_order/"] button', - callback: function (tour) { - $("input[name='phone']").val(""); - }, - }, - { - title: "test without input error", - waitFor: 'form[action="/shop/confirm_order/"] .has-error', - element: 'form[action="/shop/confirm_order/"] button', - callback: function (tour) { - if ($("input[name='name']").val() === "") - $("input[name='name']").val("website_sale-test-shoptest"); - if ($("input[name='email']").val() === "") - $("input[name='email']").val("website_sale-test-shoptest@website_sale-test-shoptest.optenerp.com"); - $("input[name='phone']").val("123"); - $("input[name='street']").val("123"); - $("input[name='city']").val("123"); - $("input[name='zip']").val("123"); - $("select[name='country_id']").val("21"); - }, - }, - { - title: "Pay Now", - element: 'button:contains("Pay Now")', - }, - { - title: "finish", - waitFor: '.oe_website_sale:contains("Thank you for your order")', - } - ]; - return this._super(); - }, - }); - // for test without editor bar - $(document).ready(function () { - website.Tour.add(website.EditorShopTest); - }); - }());