create(); $this->actingAs($user) ->get(route('woo.dashboard')) ->assertOk() ->assertSee('Open Afia AI assistant', false) ->assertSee('Woo Manager assistant', false) ->assertSee(route('woo.ai.chat'), false); } public function test_afia_chat_returns_reply_when_enabled(): void { config(['afia.enabled' => true, 'afia.api_key' => 'test-key']); $this->mock(AfiaService::class, function ($mock) { $mock->shouldReceive('enabled')->andReturn(true); $mock->shouldReceive('chat')->once()->andReturn('Install the Ladill plugin and click Connect with Ladill.'); }); $this->actingAs(User::factory()->create()) ->postJson(route('woo.ai.chat'), ['message' => 'How do I connect my store?']) ->assertOk() ->assertJsonPath('reply', 'Install the Ladill plugin and click Connect with Ladill.'); } public function test_afia_chat_uses_platform_relay_when_local_key_missing(): void { config([ 'afia.enabled' => true, 'afia.api_key' => '', 'afia.platform_api_url' => 'https://platform.test/api', 'afia.platform_api_key' => 'woo-relay-key', ]); Http::fake([ 'platform.test/api/afia/chat' => Http::response([ 'reply' => 'Use Sync from store on the Orders page.', ]), ]); $this->actingAs(User::factory()->create()) ->postJson(route('woo.ai.chat'), ['message' => 'How do I sync orders?']) ->assertOk() ->assertJsonPath('reply', 'Use Sync from store on the Orders page.'); } }