Commit a402c1f3 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio_ui_test: Fixup tests for Paid/Unpaid invoices

   Force properly the creation of the invoices and assert if links are correctly displayed.
parent 8ac27a52
......@@ -86,6 +86,26 @@
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//li[text()=\'%s\']' % (here.Base_translateString('Paid', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//p[@data-date='2019-10-20']</td>
......@@ -156,7 +176,26 @@
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//li[text()=\'%s\']' % (here.Base_translateString('Paid', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody>
</table>
......
......@@ -64,7 +64,56 @@
dummy python: context.REQUEST.set('mapping', {'count': '1'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//p[@data-date='2019-10-20']</td>
......@@ -80,10 +129,16 @@
<td>//p[@data-date='2019-10-20']</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/wait_for_content_loaded" />
<!-- check invoice view -->
<tal:block tal:define="header python: '%s ${title}' % (here.Base_translateString('Invoice:', lang=lang));
dummy python: context.REQUEST.set('mapping', {'title': '1'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/assert_page_header" />
</tal:block>
<tr>
<td colspan="3"><b tal:content="python: 'Click on Show all'"> Menu Item </b></td>
<td colspan="3"><b tal:content="python: 'Try again with Show All'"> Menu Item </b></td>
</tr>
<tal:block define="menu_item python: 'Invoices'; header menu_item">
......@@ -98,7 +153,66 @@
dummy python: context.REQUEST.set('mapping', {'count': '1'})">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a//img[@src="pdf_icon.png"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a//img[@src="pdf_icon.png"]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//p[@data-date='2019-10-20']</td>
......@@ -158,7 +272,66 @@
<td tal:content="python: '//label[text()=\'%s\']' % (here.Base_translateString('Download', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td tal:content="python: '//div[contains(@data-gadget-url, \'gadget_slapos_invoice_state.html\')]//a[text()=\'%s\']' % (here.Base_translateString('Pay Now', lang=lang))"></td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, 'PaymentTransaction_redirectToManualSlapOSPayment')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_state.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, 'SaleInvoiceTransaction_viewSlapOSPrintout')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a[contains(@href, '/accounting_module/')]</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a//img[@src="pdf_icon.png"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td> //div[contains(@data-gadget-url, 'gadget_slapos_invoice_printout.html')]//a//img[@src="pdf_icon.png"]</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_logout" />
</tbody>
</table>
......
......@@ -21,7 +21,6 @@ def wrapWithShadow():
payment.start()
if not unpaid:
payment.stop()
payment.PaymentTransaction_generatePayzenId()
template = portal.restrictedTraverse(portal.portal_preferences.getPreferredDefaultPrePaymentSubscriptionInvoiceTemplate())
......@@ -43,9 +42,6 @@ def wrapWithShadow():
quantity=1
)
cell.setPrice(1)
return current_invoice, payment
current_invoice, payment = demo_user_functional.Person_restrictMethodAsShadowUser(
......@@ -62,15 +58,21 @@ current_invoice.startBuilding()
current_invoice.reindexObject()
current_invoice.stop()
current_invoice.activate(after_method_id="immediateReindexObject").Delivery_manageBuildingCalculatingDelivery()
current_invoice.activate(
after_method_id=(
"immediateReindexObject", "_updateSimulation", "Delivery_manageBuildingCalculatingDelivery")
).SaleInvoiceTransaction_forceBuildSlapOSAccountingLineList()
if not unpaid:
def isNodeFromLineReceivable(line):
node_value = line.getSourceValue(portal_type='Account')
return node_value.getAccountType() == 'asset/receivable'
for line in current_invoice.getMovementList(portal.getPortalAccountingMovementTypeList()):
if isNodeFromLineReceivable(line):
if not line.hasGroupingReference():
line.setGroupingReference('FAKEGROUPINGREFERENCE')
break
current_invoice.activate(
after_method_id=(
"immediateReindexObject",
"_updateSimulation",
"Delivery_manageBuildingCalculatingDelivery",
"SimulationMovement_buildSlapOS",
"SaleInvoiceTransaction_forceBuildSlapOSAccountingLineList")
).SaleInvoiceTransaction_setFakeGroupingReference()
return 'Done.'
kw = {}
select_dict= {'delivery_uid': None}
kw.update(
portal_type='Simulation Movement',
# This is an optimisation to help mariadb selecting a better index
simulation_state=['draft', 'planned', None],
left_join_list=select_dict.keys(),
delivery_uid=None
)
applied_rule = context.getCausalityRelated(portal_type="Applied Rule")
for simulation_movement in context.getPortalObject().portal_catalog(
path="%%%s%%" % applied_rule, **kw):
if simulation_movement.getDelivery() is not None:
# movement build but not indexed, so do nothing
continue
root_applied_rule = simulation_movement.getRootAppliedRule()
root_applied_rule_path = root_applied_rule.getPath()
business_link = simulation_movement.getCausalityValue(portal_type='Business Link')
business_link.build(path='%s/%%' % root_applied_rule_path, activate_kw={'tag': "ForceBuild"})
return "Done."
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_forceBuildSlapOSAccountingLineList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
def isNodeFromLineReceivable(line):
node_value = line.getSourceValue(portal_type='Account')
return node_value.getAccountType() == 'asset/receivable'
for line in context.getMovementList(portal.getPortalAccountingMovementTypeList()):
if isNodeFromLineReceivable(line):
if not line.hasGroupingReference():
line.setGroupingReference('FAKEGROUPINGREFERENCE')
break
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_setFakeGroupingReference</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment