mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add tests for creating entities inline
This commit is contained in:
parent
5c98c73fde
commit
902cb2a5dc
@ -73,7 +73,12 @@ class ExpenseDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'category',
|
'category',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
return $model->category != null ? substr($model->category, 0, 100) : '';
|
$category = $model->category != null ? substr($model->category, 0, 100) : '';
|
||||||
|
if (! Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->category_user_id])) {
|
||||||
|
return $category;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $model->category_public_id ? link_to("expense_categories/{$model->category_public_id}/edit", $category)->toHtml() : '';
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -81,6 +81,8 @@ class ExpenseRepository extends BaseRepository
|
|||||||
'expenses.tax_rate1',
|
'expenses.tax_rate1',
|
||||||
'expenses.tax_rate2',
|
'expenses.tax_rate2',
|
||||||
'expense_categories.name as category',
|
'expense_categories.name as category',
|
||||||
|
'expense_categories.user_id as category_user_id',
|
||||||
|
'expense_categories.public_id as category_public_id',
|
||||||
'invoices.public_id as invoice_public_id',
|
'invoices.public_id as invoice_public_id',
|
||||||
'invoices.user_id as invoice_user_id',
|
'invoices.user_id as invoice_user_id',
|
||||||
'invoices.balance',
|
'invoices.balance',
|
||||||
|
@ -49,6 +49,13 @@ class AcceptanceTester extends \Codeception\Actor
|
|||||||
$I->click(sprintf('ul.typeahead li[data-value="%s"]', $option));
|
$I->click(sprintf('ul.typeahead li[data-value="%s"]', $option));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectDropdownCreate(\AcceptanceTester $I, $entityType, $value, $entityTypeShort = false)
|
||||||
|
{
|
||||||
|
$entityTypeShort = $entityTypeShort ?: $entityType;
|
||||||
|
$I->fillField("#{$entityType}_name", $value);
|
||||||
|
$I->click(sprintf('ul.typeahead li[data-value="%s"]', "Create {$entityTypeShort}: \$name"));
|
||||||
|
}
|
||||||
|
|
||||||
function selectDropdownRow(\AcceptanceTester $I, $option, $dropdownSelector)
|
function selectDropdownRow(\AcceptanceTester $I, $option, $dropdownSelector)
|
||||||
{
|
{
|
||||||
$I->click("$dropdownSelector span.dropdown-toggle");
|
$I->click("$dropdownSelector span.dropdown-toggle");
|
||||||
|
@ -22,17 +22,11 @@ class ExpenseCest
|
|||||||
$I->wantTo('Create an expense');
|
$I->wantTo('Create an expense');
|
||||||
|
|
||||||
$vendorName = $this->faker->name;
|
$vendorName = $this->faker->name;
|
||||||
|
$categoryName = $this->faker->text(20);
|
||||||
$clientName = $this->faker->name;
|
$clientName = $this->faker->name;
|
||||||
$clientEmail = $this->faker->safeEmail;
|
$clientEmail = $this->faker->safeEmail;
|
||||||
$amount = $this->faker->numberBetween(10, 20);
|
$amount = $this->faker->numberBetween(10, 20);
|
||||||
|
|
||||||
// create vendor
|
|
||||||
$I->amOnPage('/vendors/create');
|
|
||||||
$I->fillField(['name' => 'name'], $vendorName);
|
|
||||||
$I->click('Save');
|
|
||||||
$I->see($vendorName);
|
|
||||||
$vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]);
|
|
||||||
|
|
||||||
// create client
|
// create client
|
||||||
$I->amOnPage('/clients/create');
|
$I->amOnPage('/clients/create');
|
||||||
$I->fillField(['name' => 'name'], $clientName);
|
$I->fillField(['name' => 'name'], $clientName);
|
||||||
@ -44,17 +38,24 @@ class ExpenseCest
|
|||||||
// create expense
|
// create expense
|
||||||
$I->amOnPage('/expenses/create');
|
$I->amOnPage('/expenses/create');
|
||||||
$I->fillField(['name' => 'amount'], $amount);
|
$I->fillField(['name' => 'amount'], $amount);
|
||||||
$I->selectDropdown($I, $vendorName, '.vendor-select .dropdown-toggle');
|
$I->selectDropdownCreate($I, 'vendor', $vendorName);
|
||||||
|
$I->selectDropdownCreate($I, 'expense_category', $categoryName, 'category');
|
||||||
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
|
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
|
||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
$I->wait(2);
|
$I->wait(2);
|
||||||
$I->seeInDatabase('expenses', ['vendor_id' => $vendorId]);
|
|
||||||
$I->seeInDatabase('expenses', ['client_id' => $clientId]);
|
$vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]);
|
||||||
|
$categoryId = $I->grabFromDatabase('expense_categories', 'id', ['name' => $categoryName]);
|
||||||
|
$I->seeInDatabase('expenses', [
|
||||||
|
'client_id' => $clientId,
|
||||||
|
'vendor_id' => $vendorId,
|
||||||
|
'expense_category_id' => $categoryId
|
||||||
|
]);
|
||||||
|
|
||||||
// invoice expense
|
// invoice expense
|
||||||
$I->executeJS('submitAction(\'invoice\')');
|
$I->executeJS('submitAction(\'invoice\')');
|
||||||
$I->wait(2);
|
$I->wait(2);
|
||||||
$I->click('Save');
|
$I->click('Save Draft');
|
||||||
$I->wait(2);
|
$I->wait(2);
|
||||||
$I->see($clientEmail);
|
$I->see($clientEmail);
|
||||||
$I->see($amount);
|
$I->see($amount);
|
||||||
|
@ -19,11 +19,14 @@ class TaskCest
|
|||||||
public function createTimerTask(AcceptanceTester $I)
|
public function createTimerTask(AcceptanceTester $I)
|
||||||
{
|
{
|
||||||
$description = $this->faker->text(100);
|
$description = $this->faker->text(100);
|
||||||
|
$project = $this->faker->text(20);
|
||||||
|
|
||||||
$I->wantTo('create a timed task');
|
$I->wantTo('create a timed task');
|
||||||
$I->amOnPage('/tasks/create');
|
$I->amOnPage('/tasks/create');
|
||||||
$I->seeCurrentUrlEquals('/tasks/create');
|
$I->seeCurrentUrlEquals('/tasks/create');
|
||||||
|
|
||||||
|
$I->selectDropdown($I, 'Wilford Borer', '.client-select .dropdown-toggle');
|
||||||
|
$I->selectDropdownCreate($I, 'project', $project);
|
||||||
$I->fillField('#description', $description);
|
$I->fillField('#description', $description);
|
||||||
|
|
||||||
$I->click('Start');
|
$I->click('Start');
|
||||||
@ -32,6 +35,7 @@ class TaskCest
|
|||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
|
|
||||||
$I->seeInDatabase('tasks', ['description' => $description]);
|
$I->seeInDatabase('tasks', ['description' => $description]);
|
||||||
|
$I->seeInDatabase('projects', ['name' => $project]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createManualTask(AcceptanceTester $I)
|
public function createManualTask(AcceptanceTester $I)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user