fixed missing features
This commit is contained in:
@@ -74,6 +74,7 @@ class GiteaProviderTest extends TestCase
|
||||
|
||||
$this->assertCount(1, $repositories);
|
||||
$this->assertContainsOnlyInstancesOf(GitRepository::class, $repositories);
|
||||
$this->assertSame('https://git.example.test/api/v1', $repositories[0]->baseUrl);
|
||||
$this->assertSame('501', $repositories[0]->providerRepositoryId);
|
||||
$this->assertSame('nico/kanbangit', $repositories[0]->fullName);
|
||||
$this->assertSame('main', $repositories[0]->defaultBranch);
|
||||
@@ -113,6 +114,7 @@ class GiteaProviderTest extends TestCase
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(GitRepository::class, $repository);
|
||||
$this->assertSame('https://git.example.test', $repository->baseUrl);
|
||||
$this->assertSame('501', $repository->providerRepositoryId);
|
||||
$this->assertSame('core-team', $repository->owner);
|
||||
$this->assertSame('kanbangit', $repository->name);
|
||||
@@ -138,10 +140,17 @@ class GiteaProviderTest extends TestCase
|
||||
]);
|
||||
|
||||
$branches = app(GiteaProviderClient::class)->listBranches(
|
||||
'https://git.example.test',
|
||||
'branch-token',
|
||||
'core-team',
|
||||
'kanbangit',
|
||||
new GitRepository(
|
||||
baseUrl: 'https://git.example.test',
|
||||
providerRepositoryId: '501',
|
||||
owner: 'core-team',
|
||||
name: 'kanbangit',
|
||||
fullName: 'core-team/kanbangit',
|
||||
htmlUrl: 'https://git.example.test/core-team/kanbangit',
|
||||
defaultBranch: 'main',
|
||||
isPrivate: false,
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertCount(2, $branches);
|
||||
@@ -210,10 +219,17 @@ class GiteaProviderTest extends TestCase
|
||||
]);
|
||||
|
||||
$pullRequests = app(GiteaProviderClient::class)->listPullRequests(
|
||||
'https://git.example.test',
|
||||
'pull-token',
|
||||
'core-team',
|
||||
'kanbangit',
|
||||
new GitRepository(
|
||||
baseUrl: 'https://git.example.test',
|
||||
providerRepositoryId: '501',
|
||||
owner: 'core-team',
|
||||
name: 'kanbangit',
|
||||
fullName: 'core-team/kanbangit',
|
||||
htmlUrl: 'https://git.example.test/core-team/kanbangit',
|
||||
defaultBranch: 'main',
|
||||
isPrivate: false,
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertCount(1, $pullRequests);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use App\Actions\Git\Data\GitRepository;
|
||||
use App\Actions\Git\GitProviderKey;
|
||||
use App\Models\RepositoryConnection;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -33,4 +34,27 @@ class RepositoryConnectionTest extends TestCase
|
||||
$this->assertTrue($repositoryConnection->project()->exists());
|
||||
$this->assertTrue($repositoryConnection->project->is($repositoryConnection->fresh()->project));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure repository connections can be used as Git provider repository data.
|
||||
*/
|
||||
public function test_repository_connections_convert_to_git_repository_data(): void
|
||||
{
|
||||
$repositoryConnection = RepositoryConnection::factory()->create([
|
||||
'base_url' => 'https://git.example.test',
|
||||
'owner_name' => 'core-team',
|
||||
'provider_repository_id' => '501',
|
||||
'repository_full_name' => 'core-team/kanbangit',
|
||||
'repository_name' => 'kanbangit',
|
||||
'repository_url' => 'https://git.example.test/core-team/kanbangit',
|
||||
]);
|
||||
|
||||
$repository = $repositoryConnection->toGitRepository();
|
||||
|
||||
$this->assertInstanceOf(GitRepository::class, $repository);
|
||||
$this->assertSame('https://git.example.test', $repository->baseUrl);
|
||||
$this->assertSame('core-team', $repository->owner);
|
||||
$this->assertSame('kanbangit', $repository->name);
|
||||
$this->assertSame('core-team/kanbangit', $repository->fullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use App\Enums\TicketWorklogEntryType;
|
||||
use App\Models\TicketWorklogEntry;
|
||||
use Database\Seeders\BoardColumnSeeder;
|
||||
use Database\Seeders\ProjectSeeder;
|
||||
@@ -25,7 +26,7 @@ class TicketWorklogEntryTest extends TestCase
|
||||
|
||||
$this->assertNotNull($entry->ticket);
|
||||
$this->assertNotNull($entry->actor);
|
||||
$this->assertSame('status_changed', $entry->entry_type);
|
||||
$this->assertSame(TicketWorklogEntryType::StatusChanged, $entry->entry_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-18
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectBacklogControllerTest extends TestCase
|
||||
class ProjectBacklogTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
@@ -64,9 +64,9 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure creating tickets requires the project create permission.
|
||||
* Ensure creating tickets requires the project write permission.
|
||||
*/
|
||||
public function test_creating_tickets_requires_project_create_permission(): void
|
||||
public function test_creating_tickets_requires_project_write_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create();
|
||||
@@ -81,7 +81,7 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('projects.backlog.store', $project), [
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'title' => 'New ticket',
|
||||
'description' => 'Description',
|
||||
'acceptance_criteria' => 'Criteria',
|
||||
@@ -93,9 +93,9 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure project-local keys increment and backlog accepts duplicate titles.
|
||||
* Ensure project-local keys increment and ticket creation accepts duplicate titles.
|
||||
*/
|
||||
public function test_users_with_create_permission_can_add_duplicate_titled_tickets_to_backlog(): void
|
||||
public function test_users_with_write_permission_can_add_duplicate_titled_tickets(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$assignee = User::factory()->create();
|
||||
@@ -127,14 +127,14 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
];
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('projects.backlog.store', $project), $payload)
|
||||
->assertRedirect(route('projects.backlog.index', $project))
|
||||
->assertSessionHas('status', 'AUTH-1 was added to the backlog.');
|
||||
->post(route('projects.tickets.store', $project), $payload)
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 1]))
|
||||
->assertSessionHas('status', 'AUTH-1 was created.');
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('projects.backlog.store', $project), $payload)
|
||||
->assertRedirect(route('projects.backlog.index', $project))
|
||||
->assertSessionHas('status', 'AUTH-2 was added to the backlog.');
|
||||
->post(route('projects.tickets.store', $project), $payload)
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 2]))
|
||||
->assertSessionHas('status', 'AUTH-2 was created.');
|
||||
|
||||
$this->assertDatabaseHas('tickets', [
|
||||
'project_id' => $project->id,
|
||||
@@ -164,9 +164,9 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure ticket creation only accepts backlog statuses.
|
||||
* Ensure ticket creation can target board column statuses.
|
||||
*/
|
||||
public function test_creating_tickets_rejects_board_column_statuses(): void
|
||||
public function test_creating_tickets_accepts_board_column_statuses(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create();
|
||||
@@ -189,7 +189,7 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->from(route('projects.backlog.index', $project))
|
||||
->post(route('projects.backlog.store', $project), [
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'title' => 'New ticket',
|
||||
'description' => 'Description',
|
||||
'acceptance_criteria' => 'Criteria',
|
||||
@@ -197,9 +197,13 @@ class ProjectBacklogControllerTest extends TestCase
|
||||
'ticket_priority_id' => $project->ticketPriorities()->firstOrFail()->id,
|
||||
'ticket_status_id' => $boardStatus->id,
|
||||
])
|
||||
->assertRedirect(route('projects.backlog.index', $project))
|
||||
->assertSessionHasErrors('ticket_status_id');
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 1]))
|
||||
->assertSessionHas('status', "{$project->key}-1 was created.");
|
||||
|
||||
$this->assertDatabaseCount('tickets', 0);
|
||||
$this->assertDatabaseHas('tickets', [
|
||||
'project_id' => $project->id,
|
||||
'ticket_status_id' => $boardStatus->id,
|
||||
'title' => 'New ticket',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ class ProjectBoardControllerTest extends TestCase
|
||||
->has('boardColumns.1.tickets', 1)
|
||||
->where('boardColumns.1.tickets.0.ticket_key', $boardTicket->ticket_key)
|
||||
->where('boardColumns.1.tickets.0.title', $boardTicket->title)
|
||||
->where('canCreateTickets', false)
|
||||
->where('canEditTickets', false),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -312,9 +312,9 @@ class ProjectControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure non-admin users cannot open general project settings even with project permissions.
|
||||
* Ensure project admins can open general project settings.
|
||||
*/
|
||||
public function test_non_admin_users_cannot_view_general_project_settings(): void
|
||||
public function test_project_admins_can_view_general_project_settings(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
@@ -325,7 +325,11 @@ class ProjectControllerTest extends TestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('projects.settings.general', $project))
|
||||
->assertForbidden();
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/settings/General')
|
||||
->where('project.id', $project->id),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use App\Models\RepositoryConnection;
|
||||
use App\Models\Ticket;
|
||||
@@ -11,6 +12,7 @@ use App\Models\TicketFieldValue;
|
||||
use App\Models\TicketLink;
|
||||
use App\Models\TicketLinkType;
|
||||
use App\Models\TicketPriority;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\TicketType;
|
||||
use App\Models\TicketWorklogEntry;
|
||||
use App\Models\User;
|
||||
@@ -274,6 +276,97 @@ class ProjectTicketControllerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the create page defaults to a board status when opened from the board.
|
||||
*/
|
||||
public function test_users_with_write_permission_can_view_the_ticket_create_page(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$boardColumn = BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
$boardStatus = TicketStatus::factory()
|
||||
->for($project)
|
||||
->for($boardColumn)
|
||||
->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->get(route('projects.tickets.create', [
|
||||
'project' => $project,
|
||||
'source' => 'board',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/TicketCreate')
|
||||
->where('defaultTicketStatusId', $boardStatus->id)
|
||||
->where('project.id', $project->id)
|
||||
->where('source', 'board')
|
||||
->where('ticketStatusOptions.1.id', $boardStatus->id),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure creating tickets from the dedicated endpoint redirects to the ticket detail page.
|
||||
*/
|
||||
public function test_users_with_write_permission_can_create_tickets(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$assignee = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = $project->ticketPriorities()->firstOrFail();
|
||||
$backlogStatus = $project->ticketStatuses()
|
||||
->whereNull('board_column_id')
|
||||
->firstOrFail();
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'acceptance_criteria' => 'The ticket exists.',
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'description' => 'Created from the dedicated page.',
|
||||
'story_points' => 5,
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||
'title' => 'Dedicated create page',
|
||||
])
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 1]))
|
||||
->assertSessionHas('status', 'CORE-1 was created.');
|
||||
|
||||
$this->assertDatabaseHas('tickets', [
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'author_user_id' => $editor->id,
|
||||
'project_id' => $project->id,
|
||||
'story_points' => 5,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
'title' => 'Dedicated create page',
|
||||
]);
|
||||
$this->assertDatabaseHas('ticket_worklog_entries', [
|
||||
'actor_id' => $editor->id,
|
||||
'entry_type' => 'created',
|
||||
'summary' => 'Ticket was created in Backlog.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure updating ticket details requires the project edit permission.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user