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')); } }