Extend integrations hub with more channels, caching, and refresh.

Cache per-store status for five minutes, add TikTok/Reddit/Meta cards, and let merchants refresh without reloading WordPress on every visit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-08 07:37:41 +00:00
co-authored by Cursor
parent 5a0022af72
commit 1b0831b176
8 changed files with 162 additions and 11 deletions
+49 -4
View File
@@ -5,6 +5,7 @@ namespace Tests\Feature;
use App\Models\User;
use App\Models\WooStore;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -29,6 +30,9 @@ class WooIntegrationsTest extends TestCase
->assertSee('Google for WooCommerce')
->assertSee('Pinterest for WooCommerce')
->assertSee('Snapchat for WooCommerce')
->assertSee('TikTok for WooCommerce')
->assertSee('Reddit for WooCommerce')
->assertSee('Meta for WooCommerce')
->assertSee('Connect a WooCommerce store');
}
@@ -93,9 +97,50 @@ class WooIntegrationsTest extends TestCase
->assertSee('Connected')
->assertSee('Manage in WordPress');
Http::assertSent(function ($request) use ($store) {
return $request->url() === 'https://shop.example.com/wp-json/ladill-woo/v1/integrations/status'
&& $request->hasHeader('X-Ladill-Store', $store->public_id);
});
Http::assertSentCount(1);
}
public function test_integrations_status_is_cached_until_refresh(): void
{
config(['woo.integrations_cache_ttl_seconds' => 300]);
$user = User::factory()->create();
$store = WooStore::create([
'user_id' => $user->id,
'site_url' => 'https://shop.example.com',
'site_name' => 'Example Shop',
'status' => WooStore::STATUS_ACTIVE,
'connected_at' => now(),
'public_id' => 'store-public-id',
]);
Http::fake([
'https://shop.example.com/wp-json/ladill-woo/v1/integrations/status' => Http::response([
'integrations' => [
'shipping' => [
'state' => 'connected',
'installed' => true,
'connected' => true,
'manage_url' => 'https://shop.example.com/wp-admin/admin.php?page=wc-settings&tab=shipping',
'summary' => '1 zone, 2 methods',
'details' => ['zones' => 1, 'methods' => 2],
],
],
], 200),
]);
$this->actingAs($user)->get(route('woo.integrations.index'))->assertOk();
$this->actingAs($user)->get(route('woo.integrations.index'))->assertOk();
Http::assertSentCount(1);
$this->actingAs($user)
->post(route('woo.integrations.refresh'))
->assertRedirect(route('woo.integrations.index'));
$this->actingAs($user)->get(route('woo.integrations.index'))->assertOk();
Http::assertSentCount(2);
$this->assertTrue(Cache::has('woo.integrations.'.$store->id));
}
}