Skip to content

Commit

Permalink
Add test to validate integration history creation
Browse files Browse the repository at this point in the history
  • Loading branch information
arfenis committed Sep 17, 2024
1 parent 83e0396 commit 66e8e67
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Kanvas\Apps\Models\Apps;
use Kanvas\Connectors\Shopify\Workflows\Activities\ExportProductToShopifyActivity;
use Kanvas\Inventory\Products\Models\Products;
use Kanvas\Workflow\Integrations\Models\EntityIntegrationHistory;
use Kanvas\Workflow\Integrations\Services\EntityIntegrationHistoryService;
use Kanvas\Workflow\Models\Integrations;
use Kanvas\Workflow\Models\StoredWorkflow;
use Tests\Connectors\Traits\HasShopifyConfiguration;
use Tests\TestCase;
Expand Down Expand Up @@ -38,9 +41,48 @@ public function testExportProductWorkflow(): void
params: []
);

//We need to DELETE the exported product after the test.
//@todo We need to DELETE the exported product after the test.
$this->assertArrayHasKey('shopify_response', $result);
$this->assertArrayHasKey('company', $result);
$this->assertArrayHasKey('product', $result);
}

public function testIntegrationHistory(): void
{
$integration = Integrations::first();
$product = Products::first();

$variant = $product->variants()->first();
$warehouse = $variant->warehouses()->first();

$this->setupShopifyIntegration($product, $warehouse->region);

$exportActivity = new ExportProductToShopifyActivity(
0,
now()->toDateTimeString(),
StoredWorkflow::make(),
[]
);

$app = app(Apps::class);

$result = $exportActivity->execute(
product: $product,
app: $app,
params: []
);

//@todo We need to DELETE the exported product after the test.
$this->assertArrayHasKey('shopify_response', $result);
$this->assertArrayHasKey('company', $result);
$this->assertArrayHasKey('product', $result);

$histories = (new EntityIntegrationHistoryService(
app: $app,
company: $product->company
))->getByIntegration($integration);

$this->assertNotEmpty($histories);
$this->assertInstanceOf(EntityIntegrationHistory::class, $histories[0]);
}
}

0 comments on commit 66e8e67

Please sign in to comment.