coolify/tests/Feature/GithubSourcePagesTest.php
Andras Bacsai c7879da390 feat(github): split GitHub app source page into tabbed views
Refactor the GitHub source UI into dedicated General, Permissions & Events,
and Resources Livewire pages/components with route-based navigation.

Also keeps permission/event refetch and resource listing behavior intact while
improving page organization and adds feature coverage for the new pages.
2026-03-03 22:45:19 +01:00

56 lines
2.1 KiB
PHP

<?php
use App\Models\GithubApp;
use App\Models\InstanceSettings;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->team = Team::factory()->create();
$this->user = User::factory()->create();
$this->team->members()->attach($this->user->id, ['role' => 'owner']);
$this->actingAs($this->user);
session(['currentTeam' => $this->team]);
InstanceSettings::create(['id' => 0]);
});
test('github source has dedicated routes for each tab page', function () {
$githubApp = GithubApp::create([
'name' => 'test-github-app',
'api_url' => 'https://api.github.com',
'html_url' => 'https://github.com',
'custom_user' => 'git',
'custom_port' => 22,
'app_id' => 12345,
'installation_id' => 67890,
'team_id' => $this->team->id,
'is_system_wide' => false,
]);
$this->get(route('source.github.show', ['github_app_uuid' => $githubApp->uuid]))
->assertSuccessful();
$this->get(route('source.github.permissions-events', ['github_app_uuid' => $githubApp->uuid]))
->assertSuccessful();
$this->get(route('source.github.resources', ['github_app_uuid' => $githubApp->uuid]))
->assertSuccessful();
});
test('permissions and resources routes redirect to general if github app is not initialized yet', function () {
$githubApp = GithubApp::create([
'name' => 'test-github-app',
'api_url' => 'https://api.github.com',
'html_url' => 'https://github.com',
'custom_user' => 'git',
'custom_port' => 22,
'team_id' => $this->team->id,
'is_system_wide' => false,
]);
$this->get(route('source.github.permissions-events', ['github_app_uuid' => $githubApp->uuid]))
->assertRedirect(route('source.github.show', ['github_app_uuid' => $githubApp->uuid]));
$this->get(route('source.github.resources', ['github_app_uuid' => $githubApp->uuid]))
->assertRedirect(route('source.github.show', ['github_app_uuid' => $githubApp->uuid]));
});