diff --git a/.travis.yml b/.travis.yml index 8dd0f4cf5959..ba4fbd3de3e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ php: addons: hosts: - - ninja.dev + - www.ninja.test cache: directories: @@ -63,14 +63,14 @@ before_script: - php artisan migrate --database=db-ninja-0 --seed --no-interaction - php artisan migrate --database=db-ninja-1 --seed --no-interaction - php artisan migrate --database=db-ninja-2 --seed --no-interaction - # Start webserver on ninja.dev:8000 - - php artisan serve --host=ninja.dev --port=8000 & # '&' allows to run in background + # Start webserver on ninja.test:8000 + - php artisan serve --host=www.ninja.test --port=8000 & # '&' allows to run in background # Start PhantomJS - phantomjs --webdriver=4444 & # '&' allows to run in background # Give it some time to start - sleep 5 # Make sure the app is up-to-date - - curl -L http://ninja.dev:8000/update + - curl -L http://www.ninja.test:8000/update - php artisan ninja:create-test-data 4 true - php artisan db:seed --no-interaction --class=UserTableSeeder # development seed - sed -i 's/DB_TYPE=db-ninja-1/DB_TYPE=db-ninja-2/g' .env @@ -91,6 +91,7 @@ script: - php ./vendor/codeception/codeception/codecept run --debug acceptance PaymentCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance TaskCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance GatewayFeesCest.php + - php ./vendor/codeception/codeception/codecept run --debug acceptance DiscountCest.php - php ./vendor/codeception/codeception/codecept run --debug acceptance AllPagesCept.php #- sed -i 's/NINJA_DEV=true/NINJA_PROD=true/g' .env diff --git a/resources/views/invoices/edit_table.blade.php b/resources/views/invoices/edit_table.blade.php index 59e15a53736c..54a4b01245b5 100644 --- a/resources/views/invoices/edit_table.blade.php +++ b/resources/views/invoices/edit_table.blade.php @@ -1,4 +1,4 @@ -
diff --git a/tests/_bootstrap.php.default b/tests/_bootstrap.php.default index 33ecdcb60782..4ef057c678cc 100644 --- a/tests/_bootstrap.php.default +++ b/tests/_bootstrap.php.default @@ -2,10 +2,10 @@ // This is global bootstrap for autoloading use Codeception\Util\Fixtures; -Fixtures::add('url', 'http://ninja.dev:8000'); +Fixtures::add('url', 'http://www.ninja.test:8000'); Fixtures::add('username', 'user@example.com'); Fixtures::add('password', 'password'); Fixtures::add('api_secret', 'password'); Fixtures::add('stripe_secret_key', ''); -Fixtures::add('stripe_publishable_key', ''); \ No newline at end of file +Fixtures::add('stripe_publishable_key', ''); diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml index 593093150035..f6f64dc7d119 100644 --- a/tests/acceptance.suite.yml +++ b/tests/acceptance.suite.yml @@ -8,7 +8,7 @@ class_name: AcceptanceTester modules: enabled: - WebDriver: - url: 'http://ninja.dev:8000/' + url: 'http://www.ninja.test:8000' window_size: 1024x768 wait: 5 browser: firefox diff --git a/tests/acceptance/DiscountCest.php b/tests/acceptance/DiscountCest.php index e69de29bb2d1..5053f1742d72 100644 --- a/tests/acceptance/DiscountCest.php +++ b/tests/acceptance/DiscountCest.php @@ -0,0 +1,69 @@ +checkIfLogin($I); + + $this->faker = Factory::create(); + } + + public function lineItemDiscounts(AcceptanceTester $I) + { + $I->wantTo('test line item discounts'); + + $clientEmail = $this->faker->safeEmail; + $itemTaxName = $this->faker->word; + $itemTaxRate = rand(1, 1000) / 10; + $itemDiscount = rand(1, 1000) / 10; + $discount = rand(1, 1000) / 10; + $itemAmount = rand(1, 10000) / 10; + $quantity = rand(1,20); + + $I->amOnPage('/settings/invoice_design#product_fields'); + $I->selectOption('#product_fields_select', 'product.discount'); + $I->click('Save'); + + $I->amOnPage('/clients/create'); + + $I->fillField(['name' => 'contacts[0][email]'], $clientEmail); + $I->click('Save'); + $I->see($clientEmail); + + $clientId = $I->grabFromCurrentUrl('~clients/(\d+)~'); + + $I->amOnPage('/tax_rates/create'); + $I->fillField(['name' => 'name'], $itemTaxName); + $I->fillField(['name' => 'rate'], $itemTaxRate); + $I->click('Save'); + $I->see($itemTaxName); + + $I->amOnPage('/invoices/create'); + + $invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value'); + + // check tax and discount rounding + $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); + $I->fillField('#discount', $discount); + $this->fillItem($I, 1, 'Item', 'Notes', $itemAmount, $quantity, $itemDiscount); + + $I->click('Mark Sent'); + } + + private function fillItem(AcceptanceTester $I, $row, $product, $description, $cost, $quantity, $discount) + { + $row_selector = sprintf('table.product-table tr:nth-child(%d) ', $row); + + $I->fillField($row_selector.'#product_key', $product); + $I->fillField($row_selector.'textarea', $description); + $I->fillField($row_selector.'td:nth-child(4) input', $cost); + $I->fillField($row_selector.'td:nth-child(5) input', $quantity); + $I->fillField($row_selector.'td:nth-child(6) input', $discount); + } +} |