AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StoreDesignTest.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Tests\Feature\Stores;
  3. use App\Models\Store;
  4. use App\Models\User;
  5. use App\StorePlan\SamplePlan;
  6. use Illuminate\Foundation\Testing\RefreshDatabase;
  7. use Inertia\Testing\AssertableInertia as Assert;
  8. use Tests\TestCase;
  9. class StoreDesignTest extends TestCase
  10. {
  11. use RefreshDatabase;
  12. public function test_a_new_store_has_no_design()
  13. {
  14. $user = User::factory()->create();
  15. $store = Store::factory()->for($user)->create();
  16. $this->actingAs($user)
  17. ->get(route('stores.show', $store->slug))
  18. ->assertInertia(fn (Assert $page) => $page->where('store.has_design', false));
  19. $this->actingAs($user)->get(route('stores.preview', $store->slug))->assertNotFound();
  20. }
  21. public function test_a_user_can_preview_a_store_that_has_a_design()
  22. {
  23. $user = User::factory()->create();
  24. $store = Store::factory()->for($user)->create(['name' => 'Sambal Nenek']);
  25. $store->plan = SamplePlan::for($store);
  26. $store->save();
  27. $this->actingAs($user)
  28. ->get(route('stores.preview', $store->slug))
  29. ->assertOk()
  30. ->assertInertia(fn (Assert $page) => $page
  31. ->component('stores/preview')
  32. ->where('storeName', 'Sambal Nenek')
  33. ->has('plan.sections', 10)
  34. ->has('fonts.inter'));
  35. }
  36. public function test_a_user_cannot_preview_someone_elses_store()
  37. {
  38. $user = User::factory()->create();
  39. $store = Store::factory()->create();
  40. $store->plan = SamplePlan::for($store);
  41. $store->save();
  42. $this->actingAs($user)->get(route('stores.preview', $store->slug))->assertNotFound();
  43. }
  44. public function test_guests_cannot_preview_a_store()
  45. {
  46. $store = Store::factory()->create();
  47. $this->get(route('stores.preview', $store->slug))->assertRedirect(route('login'));
  48. }
  49. }