1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
invoiceninja/tests/acceptance/QuoteCest.php

100 lines
3.4 KiB
PHP
Raw Normal View History

2016-03-13 16:38:55 +01:00
<?php
use Faker\Factory;
class QuoteCest
{
/**
* @var \Faker\Generator
*/
private $faker;
public function _before(AcceptanceTester $I)
{
$I->checkIfLogin($I);
$this->faker = Factory::create();
}
public function createQuote(AcceptanceTester $I)
{
$clientEmail = $this->faker->safeEmail;
$productKey = $this->faker->text(10);
2018-02-13 17:08:17 +01:00
$categoryName = $this->faker->text(11);
$snippetName = $this->faker->text(12);
$templateName = $this->faker->text(13);
2016-03-13 16:38:55 +01:00
2018-02-13 17:08:17 +01:00
$I->wantTo('create a quote and proposal');
// create proposal category
$I->amOnPage('/proposals/categories/create');
$I->fillField(['name' => 'name'], $categoryName);
$I->click('Save');
$I->see('Successfully created category');
$I->amOnPage('/proposals/categories');
$I->see($categoryName);
// create proposal snippet
$I->amOnPage('/proposals/snippets/create');
$I->fillField(['name' => 'name'], $snippetName);
$I->selectDropdown($I, $categoryName, '.category-select .dropdown-toggle');
$I->click('Save');
$I->see('Successfully created snippet');
$I->amOnPage('/proposals/snippets');
$I->see($snippetName);
$I->see($categoryName);
// create proposal template
$I->amOnPage('/proposals/templates/create');
$I->fillField(['name' => 'name'], $templateName);
$I->click('Save');
$I->see('Successfully created template');
$I->amOnPage('/proposals/templates');
$I->see($templateName);
2016-03-13 16:38:55 +01:00
// create client
$I->amOnPage('/clients/create');
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
$I->click('Save');
$I->see($clientEmail);
// create product
$I->amOnPage('/products/create');
$I->fillField(['name' => 'product_key'], $productKey);
$I->fillField(['name' => 'notes'], $this->faker->text(80));
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20));
$I->click('Save');
2018-02-13 17:08:17 +01:00
$I->see('Successfully created product');
2016-03-13 16:38:55 +01:00
// create quote
$I->amOnPage('/quotes/create');
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
2017-12-25 14:23:30 +01:00
$I->fillField('table.invoice-table tbody tr:nth-child(1) td:nth-child(2) input.tt-input', $productKey);
2016-03-13 16:38:55 +01:00
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
2016-12-05 19:22:11 +01:00
$I->click('Mark Sent');
2018-03-10 20:51:41 +01:00
$I->wait(2);
2016-03-13 16:38:55 +01:00
$I->see($clientEmail);
2018-02-13 17:08:17 +01:00
$I->click('More Actions');
$I->click('New Proposal');
$I->see('Create');
2016-10-02 11:52:23 +02:00
2018-02-13 17:08:17 +01:00
$I->selectDropdown($I, $templateName, '.template-select .dropdown-toggle');
$I->click('Save');
$I->click('Download');
2018-02-14 11:27:59 +01:00
$clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]);
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]);
$proposalId = $I->grabFromDatabase('proposals', 'id', ['invoice_id' => $invoiceId]);
$invitationKey = $I->grabFromDatabase('proposal_invitations', 'invitation_key', ['proposal_id' => $proposalId]);
$clientSession = $I->haveFriend('client');
$clientSession->does(function(AcceptanceTester $I) use ($invitationKey) {
$I->amOnPage('/proposal/' . $invitationKey);
$I->click('Approve');
$I->see('Successfully approved');
});
2016-03-13 16:38:55 +01:00
}
}