| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
-
- namespace Tests\Feature\Stores;
-
- use App\Models\Store;
- use App\Models\User;
- use App\StorePlan\SamplePlan;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Inertia\Testing\AssertableInertia as Assert;
- use Tests\TestCase;
-
- class StoreDesignTest extends TestCase
- {
- use RefreshDatabase;
-
- public function test_a_new_store_has_no_design()
- {
- $user = User::factory()->create();
- $store = Store::factory()->for($user)->create();
-
- $this->actingAs($user)
- ->get(route('stores.show', $store->slug))
- ->assertInertia(fn (Assert $page) => $page->where('store.has_design', false));
-
- $this->actingAs($user)->get(route('stores.preview', $store->slug))->assertNotFound();
- }
-
- public function test_a_user_can_preview_a_store_that_has_a_design()
- {
- $user = User::factory()->create();
- $store = Store::factory()->for($user)->create(['name' => 'Sambal Nenek']);
- $store->plan = SamplePlan::for($store);
- $store->save();
-
- $this->actingAs($user)
- ->get(route('stores.preview', $store->slug))
- ->assertOk()
- ->assertInertia(fn (Assert $page) => $page
- ->component('stores/preview')
- ->where('storeName', 'Sambal Nenek')
- ->has('plan.sections', 10)
- ->has('fonts.inter'));
- }
-
- public function test_a_user_cannot_preview_someone_elses_store()
- {
- $user = User::factory()->create();
- $store = Store::factory()->create();
- $store->plan = SamplePlan::for($store);
- $store->save();
-
- $this->actingAs($user)->get(route('stores.preview', $store->slug))->assertNotFound();
- }
-
- public function test_guests_cannot_preview_a_store()
- {
- $store = Store::factory()->create();
-
- $this->get(route('stores.preview', $store->slug))->assertRedirect(route('login'));
- }
- }
|