Bläddra i källkod

Add category design guides for the AI

- One guide per store category with 2-3 directions and claims to avoid
- AI told the merchant's other stores and current design, to avoid repeats
- Test that guides only name real fonts and layouts
redesign/part-6-category-guides
fahmisaad 5 dagar sedan
förälder
incheckning
298e9bb671
5 ändrade filer med 310 tillägg och 6 borttagningar
  1. 10
    4
      PROGRESS.md
  2. 2
    2
      README.md
  3. 105
    0
      app/StorePlan/Ai/CategoryGuides.php
  4. 84
    0
      app/StorePlan/Ai/PlanPrompt.php
  5. 109
    0
      tests/Feature/Ai/CategoryGuideTest.php

+ 10
- 4
PROGRESS.md Visa fil

@@ -3,9 +3,9 @@
3 3
 This file is the single source of truth for the project plan and status.
4 4
 Update it at the end of every work session.
5 5
 
6
-**Last updated:** 2026-11-19
7
-**Current step:** Step 9 — Modern store design (parts 1–5 done; next: part 6, category guides)
8
-**Next action:** Commit part 5 on `redesign/part-5-section-layouts` (do not merge into `main` yet). Then create `redesign/part-6-category-guides` from it and write the category guides. Step 7 part 2 still waits for an EasyParcel API key
6
+**Last updated:** 2026-11-21
7
+**Current step:** Step 9 — Modern store design (parts 1–6 done; next: part 7, collections, bento, video and reviews)
8
+**Next action:** Commit part 6 on `redesign/part-6-category-guides` (do not merge into `main` yet). Then decide: part 7 (collections, bento, video, reviews) on `redesign/part-7-...`, or merge the redesign into `main` first. Step 7 part 2 still waits for an EasyParcel API key
9 9
 
10 10
 Status marks: `[ ]` not started · `[~]` in progress · `[x]` done
11 11
 
@@ -253,6 +253,10 @@ Changing from Claude to another AI model (or back) must be a settings change, no
253 253
 - The brand description decides the details, so two stores in the same category still look different (bold streetwear versus elegant modest wear).
254 254
 - Guides live in our code and can be improved any time. They only suggest styles and layouts the store can really show, so they are written after the style options and extra layouts exist (Step 9 parts 4 and 5).
255 255
 - To avoid repeats, the AI is told not to copy the example design and, for a merchant's second store, what their first store looks like.
256
+- Built in Step 9 part 6: `App\StorePlan\Ai\CategoryGuides` holds the guides; each offers 2 or 3 directions (for example Fashion: editorial, street and youth, modest and graceful) and the AI picks or mixes by the brand description. Each guide also says which claims never to make for that category (halal, health, certifications, specifications and so on).
257
+- `PlanPrompt::looksToAvoid()` lists up to 5 of the merchant's other stores and, on a redesign, the store's current design, each as a one-line summary (colours, fonts, corners, style, home layouts). Other merchants' stores are never included.
258
+- A test checks every guide only names fonts and layouts that exist, so a guide cannot point the AI at something the store cannot show.
259
+- Real test with Claude Sonnet: a Kelantanese food store came out dark and warm (Fraunces and Nunito, alternating bands, full-photo hero, "Cooked in Kota Bharu" trust point from the description); a modest-wear store came out ivory and elegant (Cormorant Garamond and Jost, spaced capitals, outline buttons, large product cards), and both differed from the merchant's existing stores.
256 260
 
257 261
 ### AI edits must really change something (added 2026-11-16)
258 262
 
