From f32ae9f3a79884edce4022cca6e105d846ce1a46 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 15 May 2017 08:54:35 +0300 Subject: [PATCH] Working on tests --- tests/acceptance/TaskCest.php | 2 +- tests/acceptance/TaxRatesCest.php | 71 +++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/tests/acceptance/TaskCest.php b/tests/acceptance/TaskCest.php index 2065f53470b6..79e810748241 100644 --- a/tests/acceptance/TaskCest.php +++ b/tests/acceptance/TaskCest.php @@ -55,7 +55,7 @@ class TaskCest $I->click('Invoice Task'); $I->click('Mark Sent'); $I->see('Sent'); - $I->see('View as recipient'); + $I->see('Successfully created invoice'); } public function createManualTask(AcceptanceTester $I) diff --git a/tests/acceptance/TaxRatesCest.php b/tests/acceptance/TaxRatesCest.php index 7dcf85f2acb7..8579dfdc54ba 100644 --- a/tests/acceptance/TaxRatesCest.php +++ b/tests/acceptance/TaxRatesCest.php @@ -14,9 +14,9 @@ class TaxRatesCest $this->faker = Factory::create(); } - public function taxRates(AcceptanceTester $I) + public function lineItemTaxRates(AcceptanceTester $I) { - $I->wantTo('test tax rates'); + $I->wantTo('test line item tax rates'); $clientEmail = $this->faker->safeEmail; $productKey = $this->faker->text(10); @@ -40,7 +40,6 @@ class TaxRatesCest // enable line item taxes $I->amOnPage('/settings/tax_rates'); $I->checkOption('#invoice_item_taxes'); - $I->selectOption('#default_tax_rate_id', 1); $I->click('Save'); // create product @@ -82,4 +81,70 @@ class TaxRatesCest $I->see("\${$total}"); } + + public function invoiceTaxRates(AcceptanceTester $I) + { + $I->wantTo('test invoice tax rates'); + + $clientEmail = $this->faker->safeEmail; + $productKey = $this->faker->text(10); + $invoiceTaxRate = $this->faker->randomFloat(2, 5, 15); + $invoiceTaxName = $this->faker->word(); + $itemCost = $this->faker->numberBetween(1, 20); + + $total = $itemCost; + $total += round($itemCost * $invoiceTaxRate / 100, 2); + + $invoiceTaxRate = number_format($invoiceTaxRate, 3); + + // create tax rates + $I->createTaxRate($I, $invoiceTaxName, $invoiceTaxRate); + + // enable line item taxes + $I->amOnPage('/settings/tax_rates'); + $I->selectOption('#default_tax_rate_id', $invoiceTaxName . ': ' . $invoiceTaxRate . '%'); + $I->click('Save'); + + // create product + $I->amOnPage('/products/create'); + $I->fillField(['name' => 'product_key'], $productKey); + $I->fillField(['name' => 'notes'], $this->faker->text(80)); + $I->fillField(['name' => 'cost'], $itemCost); + $I->click('Save'); + $I->wait(1); + //$I->see($productKey); + + // create client + $I->amOnPage('/clients/create'); + $I->fillField(['name' => 'contacts[0][email]'], $clientEmail); + $I->click('Save'); + $I->see($clientEmail); + + // create invoice + $I->amOnPage('/invoices/create'); + $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); + $I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); + $I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable'); + $I->wait(3); + + // check total is right before saving + $I->see("\${$total}"); + $I->click('Save Draft'); + $I->wait(3); + $I->see($clientEmail); + + // check total is right after saving + $I->see("\${$total}"); + $I->amOnPage('/invoices'); + $I->wait(2); + + // check total is right in list view + $I->see("\${$total}"); + + // enable line item taxes + $I->amOnPage('/settings/tax_rates'); + $I->selectOption('#default_tax_rate_id', ''); + $I->click('Save'); + } + }