From a1cd77b113e824842bba0190bfc3beddb2faf1e5 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 14 Dec 2023 15:18:21 +0300 Subject: [PATCH 01/11] edit create plan for pull request --- resources/views/livewire/plan/create.blade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/plan/create.blade.php b/resources/views/livewire/plan/create.blade.php index 71daad3..ffb0135 100644 --- a/resources/views/livewire/plan/create.blade.php +++ b/resources/views/livewire/plan/create.blade.php @@ -650,8 +650,8 @@ @endisset
-
@@ -687,6 +687,7 @@ class="diet__btn btn btn-primary">Опубликовать
+
@endif From 0d86fd7ad05c1676e909891658dc2d2d6892ff0f Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Fri, 15 Dec 2023 14:23:19 +0300 Subject: [PATCH 02/11] complete create plan --- app/Livewire/Plan/Create.php | 28 +- .../views/livewire/plan/create.blade.php | 752 +++++++----------- 2 files changed, 311 insertions(+), 469 deletions(-) diff --git a/app/Livewire/Plan/Create.php b/app/Livewire/Plan/Create.php index ad02c5d..98bdc2e 100644 --- a/app/Livewire/Plan/Create.php +++ b/app/Livewire/Plan/Create.php @@ -31,6 +31,9 @@ class Create extends Component public $input_items_2 = ""; public $input_items_3 = ""; + public $isVisibleDuration = false; + public $isVisibleState = false; + protected function rules() { $rules = [ @@ -66,6 +69,29 @@ class Create extends Component return view('livewire.plan.create'); } + public function showListDuration() + { + $this->isVisibleDuration = !$this->isVisibleDuration; + } + + public function showListState() + { + $this->isVisibleState = !$this->isVisibleState; + } + + public function toggleDuration($duration) + { + $this->duration = $duration; + $this->isVisibleDuration = false; + } + + + public function toggleState($state) + { + $this->state = $state; + $this->isVisibleState = false; + } + public function addPacketOption($options_type, $options_type_input) { $this->$options_type['short'] = $this->$options_type_input['short']; @@ -110,7 +136,7 @@ class Create extends Component public function showPreview() { - $this->state = "inactive"; + $this->state = "unactive"; $this->publish(); } } diff --git a/resources/views/livewire/plan/create.blade.php b/resources/views/livewire/plan/create.blade.php index ad334b1..ff9f1dc 100644 --- a/resources/views/livewire/plan/create.blade.php +++ b/resources/views/livewire/plan/create.blade.php @@ -53,59 +53,44 @@
- +
+ Длительность плана питания +
- @@ -119,53 +104,39 @@ Статус
+
@@ -173,10 +144,10 @@
+
-
Описание @@ -206,260 +177,30 @@ });" wire:key="myIdentifierHere" x-ref="myIdentifierHere" wire:model="details"> -
-
- - -
-
-
Оказание услуг
-
- -
-
-
- - - -
- @if($packets_count === 1) -
-
-
-
- - -
-
- - -
-
-
- - -
- - @isset($packet1_options['items']) -
    - @foreach($packet1_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
-
-
- @endif - - @if($packets_count === 3) -
-
-
-
- - -
-
- - -
-
-
- - -
- - @isset($packet1_options['items']) -
    - @foreach($packet1_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
-
-
-
-
-
- - -
-
- - -
-
-
- - -
- - @isset($packet2_options['items']) -
    - @foreach($packet2_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
-
-
-
-
-
- - -
-
- - -
-
-
- - -
- - @isset($packet3_options['items']) -
    - @foreach($packet3_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
+
-
-
-
- ОКАЗАНИЕ УСЛУГ -
-
- - -
+ +
+
+
+ ОКАЗАНИЕ УСЛУГ +
+
+ +
- - @if ($packets_count === 1) -
-
-
-
-
-
- Краткое описание -
- -
-
-
- Цена -
- -
-
-
-
-
- Описание услуги: -
- -
-
- -
-
-
- Содержание услуги -
- @isset($packet1_options['items']) -
    - @foreach ($packet1_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
- -
-
-
-
-
- @endif -
- @if ($packets_count === 3) - - + @if ($packets_count === 1)
@@ -500,7 +241,7 @@ Содержание услуги
@isset($packet1_options['items']) -
    +
      @foreach ($packet1_options['items'] as $item)
    • {{ $item }} @@ -508,166 +249,242 @@ @endforeach
    @endisset -
    -
    - -
    -
    - -
    +
    +
    + + + +
+
+ @endif - - -
-
-
-
-
-
- Краткое описание -
- -
-
-
- Цена - - - 2 вариант - -
- + @if ($packets_count === 3) +
+
+
+
+
+
+ Краткое описание
+
-
-
-
- Описание услуги: -
- +
+
+ Цена + + + 1 вариант +
+
- -
-
-
- Содержание услуги -
- @isset($packet2_options['items']) -
    - @foreach ($packet2_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
- -
+
+
+
+
+ Описание услуги:
+ +
+
+ +
+
+
+ Содержание услуги +
+ @isset($packet1_options['items']) +
    + @foreach ($packet1_options['items'] as $item) +
  • + {{ $item }} +
  • + @endforeach +
+ @endisset + +
+ +
+ + + + +
+
+
+
+
+ + + +
+
+
+
+
+
+ Краткое описание +
+ +
+
+
+ Цена + + + 2 вариант + +
+ +
+
+
+
+
+ Описание услуги: +
+ +
+
+ + +
+
+
+ Содержание услуги +
+ @isset($packet2_options['items']) +
    + @foreach ($packet2_options['items'] as $item) +
  • + {{ $item }} +
  • + @endforeach +
+ @endisset + +
+ +
+ + + + +
+
+ +
+
+
+ + + +
+
+
+
+
+
+ Краткое описание +
+ +
+
+
+ Цена + + + 3 вариант + +
+ +
+
+
+
+
+ Описание услуги: +
+ +
+
+ + +
+
+
+ Содержание услуги +
+ @isset($packet3_options['items']) +
    + @foreach ($packet3_options['items'] as $item) +
  • + {{ $item }} +
  • + @endforeach +
+ @endisset + +
+ +
+ + + +
+
+ +
-
-
-
-
-
-
- Краткое описание -
- -
-
-
- Цена - - - 3 вариант - -
- -
-
-
-
-
- Описание услуги: -
- -
-
- -
-
-
- Содержание услуги -
- @isset($packet3_options['items']) -
    - @foreach ($packet3_options['items'] as $item) -
  • - {{ $item }} -
  • - @endforeach -
- @endisset -
-
- -
-
- -
- -
-
-
-
-
@endif + + + + + + + + + + @if ($errors)
    @@ -687,7 +504,6 @@ class="diet__btn btn btn-primary">Опубликовать
-
- @endif - + +
From 3e74448123f3fe144ccd30c9d63d14ca2be973dd Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sat, 16 Dec 2023 22:19:08 +0300 Subject: [PATCH 03/11] fixed empty items delete in create plan --- app/Livewire/Plan/Create.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Livewire/Plan/Create.php b/app/Livewire/Plan/Create.php index 98bdc2e..9d776d1 100644 --- a/app/Livewire/Plan/Create.php +++ b/app/Livewire/Plan/Create.php @@ -100,6 +100,9 @@ class Create extends Component $this->$options_type['items'][] = $this->input_items_1; $this->$options_type['items'][] = $this->input_items_2; $this->$options_type['items'][] = $this->input_items_3; + + // delete empty value in items + $this->$options_type['items'] = array_filter($this->$options_type['items'], fn($item) => !empty($item)); $this->reset('input_items_1'); $this->reset('input_items_2'); $this->reset('input_items_3'); From 3c9cc8b8fc40dd6374a6e5bf5fd506852a322ddc Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sat, 16 Dec 2023 22:21:31 +0300 Subject: [PATCH 04/11] added show plan page --- app/Livewire/Diet/Comment/Create.php | 7 +++++++ app/Livewire/Plan/Accordion.php | 14 +++++++++++--- app/Livewire/Plan/Comment/Create.php | 13 ++++++++++--- .../views/livewire/plan/accordion.blade.php | 18 ++++++++++-------- .../livewire/plan/comment/create.blade.php | 11 ++++++----- resources/views/plan/show.blade.php | 13 +++++-------- 6 files changed, 49 insertions(+), 27 deletions(-) diff --git a/app/Livewire/Diet/Comment/Create.php b/app/Livewire/Diet/Comment/Create.php index a9cc90b..eb0b6a7 100644 --- a/app/Livewire/Diet/Comment/Create.php +++ b/app/Livewire/Diet/Comment/Create.php @@ -13,14 +13,21 @@ class Create extends Component public User $user; public $body = ''; public $grade = 0; + public $isChecked = true; public function render() { return view('livewire.diet.comment.create'); } + public function toggle() + { + $this->isChecked ? false : true; + } + public function save() { + $this->toggle(); $comment = new DietComment(); $comment->grade = $this->grade; $comment->body = $this->body; diff --git a/app/Livewire/Plan/Accordion.php b/app/Livewire/Plan/Accordion.php index 06dad1b..16cb986 100644 --- a/app/Livewire/Plan/Accordion.php +++ b/app/Livewire/Plan/Accordion.php @@ -16,10 +16,18 @@ class Accordion extends Component public function mount(Plan $plan): void { $this->plan = $plan; - $this->options1 = $plan->packet1_options; - $this->options2 = $plan->packet2_options; - $this->options3 = $plan->packet3_options; + // dd($this->unserializeOptions($plan->packet3_options)); + $this->options1 = $this->unserializeOptions($plan->packet1_options); + $this->options2 = $this->unserializeOptions($plan->packet2_options); + $this->options3 = $this->unserializeOptions($plan->packet3_options); + } + private function unserializeOptions($str) + { + if (preg_match('/^".*"$/', $str)) { + return json_decode(mb_substr($str, 1, -1), true); + } + return json_decode($str, true); } public function render() diff --git a/app/Livewire/Plan/Comment/Create.php b/app/Livewire/Plan/Comment/Create.php index cf89e2c..dd8d29b 100644 --- a/app/Livewire/Plan/Comment/Create.php +++ b/app/Livewire/Plan/Comment/Create.php @@ -2,11 +2,11 @@ namespace App\Livewire\Plan\Comment; -use Livewire\Component; use App\Models\Plan; use App\Models\PlanComment; use App\Models\User; use Livewire\Attributes\Validate; +use Livewire\Component; class Create extends Component { @@ -14,16 +14,21 @@ class Create extends Component public User $user; public $body = ''; public $grade = 0; + public $isChecked = false; public function render() { return view('livewire.plan.comment.create'); } + public function toggle() { + $this->isChecked = !$this->isChecked; + } + public function save() { $this->validate([ - 'body' => 'required|min:10', + 'body' => 'required|min:3', 'grade' => 'required', ]); @@ -33,8 +38,10 @@ class Create extends Component $comment->plan_id = $this->plan->id; $comment->user_id = $this->user->id; $comment->save(); + $this->reset(['body']); + + $this->toggle(); - $this->reset(['body', 'grade']); $this->dispatch('commentAdded')->to('plan.comment.show'); } } diff --git a/resources/views/livewire/plan/accordion.blade.php b/resources/views/livewire/plan/accordion.blade.php index 2626ac2..49233fb 100644 --- a/resources/views/livewire/plan/accordion.blade.php +++ b/resources/views/livewire/plan/accordion.blade.php @@ -3,8 +3,9 @@
diff --git a/resources/views/plan/show.blade.php b/resources/views/plan/show.blade.php index d06a3dd..f256633 100644 --- a/resources/views/plan/show.blade.php +++ b/resources/views/plan/show.blade.php @@ -28,7 +28,7 @@
- thumb + thumb
@@ -86,8 +86,6 @@ {{ $plan->details }}

- {{-- @livewire('plan.like', ['plan' => $plan]) --}} -
- @livewire('plan.accordion', ['plan' => $plan])
@@ -119,8 +116,8 @@ @endsection -@push('jq_scripts') +{{-- @push('jq_scripts') --}} {{-- --}} - - -@endpush + {{-- --}} + {{-- --}} +{{-- @endpush --}} From c887b04631232385e491e80e2cec98f106046735 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sat, 16 Dec 2023 22:39:09 +0300 Subject: [PATCH 05/11] added alert for create comment page --- app/Livewire/Plan/Comment/Create.php | 2 +- .../livewire/plan/comment/create.blade.php | 39 ++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/Livewire/Plan/Comment/Create.php b/app/Livewire/Plan/Comment/Create.php index dd8d29b..fc505c8 100644 --- a/app/Livewire/Plan/Comment/Create.php +++ b/app/Livewire/Plan/Comment/Create.php @@ -13,7 +13,7 @@ class Create extends Component public Plan $plan; public User $user; public $body = ''; - public $grade = 0; + public $grade; public $isChecked = false; public function render() diff --git a/resources/views/livewire/plan/comment/create.blade.php b/resources/views/livewire/plan/comment/create.blade.php index c7c0cda..507b5b0 100644 --- a/resources/views/livewire/plan/comment/create.blade.php +++ b/resources/views/livewire/plan/comment/create.blade.php @@ -1,19 +1,46 @@ +
- $isChecked]) wire:model="isChecked" wire:click="$set('grade', 5)" type="radio" name="rate" id="rate-5" value="5" hidden> + $isChecked]) wire:model="isChecked" wire:click="$set('grade', 5)" type="radio" + name="rate" id="rate-5" value="5" hidden> - $isChecked]) wire:model="isChecked" wire:click="$set('grade',4)" type="radio" name="rate" id="rate-4" value="4" hidden> + $isChecked]) wire:model="isChecked" wire:click="$set('grade',4)" type="radio" + name="rate" id="rate-4" value="4" hidden> - $isChecked]) wire:model="isChecked" wire:click="$set('grade',3)" type="radio" name="rate" id="rate-3" value="3" hidden> + $isChecked]) wire:model="isChecked" wire:click="$set('grade',3)" type="radio" + name="rate" id="rate-3" value="3" hidden> - $isChecked]) wire:model="isChecked" wire:click="$set('grade',2)" type="radio" name="rate" id="rate-2" value="2" hidden> + $isChecked]) wire:model="isChecked" wire:click="$set('grade',2)" type="radio" + name="rate" id="rate-2" value="2" hidden> - $isChecked]) wire:model="isChecked" wire:click="$set('grade',1)" type="radio" name="rate" id="rate-1" value="1" hidden> + $isChecked]) wire:model="isChecked" wire:click="$set('grade',1)" type="radio" + name="rate" id="rate-1" value="1" hidden> - +
+
+
+ + + @error('grade') +
+ {{ $message }} +
+ @enderror + + + + @error('body') +
+ {{ $message }} +
+ @enderror + + +
+ From 14130eb8be558abf7a307da301dca6428e4fbfef Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sat, 16 Dec 2023 23:46:38 +0300 Subject: [PATCH 06/11] added Test for show page --- tests/Feature/Plan/ShowTest.php | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/Feature/Plan/ShowTest.php diff --git a/tests/Feature/Plan/ShowTest.php b/tests/Feature/Plan/ShowTest.php new file mode 100644 index 0000000..a3c60c7 --- /dev/null +++ b/tests/Feature/Plan/ShowTest.php @@ -0,0 +1,60 @@ +image = UploadedFile::fake()->image('plan.png'); + + $this->user = User::factory()->create(['is_consultant' => true]); + $this->plan = Plan::factory()->create(); + + } + + public function test_show_form_success() + { + $response = $this->actingAs($this->user) + ->get('/plan/'. $this->plan->id); + + $response + ->assertStatus(302) + ->assertRedirect('https://dev2.eatvio.com/ru'); + } + + // When appear role for user + // public function test_show_form_is_not_consultant() + // { + // $user = User::factory()->create(['is_consultant' => false]); + + // $response = $this->actingAs($this->user) + // ->get('/plan/'. $this->plan->id); + + // $response + // ->assertStatus(403); + + // } +} From 1b2ff3af4d377b6f738fbac308021b97d691e84f Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 17 Dec 2023 00:42:56 +0300 Subject: [PATCH 07/11] update CreateTest --- tests/Feature/Plan/CreateTest.php | 102 +++++++++++++++++++----------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/tests/Feature/Plan/CreateTest.php b/tests/Feature/Plan/CreateTest.php index ce132e2..e269d0b 100644 --- a/tests/Feature/Plan/CreateTest.php +++ b/tests/Feature/Plan/CreateTest.php @@ -1,29 +1,28 @@ user = User::factory()->create(['is_consultant' => true]); $this->plan = Plan::factory()->make(); - } public function test_show_form_create_plan() { - $response = $this->actingAs($this->user) + $response = $this + ->actingAs($this->user) ->get('/plan/create'); $response @@ -47,66 +46,72 @@ class CreateTest extends TestCase public function test_publish_new_plan_success(): void { - $countPlanBeforeCreated = $this->plan->count(); - $this->actingAs($this->user); + // $this->assertEquals($this->plan->count(), $count = Plan::count()); + Livewire::test(Create::class) ->set('name', $this->plan->name) ->assertSet('name', $this->plan->name) ->set('image', $this->image) ->set('duration', $this->plan->duration) + ->assertSet('duration', $this->plan->duration) ->set('state', $this->plan->state) + ->assertSet('state', $this->plan->state) ->set('type', $this->plan->type) + ->assertSet('type', $this->plan->type) ->set('details', $this->plan->details) + ->assertSet('details', $this->plan->details) ->set('packets_count', $this->plan->packets_count) + ->assertSet('packets_count', $this->plan->packets_count) ->set('packet1_options', $this->plan->packet1_options) + ->assertSet('packet1_options', $this->plan->packet1_options) ->set('packet2_options', $this->plan->packet2_options) + ->assertSet('packet2_options', $this->plan->packet2_options) ->set('packet3_options', $this->plan->packet3_options) + ->assertSet('packet3_options', $this->plan->packet3_options) ->call('publish') - // ->assertFileDownloaded('plan.png'); - ->assertStatus(200) - ->assertRedirect('plan/'.$this->plan->count()); - - $countPlanAfterCreated = $this->plan->count(); + ->assertStatus(200); - $this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated); + // $this->assertEquals($count + 1, Plan::count()); } -// + + // public function test_to_draft_new_plan_success(): void { - $countPlanBeforeCreated = $this->plan->count(); - $this->actingAs($this->user); + $id = $this->plan->count(); + Livewire::test(Create::class) ->set('name', $this->plan->name) ->assertSet('name', $this->plan->name) ->set('image', $this->image) ->set('duration', $this->plan->duration) + ->assertSet('duration', $this->plan->duration) ->set('state', $this->plan->state) + ->assertSet('state', $this->plan->state) ->set('type', $this->plan->type) + ->assertSet('type', $this->plan->type) ->set('details', $this->plan->details) + ->assertSet('details', $this->plan->details) ->set('packets_count', $this->plan->packets_count) + ->assertSet('packets_count', $this->plan->packets_count) ->set('packet1_options', $this->plan->packet1_options) + ->assertSet('packet1_options', $this->plan->packet1_options) ->set('packet2_options', $this->plan->packet2_options) + ->assertSet('packet2_options', $this->plan->packet2_options) ->set('packet3_options', $this->plan->packet3_options) + ->assertSet('packet3_options', $this->plan->packet3_options) ->call('addToDrafts') - // ->assertFileDownloaded('plan.png'); ->assertStatus(200) - ->assertRedirect('plan/'.$this->plan->count()); - - $countPlanAfterCreated = $this->plan->count(); - - $this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated); + ->assertRedirect('plan/' . $id + 1); } -// + + // public function test_to_preview_new_plan_success(): void { - - $countPlanBeforeCreated = $this->plan->count(); - $this->actingAs($this->user); Livewire::test(Create::class) @@ -114,21 +119,42 @@ class CreateTest extends TestCase ->assertSet('name', $this->plan->name) ->set('image', $this->image) ->set('duration', $this->plan->duration) + ->assertSet('duration', $this->plan->duration) ->set('state', $this->plan->state) + ->assertSet('state', $this->plan->state) ->set('type', $this->plan->type) + ->assertSet('type', $this->plan->type) ->set('details', $this->plan->details) + ->assertSet('details', $this->plan->details) ->set('packets_count', $this->plan->packets_count) + ->assertSet('packets_count', $this->plan->packets_count) ->set('packet1_options', $this->plan->packet1_options) + ->assertSet('packet1_options', $this->plan->packet1_options) ->set('packet2_options', $this->plan->packet2_options) + ->assertSet('packet2_options', $this->plan->packet2_options) ->set('packet3_options', $this->plan->packet3_options) + ->assertSet('packet3_options', $this->plan->packet3_options) ->call('showPreview') - // ->assertFileDownloaded('plan.png'); - ->assertStatus(200) - ->assertRedirect('plan/'.$this->plan->count()); - - $countPlanAfterCreated = $this->plan->count(); - - $this->assertEquals($countPlanBeforeCreated + 1, $countPlanAfterCreated); + ->assertStatus(200); } + + public function test_set_empty_data(): void + { + $this->actingAs($this->user); + + Livewire::test(Create::class) + ->set('name', null) + ->set('image', null) + ->set('duration', null) + ->set('state', null) + ->set('type', null) + ->set('details', null) + ->set('packets_count', null) + ->set('packet1_options', null) + ->set('packet2_options', null) + ->set('packet3_options', null) + ->call('publish') + ->assertHasErrors(['name', 'image', 'duration', 'details']); + } } From a99989863f8c3a3e66b3aa1d243d58e5946c6440 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 17 Dec 2023 01:19:00 +0300 Subject: [PATCH 08/11] added upvoted to show comments --- .../views/livewire/plan/comment/show.blade.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/views/livewire/plan/comment/show.blade.php b/resources/views/livewire/plan/comment/show.blade.php index d952cbc..f735b04 100644 --- a/resources/views/livewire/plan/comment/show.blade.php +++ b/resources/views/livewire/plan/comment/show.blade.php @@ -21,9 +21,9 @@
$tabpanelState['negative'] + 'tabpanel--hidden' => $tabpanelState['positive'] ]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1"> - @foreach ($positivComments->get() as $comment) + @foreach ($positivComments->get() as $comment)
@@ -44,7 +44,7 @@
{{ $comment->grade }}
- {{-- @livewire('plan.comment.upvote', ['comment' => $comment]) --}} +
@@ -54,9 +54,9 @@
$tabpanelState['positive'] - ]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1"> - @foreach ($negativeComments->get() as $comment) + 'tabpanel--hidden' => $tabpanelState['negative'] + ]) role="tabpanel" id="tabpanel-2" tabindex="0" aria-labelledby="tab-1"> + @foreach ($negativeComments->get() as $comment)
@@ -77,7 +77,8 @@
{{ $comment->grade }}
- {{-- @livewire('plan.comment.upvote', ['comment' => $comment]) --}} + +
From dbf4d5304da3b63f64657ee4260c5cb282a48c57 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Sun, 17 Dec 2023 18:36:54 +0300 Subject: [PATCH 09/11] 'change negative on positive comments place' --- resources/views/livewire/plan/comment/show.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/plan/comment/show.blade.php b/resources/views/livewire/plan/comment/show.blade.php index f735b04..e874223 100644 --- a/resources/views/livewire/plan/comment/show.blade.php +++ b/resources/views/livewire/plan/comment/show.blade.php @@ -21,7 +21,7 @@
$tabpanelState['positive'] + 'tabpanel--hidden' => $tabpanelState['negative'] ]) role="tabpanel" id="tabpanel-1" tabindex="0" aria-labelledby="tab-1"> @foreach ($positivComments->get() as $comment)
@@ -54,7 +54,7 @@
$tabpanelState['negative'] + 'tabpanel--hidden' => $tabpanelState['positive'] ]) role="tabpanel" id="tabpanel-2" tabindex="0" aria-labelledby="tab-1"> @foreach ($negativeComments->get() as $comment)
From 2a60fe392a5b9279013b0083a72fdcfad76088ce Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 18 Dec 2023 00:04:57 +0300 Subject: [PATCH 10/11] added own style for upvote --- resources/views/livewire/plan/comment/create.blade.php | 3 +-- resources/views/livewire/plan/comment/upvote.blade.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/views/livewire/plan/comment/create.blade.php b/resources/views/livewire/plan/comment/create.blade.php index 507b5b0..92a27a0 100644 --- a/resources/views/livewire/plan/comment/create.blade.php +++ b/resources/views/livewire/plan/comment/create.blade.php @@ -18,9 +18,8 @@ $isChecked]) wire:model="isChecked" wire:click="$set('grade',1)" type="radio" name="rate" id="rate-1" value="1" hidden> -
- +
diff --git a/resources/views/livewire/plan/comment/upvote.blade.php b/resources/views/livewire/plan/comment/upvote.blade.php index 1f8c0a9..58d0e30 100644 --- a/resources/views/livewire/plan/comment/upvote.blade.php +++ b/resources/views/livewire/plan/comment/upvote.blade.php @@ -1,4 +1,4 @@ -
+
From 8d267bee25ea275c51becc1b2ec7968c1dc2351d Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Mon, 18 Dec 2023 13:18:48 +0300 Subject: [PATCH 11/11] clear check assert redirect tests --- tests/Feature/Plan/CreateTest.php | 24 ++++++++++++++++-------- tests/Feature/Plan/ShowTest.php | 5 +++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/Feature/Plan/CreateTest.php b/tests/Feature/Plan/CreateTest.php index e269d0b..11c7092 100644 --- a/tests/Feature/Plan/CreateTest.php +++ b/tests/Feature/Plan/CreateTest.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Storage; use App\Livewire\Plan\Create; use App\Models\Plan; use App\Models\User; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\RefreshDatabase; use Livewire\Features\SupportFileUploads\TemporaryUploadedFile; @@ -40,8 +41,8 @@ class CreateTest extends TestCase ->get('/plan/create'); $response - ->assertStatus(302) - ->assertRedirect('https://dev2.eatvio.com/ru'); + ->assertStatus(302); + // ->assertRedirect(route('home')); } public function test_publish_new_plan_success(): void @@ -71,13 +72,15 @@ class CreateTest extends TestCase ->set('packet3_options', $this->plan->packet3_options) ->assertSet('packet3_options', $this->plan->packet3_options) ->call('publish') - ->assertStatus(200); + ->assertStatus(200) + ->assertHasNoErrors(['name', 'image', 'duration', 'details']); + Storage::disk('public')->assertExists($this->plan->image); // $this->assertEquals($count + 1, Plan::count()); } - // + public function test_to_draft_new_plan_success(): void { $this->actingAs($this->user); @@ -106,10 +109,13 @@ class CreateTest extends TestCase ->assertSet('packet3_options', $this->plan->packet3_options) ->call('addToDrafts') ->assertStatus(200) - ->assertRedirect('plan/' . $id + 1); + ->assertRedirect('plan/' . $id + 1) + ->assertHasNoErrors(['name', 'image', 'duration', 'details']); + + Storage::disk('public')->assertExists($this->plan->image); } - // + public function test_to_preview_new_plan_success(): void { $this->actingAs($this->user); @@ -135,9 +141,11 @@ class CreateTest extends TestCase ->set('packet3_options', $this->plan->packet3_options) ->assertSet('packet3_options', $this->plan->packet3_options) ->call('showPreview') - ->assertStatus(200); - } + ->assertStatus(200) + ->assertHasNoErrors(['name', 'image', 'duration', 'details']); + Storage::disk('public')->assertExists($this->plan->image); + } public function test_set_empty_data(): void { diff --git a/tests/Feature/Plan/ShowTest.php b/tests/Feature/Plan/ShowTest.php index a3c60c7..375435a 100644 --- a/tests/Feature/Plan/ShowTest.php +++ b/tests/Feature/Plan/ShowTest.php @@ -41,8 +41,9 @@ class ShowTest extends TestCase ->get('/plan/'. $this->plan->id); $response - ->assertStatus(302) - ->assertRedirect('https://dev2.eatvio.com/ru'); + ->assertStatus(302); + // ->assertRedirect(route('home')); + // ->assertRedirect('https://dev2.eatvio.com/ru'); } // When appear role for user