@@ -389,7 +393,7 @@ Agreed on 2026-11-17 after comparing our stores with 2026 design trends (researc
389 393
 - [x] Part 3 — Product page upgrade (done 2026-11-18): trust points under the button, folding sections (the product's own, such as "How to use", plus shipping from real fees), sticky add-to-cart bar on phones, "pairs well with", photos that stay in view on wide screens, and a phone menu for the header
390 394
 - [x] Part 4 — Style options and motion (done 2026-11-19): six style options (buttons, cards, spacing, headings, backgrounds, motion), six ready-made looks in a Style box in the Design tab, 12 more fonts (20 in all), gentle fade-in motion, and AI rules so each brand gets a fitting style
391 395
 - [x] Part 5 — More layouts per section (done 2026-11-19): 7 new layouts, so the main sections have 3 or 4 each, and a Layouts box in the Design tab
392
-- [ ] Part 6 — Category guides for the AI (see section 2)
396
+- [x] Part 6 — Category guides for the AI (done 2026-11-21): one guide per category with 2 or 3 directions each, plus the merchant's other stores (and the current design on a redesign) as looks not to repeat
393 397
 - [ ] Part 7 — Collections ("shop by need" tiles and menu links), bento grid section, video section, real reviews from buyers after delivery
394 398
 
395 399
 Branches (agreed 2026-11-18):
@@ -503,6 +507,7 @@ Then, from the project folder:
503 507
 | Product page, phone menu               | `storefront/pages/product.tsx`, `app/Storefront/RelatedProducts.php`, `components/stores/details-editor.tsx`, `storefront/sections/header.tsx`                                         |
504 508
 | Store styles                           | `PlanSchema::STYLE_OPTIONS` and `STYLE_PRESETS`, `StoreStyleController`, `storefront/theme.ts`, `storefront/reveal.tsx`, `resources/css/app.css`, `components/stores/style-picker.tsx` |
505 509
 | Section layouts                        | `PlanSchema::SECTIONS`, `app/StorePlan/SectionLayouts.php`, `SectionLayoutController`, `storefront/sections/*.tsx`, `components/stores/layout-picker.tsx`                              |
510
+| Category guides                        | `app/StorePlan/Ai/CategoryGuides.php`, `PlanPrompt::categoryGuide()` and `looksToAvoid()`                                                                                              |
506 511
 | Storefront words (English, Malay)      | `resources/js/storefront/text.ts`                                                                                                                                                      |
507 512
 | Store plan format (frontend types)     | `resources/js/storefront/types.ts`                                                                                                                                                     |
508 513
 | Storefront renderer and sections       | `resources/js/storefront/renderer.tsx`, `resources/js/storefront/sections/`                                                                                                            |
@@ -565,3 +570,4 @@ Add one line per work session: date, what was done, what is next.
565 570
 | 2026-11-18 | Step 9 part 3 on branch `redesign/part-3-product-page` (from part 2): folding sections (form, chat with merge by title), trust points, sticky phone add-to-cart bar, pairs well with, phone menu, sticky photos. Found and fixed the sticky bar hiding under the header. 261 tests pass; real DeepSeek wrote a sensible "How to use" for the sunscreen (confirmed); checked at phone width.                                                                        | Commit; part 4 branches from part 3                             |
566 571
 | 2026-11-19 | Step 9 part 4 on branch `redesign/part-4-style-options` (from part 3): style options, six ready-made looks with a Style box, 12 more fonts, gentle motion, AI style rules. Fixed fade-in hiding a section that was already partly on screen. "More layouts per section" moved to a new part 5; category guides are now part 6 and collections part 7. 266 tests pass; Bold look and a real DeepSeek "more premium and elegant" change both checked in the browser. | Commit; part 5 branches from part 4                             |
567 572
 | 2026-11-19 | Step 9 part 5 on branch `redesign/part-5-section-layouts` (from part 4): 7 new section layouts (products carousel and large, featured stacked, about statement, reviews wall, FAQ cards, newsletter split, footer columns) and a Layouts box. 270 tests pass; every layout checked in the browser on Luna Skin; long About statements now shown a step smaller.                                                                                                    | Commit; part 6 branches from part 5                             |
573
+| 2026-11-21 | Step 9 part 6 on branch `redesign/part-6-category-guides` (from part 5): category design guides and "looks to avoid" for the AI. 275 tests pass; generated two real test stores with Claude Sonnet (Dapur Mak Teh, food; Seri Anggun, fashion) and they came out clearly different.                                                                                                                                                                                | Commit; then part 7 or merge                                    |

+ 2
- 2
README.md Visa fil

@@ -21,7 +21,7 @@ An AI store generator for ecommerce. A customer describes their brand, and the A
21 21
 | 6    | Our own subscription billing                            | Done                                                           |
22 22
 | 7    | Malaysia features: FPX, DuitNow, EasyParcel, WhatsApp   | Part 1 done (shipping fees, WhatsApp); EasyParcel and FPX next |
23 23
 | 8    | Discounts and product options: codes, variants, bundles | Done                                                           |
24
-| 9    | Modern store design: photos, styles, category guides    | In progress: parts 1–5 done; part 6 next                       |
24
+| 9    | Modern store design: photos, styles, category guides    | In progress: parts 1–6 done; part 7 next                       |
25 25
 | 10   | Before launch: hosting, legal pages, backups            | Not started                                                    |
26 26
 
27 27
 ## What works today
@@ -32,7 +32,7 @@ An AI store generator for ecommerce. A customer describes their brand, and the A
32 32
 - A saved design for each store, called a **store plan**
33 33
 - 10 storefront sections, each with 2 layouts: header, hero, product grid, featured product, about, testimonials, FAQ, newsletter, contact, footer
34 34
 - A live preview of the storefront inside the dashboard, at desktop and mobile size
35
-- "Generate my store": the AI designs the whole store in the background, with a progress screen
35
+- "Generate my store": the AI designs the whole store in the background, with a progress screen. A design guide for the store's category gives it a starting direction, and it avoids repeating the merchant's other stores
36 36
 - Change the design by chat, for example "make the main colour dark green"
37 37
 - Hero banner with a big photo (full width, or beside the words): upload a banner photo or pick a product photo in the Design tab. With no choice, the newest product photo is used
38 38
 - Product cards show a second photo on hover

+ 105
- 0
app/StorePlan/Ai/CategoryGuides.php Visa fil

@@ -0,0 +1,105 @@
1
+<?php
2
+
3
+namespace App\StorePlan\Ai;
4
+
5
+use App\Enums\StoreCategory;
6
+
7
+/**
8
+ * A short design guide for each store category, sent to the AI with the brand description.
9
+ *
10
+ * A guide is a starting direction, not a template. Each one offers two or three directions and the AI picks
11
+ * (or mixes) whichever fits the merchant's own words, so two stores in one category still look different.
12
+ * Guides only name styles, fonts and layouts the store can really show (see PlanSchema).
13
+ * "Other" has no guide: the brand description alone decides.
14
+ */
15
+final class CategoryGuides
16
+{
17
+    /**
18
+     * @var array<string, string>
19
+     */
20
+    private const array GUIDES = [
21
+        'fashion' => <<<'TEXT'
22
+        Fashion stores sell a look and a feeling first; photos do most of the work.
23
+        Possible directions (pick what the description suggests, or mix):
24
+        - Editorial: "image-full" hero, spaced-capital or serif headings (cormorant-garamond, playfair-display, dm-serif-display), plain cards, airy spacing, outline buttons, product_grid "large".
25
+        - Street and youth: heavy headings (archivo-black, bebas-neue, unbounded), hard cards, shadow buttons, alternating bands, product_grid "carousel".
26
+        - Modest and graceful: soft neutral colours, serif headings with a clean body (jost, dm-sans), soft-shadow cards, airy spacing.
27
+        Sections that usually help: a big photo hero, products early, featured_product "stacked" for a new collection, about "statement" for the brand story.
28
+        Copy: short and confident. Talk about fit, fabric feel and occasions only as the description gives them.
29
+        TEXT,
30
+
31
+        'beauty' => <<<'TEXT'
32
+        Beauty and skincare stores must feel clean, calm and trustworthy.
33
+        Possible directions:
34
+        - Clinical calm: light neutral colours with one soft accent, plain or thin-line cards, airy spacing, normal headings (manrope, dm-sans, outfit), solid buttons.
35
+        - Luxe: warm ivory or deep colours, serif headings (cormorant-garamond, fraunces), spaced-capital headings, outline buttons.
36
+        - Playful colour cosmetics: brighter palette, rounded corners, soft-shadow cards, heavy headings (bricolage-grotesque).
37
+        Sections that usually help: a trust row early, a routine or "how to use" story, faq "cards" for skin questions, reviews.
38
+        Copy: gentle and specific. Never promise results, cures or medical effects, and never claim halal, dermatologist tested or organic unless the description says so.
39
+        TEXT,
40
+
41
+        'food' => <<<'TEXT'
42
+        Food and drink stores should look warm, appetising and homely.
43
+        Possible directions:
44
+        - Home kitchen: warm colours (chilli red, turmeric, pandan green, cream), rounded corners, soft-shadow cards, friendly headings (fraunces, bricolage-grotesque, nunito body), alternating bands.
45
+        - Bold snacks and drinks: bright colours, heavy headings (archivo-black, bebas-neue, unbounded), shadow buttons, hard cards, product_grid "carousel".
46
+        - Premium gifts and bakes: deep or cream palette, serif headings, airy spacing, outline buttons, featured_product "stacked".
47
+        Sections that usually help: products early, a "how it's made" about story, reviews high up (testimonials "wall" if there are 3 or more), a trust row with delivery, faq about shelf life and delivery.
48
+        Copy: describe taste, texture and how people eat it. Never claim halal, no-preservatives, homemade or award-winning unless the description says so.
49
+        TEXT,
50
+
51
+        'home' => <<<'TEXT'
52
+        Home and living stores sell a calm, lived-in feeling.
53
+        Possible directions:
54
+        - Warm minimal: earthy neutrals, plain cards, airy spacing, clean headings (manrope, jost) or a soft serif (lora, fraunces), solid buttons.
55
+        - Crafted and natural: natural greens and browns, serif headings, thin-line cards, about "statement" for the maker's story.
56
+        - Bright and modern: one bold accent colour, soft-shadow cards, rounded corners, product_grid "large".
57
+        Sections that usually help: a big photo hero, products in "large" or "grid", an about story, a trust row with delivery, faq about sizes and care.
58
+        Copy: describe the room, the mood and daily use. Never invent materials, sizes or origins.
59
+        TEXT,
60
+
61
+        'electronics' => <<<'TEXT'
62
+        Electronics and gadget stores must look sharp, modern and reliable.
63
+        Possible directions:
64
+        - Tech clean: white or very dark background with one bright accent, small or no corners, thin-line cards, clean headings (space-grotesk, manrope, inter body), compact or normal spacing.
65
+        - Futuristic: dark palette, headings in unbounded or syne, hard or soft-shadow cards, gentle motion.
66
+        Sections that usually help: a "split" hero with the product, a trust row (delivery, secure payment, WhatsApp support), featured_product for the hero product, faq "cards" for compatibility and warranty questions.
67
+        Copy: clear and practical, short sentences. Never invent specifications, warranty terms or certifications.
68
+        TEXT,
69
+
70
+        'health' => <<<'TEXT'
71
+        Health and wellness stores must feel calm, honest and trustworthy.
72
+        Possible directions:
73
+        - Calm natural: soft greens, blues or sand, plain or thin-line cards, airy spacing, gentle headings (outfit, nunito, lora), solid buttons.
74
+        - Active and energetic: brighter accent, heavy headings (bricolage-grotesque, space-grotesk), soft-shadow cards, alternating bands.
75
+        Sections that usually help: a trust row early, a clear about story, faq "cards", reviews.
76
+        Copy: careful and plain. Never make health, medical, weight-loss or cure claims, and never mention certifications unless the description says so.
77
+        TEXT,
78
+
79
+        'kids' => <<<'TEXT'
80
+        Baby and kids stores should feel friendly, safe and cheerful, and parents are the buyers.
81
+        Possible directions:
82
+        - Soft pastel: pastel palette, large or full corners, soft-shadow cards, rounded headings (nunito, outfit, bricolage-grotesque), airy spacing.
83
+        - Bright and playful: bold primary colours, heavy headings, shadow buttons, alternating bands, product_grid "carousel".
84
+        Sections that usually help: products early, a trust row, faq about ages and safety, reviews from parents.
85
+        Copy: warm and simple, written for parents. Never claim safety certifications or age ratings unless the description gives them.
86
+        TEXT,
87
+
88
+        'digital' => <<<'TEXT'
89
+        Digital product stores, such as templates, courses, e-books or presets, sell what the buyer gets straight away.
90
+        Possible directions:
91
+        - Creator studio: bold accent, heavy or display headings (syne, unbounded, bricolage-grotesque), soft-shadow or hard cards, gentle motion.
92
+        - Clean professional: neutral palette, clean headings (manrope, inter), thin-line cards, compact spacing.
93
+        Sections that usually help: a "split" hero, a featured_product for the main offer, about "statement" for who made it, faq "cards" about how delivery works, reviews.
94
+        Copy: say exactly what the buyer receives and how they use it. Do not use the shipping item in a trust row; use custom items only with facts from the description.
95
+        TEXT,
96
+    ];
97
+
98
+    /**
99
+     * The guide for a category, or null for "Other".
100
+     */
101
+    public static function for(StoreCategory $category): ?string
102
+    {
103
+        return self::GUIDES[$category->value] ?? null;
104
+    }
105
+}

+ 84
- 0
app/StorePlan/Ai/PlanPrompt.php Visa fil

@@ -61,6 +61,8 @@ final class PlanPrompt
61 61
         $language = $store->language->value === 'ms' ? 'Bahasa Malaysia' : 'English';
62 62
         $products = self::productList($store);
63 63
         $photos = self::photoList($store);
64
+        $guide = self::categoryGuide($store);
65
+        $avoid = self::looksToAvoid($store);
64 66
 
65 67
         return <<<TEXT
66 68
         Design a store for this brand.
@@ -73,11 +75,93 @@ final class PlanPrompt
73 75
         """
74 76
         {$store->description}
75 77
         """
78
+        {$guide}
79
+        {$avoid}
76 80
         {$products}
77 81
         {$photos}
78 82
         TEXT;
79 83
     }
80 84
 
85
+    /**
86
+     * The design guide for the store's category, as a starting direction. Empty for "Other".
87
+     */
88
+    public static function categoryGuide(Store $store): string
89
+    {
90
+        $guide = CategoryGuides::for($store->category);
91
+
92
+        if ($guide === null) {
93
+            return '';
94
+        }
95
+
96
+        return <<<TEXT
97
+
98
+        Design guide for {$store->category->label()} stores. It is a starting direction, not a template: choose the direction (or mix) that fits the description above, and let the brand's own words decide the details.
99
+        {$guide}
100
+        TEXT;
101
+    }
102
+
103
+    /**
104
+     * Looks this design must not repeat: the merchant's other stores, and this store's current design when
105
+     * it is being redesigned. Empty when there are none.
106
+     */
107
+    public static function looksToAvoid(Store $store): string
108
+    {
109
+        $lines = [];
110
+
111
+        if (is_array($store->plan)) {
112
+            $lines[] = '- This store\'s current design, which the merchant wants replaced: '.self::lookSummary($store->plan);
113
+        }
114
+
115
+        $others = Store::query()
116
+            ->where('user_id', $store->user_id)
117
+            ->whereKeyNot($store->id)
118
+            ->whereNotNull('plan')
119
+            ->latest('id')
120
+            ->limit(5)
121
+            ->get();
122
+
123
+        foreach ($others as $other) {
124
+            if (is_array($other->plan)) {
125
+                $lines[] = "- The merchant's store \"{$other->name}\": ".self::lookSummary($other->plan);
126
+            }
127
+        }
128
+
129
+        if ($lines === []) {
130
+            return '';
131
+        }
132
+
133
+        $list = implode("\n", $lines);
134
+
135
+        return <<<TEXT
136
+
137
+        Make this design clearly different from these looks (other colours, fonts, style and layouts):
138
+        {$list}
139
+        TEXT;
140
+    }
141
+
142
+    /**
143
+     * A short description of a design's look: colours, fonts, corners, style and layouts.
144
+     *
145
+     * @param  array<string, mixed>  $plan
146
+     */
147
+    public static function lookSummary(array $plan): string
148
+    {
149
+        $theme = is_array($plan['theme'] ?? null) ? $plan['theme'] : [];
150
+        $colors = is_array($theme['colors'] ?? null) ? $theme['colors'] : [];
151
+        $style = [...PlanSchema::STYLE_DEFAULTS, ...(is_array($theme['style'] ?? null) ? $theme['style'] : [])];
152
+        $layouts = [];
153
+
154
+        foreach ($plan['pages'][0]['sections'] ?? [] as $section) {
155
+            $layouts[] = ($section['type'] ?? '?').' '.($section['variant'] ?? '?');
156
+        }
157
+
158
+        return 'background '.($colors['background'] ?? '?').', primary '.($colors['primary'] ?? '?')
159
+            .'; fonts '.($theme['fonts']['heading'] ?? '?').' / '.($theme['fonts']['body'] ?? '?')
160
+            .'; radius '.($theme['radius'] ?? '?')
161
+            .'; style '.implode(', ', array_map(fn (string $key, string $value) => "$key $value", array_keys($style), $style))
162
+            .'; home sections: '.implode(', ', $layouts);
163
+    }
164
+
81 165
     /**
82 166
      * Photos a hero may use, by the name the "image" field takes. Empty when the store has none.
83 167
      */

+ 109
- 0
tests/Feature/Ai/CategoryGuideTest.php Visa fil

@@ -0,0 +1,109 @@
1
+<?php
2
+
3
+namespace Tests\Feature\Ai;
4
+
5
+use App\Enums\StoreCategory;
6
+use App\Models\Store;
7
+use App\Models\User;
8
+use App\StorePlan\Ai\CategoryGuides;
9
+use App\StorePlan\Ai\PlanPrompt;
10
+use App\StorePlan\PlanSchema;
11
+use App\StorePlan\SamplePlan;
12
+use Illuminate\Foundation\Testing\RefreshDatabase;
13
+use Tests\Support\ScriptedDriver;
14
+use Tests\TestCase;
15
+
16
+class CategoryGuideTest extends TestCase
17
+{
18
+    use RefreshDatabase;
19
+
20
+    public function test_every_category_except_other_has_a_guide()
21
+    {
22
+        foreach (StoreCategory::cases() as $category) {
23
+            $guide = CategoryGuides::for($category);
24
+
25
+            if ($category === StoreCategory::Other) {
26
+                $this->assertNull($guide);
27
+            } else {
28
+                $this->assertNotNull($guide, $category->value);
29
+                $this->assertStringContainsString('Possible directions', $guide);
30
+            }
31
+        }
32
+    }
33
+
34
+    public function test_guides_only_name_fonts_and_layouts_the_store_really_has()
35
+    {
36
+        $variants = array_merge(...array_values(PlanSchema::SECTIONS));
37
+
38
+        foreach (StoreCategory::cases() as $category) {
39
+            $guide = (string) CategoryGuides::for($category);
40
+
41
+            // Font lists are written in brackets: (cormorant-garamond, playfair-display).
42
+            preg_match_all('/\(([a-z0-9-]+(?:, [a-z0-9-]+)*(?:,? (?:or|and) [a-z0-9-]+)?)(?: body)?\)/', $guide, $lists);
43
+
44
+            foreach ($lists[1] as $list) {
45
+                foreach (preg_split('/,? (?:or|and) |, /', $list) as $font) {
46
+                    $this->assertArrayHasKey($font, PlanSchema::FONTS, "{$category->value}: unknown font [$font]");
47
+                }
48
+            }
49
+
50
+            // Layouts are written in quotes: "carousel".
51
+            preg_match_all('/"([a-z-]+)"/', $guide, $quoted);
52
+
53
+            foreach ($quoted[1] as $layout) {
54
+                $this->assertContains($layout, $variants, "{$category->value}: unknown layout [$layout]");
55
+            }
56
+        }
57
+    }
58
+
59
+    public function test_the_ai_gets_the_guide_for_the_store_category()
60
+    {
61
+        ScriptedDriver::use([(string) json_encode(SamplePlan::forName('Kedai Ali'))]);
62
+
63
+        $user = User::factory()->create();
64
+        $store = Store::factory()->for($user)->create(['category' => StoreCategory::Food]);
65
+
66
+        $this->actingAs($user)->post(route('stores.generate', $store->slug));
67
+
68
+        $prompt = ScriptedDriver::$requests[0]->prompt;
69
+        $this->assertStringContainsString('Design guide for Food & beverage stores', $prompt);
70
+        $this->assertStringContainsString('Home kitchen', $prompt);
71
+        $this->assertStringNotContainsString('Make this design clearly different', $prompt);
72
+    }
73
+
74
+    public function test_other_stores_get_no_guide()
75
+    {
76
+        $store = Store::factory()->create(['category' => StoreCategory::Other]);
77
+
78
+        $this->assertSame('', PlanPrompt::categoryGuide($store));
79
+        $this->assertStringNotContainsString('Design guide', PlanPrompt::generatePrompt($store));
80
+    }
81
+
82
+    public function test_the_ai_is_told_not_to_repeat_the_merchants_other_stores_or_the_current_design()
83
+    {
84
+        $user = User::factory()->create();
85
+        $first = Store::factory()->for($user)->create(['name' => 'Sambal Nenek']);
86
+        $first->plan = SamplePlan::for($first);
87
+        $first->save();
88
+
89
+        // Someone else's store is never mentioned.
90
+        $stranger = Store::factory()->create(['name' => 'Not Yours']);
91
+        $stranger->plan = SamplePlan::for($stranger);
92
+        $stranger->save();
93
+
94
+        $second = Store::factory()->for($user)->create(['name' => 'Kopi Pagi']);
95
+        $prompt = PlanPrompt::generatePrompt($second);
96
+
97
+        $this->assertStringContainsString('Make this design clearly different', $prompt);
98
+        $this->assertStringContainsString('The merchant\'s store "Sambal Nenek": background #FBF7F0', $prompt);
99
+        $this->assertStringContainsString('fonts fraunces / dm-sans', $prompt);
100
+        $this->assertStringContainsString('home sections: hero split, trust_bar row', $prompt);
101
+        $this->assertStringNotContainsString('Not Yours', $prompt);
102
+
103
+        // A redesign also avoids the store's own current look.
104
+        $second->plan = SamplePlan::for($second);
105
+        $second->save();
106
+
107
+        $this->assertStringContainsString("This store's current design, which the merchant wants replaced", PlanPrompt::generatePrompt($second));
108
+    }
109
+}

Laddar…
Avbryt
Spara