1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 15:54:03 +00:00

Simplify the slack channel usage test

This commit is contained in:
lukinovec 2025-07-29 12:24:06 +02:00
parent a13110c880
commit 718afd3069

View file

@ -363,35 +363,24 @@ test('slack channel uses correct webhook urls', function () {
];
// Test central context - should attempt to use central webhook
// Because the Slack channel uses cURL to send messages, we cannot use Http::fake() here.
// Instead, we catch the exception and check the error message which contains the actual webhook URL.
try {
logger('central');
} catch (Exception $e) {
expect($e->getMessage())->toContain('central-webhook');
}
// Test tenant 1 context - should attempt to use tenant1 webhook
tenancy()->initialize($tenant1);
// Slack channel should attempt to use the tenant-specific webhooks
tenancy()->runForMultiple([$tenant1, $tenant2], function (Tenant $tenant) {
try {
logger('tenant1');
logger($tenant->id);
} catch (Exception $e) {
expect($e->getMessage())->toContain('tenant1-webhook');
expect($e->getMessage())->toContain($tenant->slackUrl);
}
});
tenancy()->end();
// Test tenant 2 context - should attempt to use tenant2 webhook
tenancy()->initialize($tenant2);
try {
logger('tenant2');
} catch (Exception $e) {
expect($e->getMessage())->toContain('tenant2-webhook');
}
tenancy()->end();
// Back to central - should use central webhook again
// Central context, central webhook should be used again
try {
logger('central');
} catch (Exception $e) {