- Refactor WorkspacePolicy to use pivot role instead of workspace.user_id - Add manageBilling policy (owner only) to BillingController - Fix ApiKeyController authorization (view → manageTeam for store/destroy) - Fix WorkspaceInviteController using workspace.user_id for owner checks - Fix WorkspaceController settings is_owner using workspace.user_id - Create PostAction enum for UpdatePost/PostController action strings - Create ApiToken\Status enum - Add User::SUBSCRIPTION_NAME constant, replace all hardcoded 'default' - Convert wantsEmailFor to accept NotificationType enum - Convert all $data[] to data_get() across publishers, controllers, jobs - Fix SocialLoginController callback missing try/catch - Fix SocialController::toggleActive missing workspace null check - Fix UpdatePost NPE on meta merge when postPlatform not found - Remove HTML5 required attributes from form inputs - Convert function declarations to arrow functions in Vue components - Replace hardcoded URLs with Wayfinder route helpers - Replace new Date() with dayjs - Add 16 new test files covering policies, authorization, publishing
84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Enums\User\Setup;
|
|
use App\Enums\UserWorkspace\Role;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
|
|
test('user with completed setup can access protected routes', function () {
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
$user = User::factory()->create(['setup' => Setup::Completed]);
|
|
$workspace = Workspace::factory()->create(['user_id' => $user->id]);
|
|
$workspace->members()->attach($user->id, ['role' => Role::Owner->value]);
|
|
$user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.calendar'))
|
|
->assertOk();
|
|
});
|
|
|
|
test('user on role step is redirected to onboarding step 1', function () {
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
$user = User::factory()->create(['setup' => Setup::Role]);
|
|
$workspace = Workspace::factory()->create(['user_id' => $user->id]);
|
|
$workspace->members()->attach($user->id, ['role' => Role::Owner->value]);
|
|
$user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.calendar'))
|
|
->assertRedirect(route('app.onboarding.role'));
|
|
});
|
|
|
|
test('user on connections step is redirected to onboarding step 2', function () {
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
$user = User::factory()->create(['setup' => Setup::Connections]);
|
|
$workspace = Workspace::factory()->create(['user_id' => $user->id]);
|
|
$workspace->members()->attach($user->id, ['role' => Role::Owner->value]);
|
|
$user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.calendar'))
|
|
->assertRedirect(route('app.onboarding.connect'));
|
|
});
|
|
|
|
test('user on subscription step is redirected to subscribe', function () {
|
|
config(['trypost.self_hosted' => true]);
|
|
|
|
$user = User::factory()->create(['setup' => Setup::Subscription]);
|
|
$workspace = Workspace::factory()->create(['user_id' => $user->id]);
|
|
$workspace->members()->attach($user->id, ['role' => Role::Owner->value]);
|
|
$user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.calendar'))
|
|
->assertRedirect(route('app.subscribe'));
|
|
});
|
|
|
|
test('user on role step can access onboarding step 1', function () {
|
|
$user = User::factory()->create(['setup' => Setup::Role]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.onboarding.role'))
|
|
->assertOk();
|
|
});
|
|
|
|
test('user on connections step can access onboarding step 2', function () {
|
|
$user = User::factory()->create(['setup' => Setup::Connections]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.onboarding.connect'))
|
|
->assertOk();
|
|
});
|
|
|
|
test('user on connections step can access social connect routes', function () {
|
|
$user = User::factory()->create(['setup' => Setup::Connections]);
|
|
|
|
$this->actingAs($user)
|
|
->get(route('app.social.linkedin.connect'))
|
|
->assertRedirect();
|
|
});
|