2026-01-18 23:33:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-01-18 23:33:45 +00:00
|
|
|
use App\Enums\User\Setup;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Models\Workspace;
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
use Illuminate\Http\UploadedFile;
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
$this->user = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
$this->workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
2026-01-20 19:53:54 +00:00
|
|
|
$this->workspace->members()->attach($this->user->id, ['role' => 'owner']);
|
2026-01-18 23:33:45 +00:00
|
|
|
$this->user->update(['current_workspace_id' => $this->workspace->id]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Index tests
|
|
|
|
|
test('workspaces index requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.workspaces.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('workspaces index shows all workspaces for user', function () {
|
2026-01-20 19:53:54 +00:00
|
|
|
$workspaces = Workspace::factory()->count(2)->create(['user_id' => $this->user->id]);
|
|
|
|
|
foreach ($workspaces as $workspace) {
|
|
|
|
|
$workspace->members()->attach($this->user->id, ['role' => 'owner']);
|
|
|
|
|
}
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.workspaces.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('workspaces/Index', false)
|
|
|
|
|
->has('workspaces', 3)
|
|
|
|
|
->has('currentWorkspaceId')
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Create tests
|
|
|
|
|
test('create workspace requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.workspaces.create'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('create workspace shows form for user with no workspaces', function () {
|
|
|
|
|
// Delete existing workspace so user has none
|
|
|
|
|
$this->user->update(['current_workspace_id' => null]);
|
|
|
|
|
$this->workspace->delete();
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.workspaces.create'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('workspaces/Create', false)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-26 15:01:53 +00:00
|
|
|
test('create workspace shows form when user already has workspace in self-hosted mode', function () {
|
|
|
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.workspaces.create'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-01-26 15:01:53 +00:00
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('workspaces/Create', false)
|
|
|
|
|
);
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Store tests
|
|
|
|
|
test('store workspace requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->post(route('app.workspaces.store'), ['name' => 'Test Workspace']);
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store workspace creates first workspace', function () {
|
|
|
|
|
// Delete existing workspace so user has none
|
|
|
|
|
$this->user->update(['current_workspace_id' => null]);
|
|
|
|
|
$this->workspace->delete();
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspaces.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'New Workspace',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.calendar'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('workspaces', [
|
|
|
|
|
'name' => 'New Workspace',
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-26 15:01:53 +00:00
|
|
|
test('store workspace creates second workspace in self-hosted mode', function () {
|
|
|
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspaces.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Second Workspace',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.calendar'));
|
2026-01-26 15:01:53 +00:00
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('workspaces', [
|
|
|
|
|
'name' => 'Second Workspace',
|
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
|
]);
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store workspace validates name is required', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspaces.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => '',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('name');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('store workspace sets new workspace as current', function () {
|
|
|
|
|
// Delete existing workspace so user has none
|
|
|
|
|
$this->user->update(['current_workspace_id' => null]);
|
|
|
|
|
$this->workspace->delete();
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$this->actingAs($this->user)->post(route('app.workspaces.store'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'New Workspace',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->user->refresh();
|
|
|
|
|
$newWorkspace = Workspace::where('name', 'New Workspace')->first();
|
|
|
|
|
|
|
|
|
|
expect($this->user->current_workspace_id)->toBe($newWorkspace->id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Switch tests
|
|
|
|
|
test('switch workspace requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->post(route('app.workspaces.switch', $this->workspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('switch workspace changes current workspace', function () {
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
2026-01-20 19:53:54 +00:00
|
|
|
$otherWorkspace->members()->attach($this->user->id, ['role' => 'owner']);
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspaces.switch', $otherWorkspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.calendar'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$this->user->refresh();
|
|
|
|
|
expect($this->user->current_workspace_id)->toBe($otherWorkspace->id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('switch workspace returns 403 for workspace user does not belong to', function () {
|
|
|
|
|
$otherUser = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
$otherWorkspace = Workspace::factory()->create(['user_id' => $otherUser->id]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspaces.switch', $otherWorkspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertForbidden();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Settings tests
|
|
|
|
|
test('workspace settings requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->get(route('app.workspace.settings'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
test('workspace settings shows settings page with members and invitations', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.workspace.settings'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
|
$response->assertInertia(fn ($page) => $page
|
|
|
|
|
->component('settings/Workspace', false)
|
|
|
|
|
->has('workspace')
|
|
|
|
|
->has('timezones')
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
->has('members')
|
|
|
|
|
->has('invitations')
|
2026-01-18 23:33:45 +00:00
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('workspace settings redirects to create if no workspace', function () {
|
|
|
|
|
$this->user->update(['current_workspace_id' => null]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->get(route('app.workspace.settings'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.workspaces.create'));
|
2026-01-18 23:33:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Update settings tests
|
|
|
|
|
test('update workspace settings requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->put(route('app.workspace.settings.update'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Updated Name',
|
|
|
|
|
'timezone' => 'America/New_York',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update workspace settings updates workspace', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.workspace.settings.update'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Updated Name',
|
|
|
|
|
'timezone' => 'America/New_York',
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.workspace.settings'));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$this->workspace->refresh();
|
|
|
|
|
expect($this->workspace->name)->toBe('Updated Name');
|
|
|
|
|
expect($this->workspace->timezone)->toBe('America/New_York');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update workspace settings validates required fields', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.workspace.settings.update'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => '',
|
|
|
|
|
'timezone' => '',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors(['name', 'timezone']);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('update workspace settings validates timezone', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->put(route('app.workspace.settings.update'), [
|
2026-01-18 23:33:45 +00:00
|
|
|
'name' => 'Valid Name',
|
|
|
|
|
'timezone' => 'Invalid/Timezone',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('timezone');
|
|
|
|
|
});
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
// Logo upload tests
|
|
|
|
|
test('upload workspace logo requires authentication', function () {
|
|
|
|
|
$response = $this->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->image('logo.jpg'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('upload workspace logo succeeds with valid image', function () {
|
|
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->image('logo.jpg', 200, 200),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$this->workspace->refresh();
|
|
|
|
|
expect($this->workspace->has_logo)->toBeTrue();
|
|
|
|
|
expect($this->workspace->logo_url)->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('upload workspace logo validates file is an image', function () {
|
|
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->create('document.pdf', 100),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('photo');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('upload workspace logo validates max size', function () {
|
|
|
|
|
$response = $this->actingAs($this->user)->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->image('logo.jpg')->size(3000),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertSessionHasErrors('photo');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('upload workspace logo requires authorization', function () {
|
|
|
|
|
$otherUser = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($otherUser)->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->image('logo.jpg'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response->assertForbidden();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('delete workspace logo requires authentication', function () {
|
|
|
|
|
$response = $this->delete(route('app.workspace.delete-logo'));
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('delete workspace logo succeeds', function () {
|
|
|
|
|
// Upload first
|
|
|
|
|
$this->actingAs($this->user)->post(route('app.workspace.upload-logo'), [
|
|
|
|
|
'photo' => UploadedFile::fake()->image('logo.jpg', 200, 200),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->workspace->refresh();
|
|
|
|
|
expect($this->workspace->has_logo)->toBeTrue();
|
|
|
|
|
|
|
|
|
|
// Delete
|
|
|
|
|
$response = $this->actingAs($this->user)->delete(route('app.workspace.delete-logo'));
|
|
|
|
|
|
|
|
|
|
$response->assertRedirect();
|
|
|
|
|
|
|
|
|
|
$this->workspace->refresh();
|
|
|
|
|
expect($this->workspace->has_logo)->toBeFalse();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('delete workspace logo requires authorization', function () {
|
|
|
|
|
$otherUser = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
|
|
|
|
|
$response = $this->actingAs($otherUser)->delete(route('app.workspace.delete-logo'));
|
|
|
|
|
|
|
|
|
|
$response->assertForbidden();
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-18 23:33:45 +00:00
|
|
|
// Destroy tests
|
|
|
|
|
test('destroy workspace requires authentication', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->delete(route('app.workspaces.destroy', $this->workspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertRedirect(route('login'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('destroy workspace deletes the workspace', function () {
|
|
|
|
|
$workspaceId = $this->workspace->id;
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($this->user)->delete(route('app.workspaces.destroy', $this->workspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response->assertRedirect(route('app.workspaces.index'));
|
2026-01-18 23:33:45 +00:00
|
|
|
expect(Workspace::find($workspaceId))->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('destroy workspace clears current workspace if deleting current', function () {
|
2026-03-29 22:24:28 +00:00
|
|
|
$this->actingAs($this->user)->delete(route('app.workspaces.destroy', $this->workspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$this->user->refresh();
|
|
|
|
|
expect($this->user->current_workspace_id)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('destroy workspace returns 403 for non-owner', function () {
|
|
|
|
|
$otherUser = User::factory()->create(['setup' => Setup::Completed]);
|
|
|
|
|
|
2026-03-29 22:24:28 +00:00
|
|
|
$response = $this->actingAs($otherUser)->delete(route('app.workspaces.destroy', $this->workspace));
|
2026-01-18 23:33:45 +00:00
|
|
|
|
|
|
|
|
$response->assertForbidden();
|
|
|
|
|
});
|