Add Integrations hub for Woo marketing and shipping extensions.
Surface Google, Pinterest, Snapchat, and shipping status from the WordPress plugin with deep links to finish setup in WooCommerce. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WooStore;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WooIntegrationsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_guest_is_redirected_from_integrations(): void
|
||||
{
|
||||
$this->get(route('woo.integrations.index'))
|
||||
->assertRedirect(route('sso.connect', ['redirect' => route('woo.integrations.index')]));
|
||||
}
|
||||
|
||||
public function test_integrations_page_without_store_shows_catalog(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('woo.integrations.index'))
|
||||
->assertOk()
|
||||
->assertSee('Integrations')
|
||||
->assertSee('Google for WooCommerce')
|
||||
->assertSee('Pinterest for WooCommerce')
|
||||
->assertSee('Snapchat for WooCommerce')
|
||||
->assertSee('Connect a WooCommerce store');
|
||||
}
|
||||
|
||||
public function test_integrations_page_fetches_status_from_plugin(): void
|
||||
{
|
||||
$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' => '2 zones, 4 methods',
|
||||
'details' => ['zones' => 2, 'methods' => 4],
|
||||
],
|
||||
'google' => [
|
||||
'state' => 'needs_setup',
|
||||
'installed' => true,
|
||||
'connected' => false,
|
||||
'manage_url' => 'https://shop.example.com/wp-admin/admin.php?page=wc-admin&path=/google/start',
|
||||
'summary' => 'Installed — finish setup in WordPress.',
|
||||
'details' => [],
|
||||
],
|
||||
'pinterest' => [
|
||||
'state' => 'not_installed',
|
||||
'installed' => false,
|
||||
'connected' => false,
|
||||
'manage_url' => null,
|
||||
'summary' => 'Extension is not installed on this store.',
|
||||
'details' => [],
|
||||
],
|
||||
'snapchat' => [
|
||||
'state' => 'connected',
|
||||
'installed' => true,
|
||||
'connected' => true,
|
||||
'manage_url' => 'https://shop.example.com/wp-admin/admin.php?page=wc-admin&path=/snapchat/setup',
|
||||
'summary' => 'Connected and ready.',
|
||||
'details' => [],
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('woo.integrations.index'))
|
||||
->assertOk()
|
||||
->assertSee('Example Shop')
|
||||
->assertSee('2 zones, 4 methods')
|
||||
->assertSee('Needs setup')
|
||||
->assertSee('Not installed')
|
||||
->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);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class WooMobileNavTest extends TestCase
|
||||
->assertSee('>Profile</span>', false);
|
||||
}
|
||||
|
||||
public function test_desktop_store_switcher_renders_after_search_form(): void
|
||||
public function test_desktop_store_switcher_renders_before_afia(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
WooStore::create([
|
||||
@@ -48,11 +48,11 @@ class WooMobileNavTest extends TestCase
|
||||
->assertOk()
|
||||
->getContent();
|
||||
|
||||
$searchPos = strpos($html, 'Search orders…');
|
||||
$switcherPos = strpos($html, 'Example Shop');
|
||||
$afiaPos = strpos($html, 'afia');
|
||||
|
||||
$this->assertNotFalse($searchPos);
|
||||
$this->assertNotFalse($switcherPos);
|
||||
$this->assertLessThan($switcherPos, $searchPos);
|
||||
$this->assertNotFalse($afiaPos);
|
||||
$this->assertLessThan($afiaPos, $switcherPos);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user