diff --git a/tests/behat/shopping_cart_costcenter_credit_manager.feature b/tests/behat/shopping_cart_costcenter_credit_manager.feature index 2a69ba9..e94f2e1 100644 --- a/tests/behat/shopping_cart_costcenter_credit_manager.feature +++ b/tests/behat/shopping_cart_costcenter_credit_manager.feature @@ -33,7 +33,6 @@ Feature: Cashier manage credits with costcenters enabled in shopping cart Given the following config values are set as admin: | config | value | plugin | | samecostcenterforcredits | 1 | local_shopping_cart | - | defaultcostcenterforcredits | CostCenter1 | local_shopping_cart | And I log in as "admin" And I visit "/local/shopping_cart/cashier.php" And I set the field "Select a user..." to "Username1" @@ -42,6 +41,7 @@ Feature: Cashier manage credits with costcenters enabled in shopping cart And I wait until the page is ready ## And I should not see "Credits" in the ".cashier-history-items" "css_element" And "//*[@class='credit_total']" "xpath_element" should not exist + ## Add credits to the CostCenter1 When I click on "Credits manager" "button" And I wait until the page is ready ## Dynamic fields - step-by-step proceeding required @@ -51,6 +51,7 @@ Feature: Cashier manage credits with costcenters enabled in shopping cart And I set the field "Reason" to "add credits CostCenter1" And I press "Save changes" And I wait until the page is ready + ## Add credits to the CostCenter2 And I click on "Credits manager" "button" And I wait until the page is ready ## Dynamic fields - step-by-step proceeding required @@ -60,12 +61,62 @@ Feature: Cashier manage credits with costcenters enabled in shopping cart And I set the field "Reason" to "add credits CostCenter2" And I press "Save changes" And I wait until the page is ready + ## Verify credits per costcenters Then I should see "16.35" in the ".cashier-history-items [data-costcenter=\"CostCenter1\"] .credit_total" "css_element" And I should see "25.53" in the ".cashier-history-items [data-costcenter=\"CostCenter2\"] .credit_total" "css_element" And I follow "Cash report" And I wait until the page is ready And I should see "25.53" in the "#cash_report_table_r1" "css_element" - And I should see "add credits" in the "#cash_report_table_r1" "css_element" + And I should see "add credits CostCenter2" in the "#cash_report_table_r1" "css_element" And I should see "16.35" in the "#cash_report_table_r2" "css_element" - And I should see "add credits" in the "#cash_report_table_r2" "css_element" + And I should see "add credits CostCenter1" in the "#cash_report_table_r2" "css_element" + And "//*[@id='cash_report_table_r3']" "xpath_element" should not exist + + @javascript + Scenario: Shopping cart costcenter credits: cashier correct (reduce) credits for user + Given the following config values are set as admin: + | config | value | plugin | + | samecostcenterforcredits | 1 | local_shopping_cart | + ## | defaultcostcenterforcredits | CostCenter1 | local_shopping_cart | + And the following "local_shopping_cart > user credits" exist: + | user | credit | currency | costcenter | + | user1 | 30 | EUR | CostCenter1 | + | user1 | 40 | EUR | CostCenter2 | + And I log in as "admin" + And I visit "/local/shopping_cart/cashier.php" + And I set the field "Select a user..." to "Username1" + And I should see "Username1 Test" + And I click on "Continue" "button" + And I wait until the page is ready + And I should see "30" in the ".cashier-history-items [data-costcenter=\"CostCenter1\"] .credit_total" "css_element" + And I should see "40" in the ".cashier-history-items [data-costcenter=\"CostCenter2\"] .credit_total" "css_element" + ## Reduce credits to the CostCenter1 + When I click on "Credits manager" "button" + And I wait until the page is ready + ## Dynamic fields - step-by-step proceeding required + And I set the field "What do you want to do?" to "Correct credits" + And I set the field "Correction value or credits to pay back" to "-11" + And I set the field "Costcenter to which the credit is assigned to" to "CostCenter1" + And I set the field "Reason" to "cc1 reduce credits" + And I press "Save changes" + And I wait until the page is ready + ## Reduce credits to the CostCenter2 + When I click on "Credits manager" "button" + And I wait until the page is ready + ## Dynamic fields - step-by-step proceeding required + And I set the field "What do you want to do?" to "Correct credits" + And I set the field "Correction value or credits to pay back" to "-12" + And I set the field "Costcenter to which the credit is assigned to" to "CostCenter2" + And I set the field "Reason" to "cc2 reduce credits" + And I press "Save changes" + And I wait until the page is ready + ## Verify credits per costcenters + Then I should see "19.00" in the ".cashier-history-items [data-costcenter=\"CostCenter1\"] .credit_total" "css_element" + And I should see "28.00" in the ".cashier-history-items [data-costcenter=\"CostCenter2\"] .credit_total" "css_element" + And I follow "Cash report" + And I wait until the page is ready + And I should see "-12.00" in the "#cash_report_table_r1" "css_element" + And I should see "cc2 reduce credits" in the "#cash_report_table_r1" "css_element" + And I should see "-11.00" in the "#cash_report_table_r2" "css_element" + And I should see "cc1 reduce credits" in the "#cash_report_table_r2" "css_element" And "//*[@id='cash_report_table_r3']" "xpath_element" should not exist