Open a TaskStream board for a project that has none yet
The project form gets «Crear en TaskStream» while the project has no board, and `taskstream: true` on a PATCH does the same through the API. A refusal leaves the edit unsaved; a project with a board keeps it, and `taskstream_key` without the flag is still ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,9 @@ use Tests\FakesPireon;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* The panel's way to open a project's board in TaskStream: a toggle on the
|
||||
* create form, as the person signed in.
|
||||
* The panel's way to open a project's board in TaskStream, as the person
|
||||
* signed in: a toggle on the create form, or an action on a project that
|
||||
* has none yet.
|
||||
*/
|
||||
class TaskStreamPanelTest extends TestCase
|
||||
{
|
||||
@@ -131,4 +132,41 @@ class TaskStreamPanelTest extends TestCase
|
||||
|
||||
$this->assertSame(0, Project::withTrashed()->count());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function a_project_without_a_board_can_get_one_later(): void
|
||||
{
|
||||
$this->fakeTaskStream();
|
||||
$project = Project::factory()->create(['slug' => ['es' => 'catalogo']]);
|
||||
|
||||
Livewire::test(EditProject::class, ['record' => $project->getRouteKey()])
|
||||
->assertActionHidden('taskstream')
|
||||
->assertActionVisible('createInTaskStream')
|
||||
->callAction('createInTaskStream', data: ['key' => 'cat'])
|
||||
->assertHasNoActionErrors()
|
||||
->assertNotified();
|
||||
|
||||
Http::assertSent(fn (Request $request) => $request->hasHeader('Authorization', 'Bearer session-token')
|
||||
&& $request['key'] === 'CAT'
|
||||
&& $request['isPublic'] === true);
|
||||
|
||||
$this->assertSame('CAT', $project->fresh()->taskstream_key);
|
||||
|
||||
Livewire::test(EditProject::class, ['record' => $project->getRouteKey()])
|
||||
->assertActionVisible('taskstream')
|
||||
->assertActionHidden('createInTaskStream');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function a_refusal_later_keeps_the_project_without_a_board(): void
|
||||
{
|
||||
$this->fakeTaskStream(409, ['statusCode' => 409, 'message' => 'Project key WEB is already in use']);
|
||||
$project = Project::factory()->create();
|
||||
|
||||
Livewire::test(EditProject::class, ['record' => $project->getRouteKey()])
|
||||
->callAction('createInTaskStream', data: ['key' => 'WEB'])
|
||||
->assertNotified(__('rules.taskstream.refused', ['reason' => 'Project key WEB is already in use']));
|
||||
|
||||
$this->assertNull($project->fresh()->taskstream_key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user