Browse Source
Added Transaction Draft view and and has product search
Added Transaction Draft view and and has product search
Added Transaction Draft Button on top navbar Group cart routes in auth middlewarepull/1/head
9 changed files with 174 additions and 13 deletions
-
2app/Cart/CashDraft.php
-
2app/Cart/CreditDraft.php
-
25app/Http/Controllers/CartController.php
-
41resources/views/cart/index.blade.php
-
13resources/views/layouts/app.blade.php
-
18routes/web.php
-
10tests/BrowserKitTestCase.php
-
4tests/Feature/Cart/CartControllerTest.php
-
72tests/Feature/TransactionEntryTest.php
@ -0,0 +1,41 @@ |
|||
@extends('layouts.app') |
|||
|
|||
@section('content') |
|||
<?php use Facades\App\Cart\CartCollection; ?>
|
|||
|
|||
<h3 class="page-header">drafts</h3> |
|||
@if (! CartCollection::isEmpty()) |
|||
<ul class="nav nav-tabs draft-drafts-list"> |
|||
@foreach(CartCollection::content() as $key => $content) |
|||
<?php $active = ($draft->draftKey == $key) ? 'class=active' : '' ?>
|
|||
<li {{ $active }} role="presentation"> |
|||
<a href="{{ route('cart.show', $key) }}"> |
|||
{{ $content->type }} - {{ $key }} |
|||
<form action="{{ route('cart.remove') }}" method="post" style="display:inline" onsubmit="return confirm('Yakin ingin menghapus Draft Transaksi ini?')"> |
|||
{{ csrf_field() }} |
|||
{{ method_field('delete') }} |
|||
<input type="hidden" name="draft_key" value="{{ $key }}"> |
|||
<input type="submit" value="x" style="margin: -2px -7px 0px 0px" class="btn-link btn-xs pull-right"> |
|||
</form> |
|||
</a> |
|||
</li> |
|||
@endforeach |
|||
</ul><!-- Tab panes --> |
|||
<br> |
|||
@endif |
|||
@if ($draft) |
|||
{{ $draft ? $draft->type : '' }} |
|||
<form method="get" action="{{ route('cart.show', $draft->draftKey) }}"> |
|||
<input type="text" name="query" value="{{ request('query') }}"> |
|||
<input type="submit" value="{{ trans('product.search') }}" style="display:none"> |
|||
</form> |
|||
@if (isset($queriedProducts)) |
|||
<ul> |
|||
@foreach($queriedProducts as $product) |
|||
<li>{{ $product->name }}</li> |
|||
<li>{{ $draft->type == 'cash' ? $product->cash_price : $product->credit_price }}</li> |
|||
@endforeach |
|||
</ul> |
|||
@endif |
|||
@endif |
|||
@endsection |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
namespace Tests\Feature; |
|||
|
|||
use App\Cart\CartCollection; |
|||
use App\Cart\CashDraft; |
|||
use App\Cart\CreditDraft; |
|||
use App\Product; |
|||
use Illuminate\Foundation\Testing\DatabaseMigrations; |
|||
use Tests\BrowserKitTestCase; |
|||
|
|||
class TransactionEntryTest extends BrowserKitTestCase |
|||
{ |
|||
use DatabaseMigrations; |
|||
|
|||
/** @test */ |
|||
public function user_can_visit_transaction_drafts_page() |
|||
{ |
|||
$this->loginAsUser(); |
|||
|
|||
// Add new draft to collection
|
|||
$cart = new CartCollection; |
|||
$draft = $cart->add(new CashDraft); |
|||
|
|||
$this->visit(route('cart.index')); |
|||
|
|||
$this->assertViewHas('draft', $draft); |
|||
$this->see($draft->type); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_can_create_transaction_draft_by_transaction_create_button() |
|||
{ |
|||
$this->loginAsUser(); |
|||
$this->visit(route('home')); |
|||
|
|||
$this->press(trans('transaction.create')); |
|||
$cart = new CartCollection; |
|||
$draft = $cart->content()->last(); |
|||
$this->seePageIs(route('cart.show', $draft->draftKey)); |
|||
|
|||
$this->press(trans('transaction.create_credit')); |
|||
$cart = new CartCollection; |
|||
$draft = $cart->content()->last(); |
|||
$this->seePageIs(route('cart.show', $draft->draftKey)); |
|||
} |
|||
|
|||
/** @test */ |
|||
public function user_can_search_product_on_transaction_draft_page() |
|||
{ |
|||
$product = factory(Product::class)->create(['name' => 'Testing Produk 1']); |
|||
$this->loginAsUser(); |
|||
|
|||
$cart = new CartCollection; |
|||
$draft = new CreditDraft; |
|||
$cart->add($draft); |
|||
|
|||
// Visit cart index page
|
|||
$this->visit(route('cart.index')); |
|||
|
|||
// Visit search for products
|
|||
$this->submitForm(trans('product.search'), [ |
|||
'query' => 'testing', |
|||
]); |
|||
|
|||
$this->seePageIs(route('cart.show', [$draft->draftKey, 'query' => 'testing'])); |
|||
// See product list appears
|
|||
$this->see($product->name); |
|||
$this->see($product->credit_price); |
|||
$this->dontSee($product->cash_price); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue