Features: - Implement two fee types: entrance fee and annual fee (both NT$1,000) - Add 50% discount for disability certificate holders - Add disability certificate upload in member profile - Integrate disability verification into cashier approval workflow - Add membership fee settings in system admin Document permissions: - Fix hard-coded role logic in Document model - Use permission-based authorization instead of role checks Additional features: - Add announcements, general ledger, and trial balance modules - Add income management and accounting entries - Add comprehensive test suite with factories - Update UI translations to Traditional Chinese 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
255 lines
7.2 KiB
PHP
255 lines
7.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser;
|
|
|
|
use App\Models\Issue;
|
|
use App\Models\IssueLabel;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Laravel\Dusk\Browser;
|
|
use Tests\DuskTestCase;
|
|
|
|
/**
|
|
* Issue Tracker Browser Tests
|
|
*
|
|
* Tests the issue tracking user interface and user experience.
|
|
*/
|
|
class IssueTrackerBrowserTest extends DuskTestCase
|
|
{
|
|
use DatabaseMigrations;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->artisan('db:seed', ['--class' => 'FinancialWorkflowPermissionsSeeder']);
|
|
}
|
|
|
|
/**
|
|
* Create an admin user
|
|
*/
|
|
protected function createAdmin(): User
|
|
{
|
|
$user = User::factory()->create([
|
|
'email' => 'admin@test.com',
|
|
'password' => Hash::make('password'),
|
|
]);
|
|
$user->assignRole('admin');
|
|
|
|
return $user;
|
|
}
|
|
|
|
/**
|
|
* Test issue list page loads
|
|
*/
|
|
public function test_issue_list_page_loads(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
$this->browse(function (Browser $browser) use ($admin) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.index'))
|
|
->assertSee('議題列表');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can create new issue
|
|
*/
|
|
public function test_can_create_new_issue(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
$this->browse(function (Browser $browser) use ($admin) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.create'))
|
|
->assertSee('新增議題')
|
|
->type('title', '測試議題標題')
|
|
->type('description', '這是測試議題描述')
|
|
->select('priority', Issue::PRIORITY_HIGH)
|
|
->press('建立')
|
|
->waitForLocation('/admin/issues/*')
|
|
->assertSee('測試議題標題');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test issue shows status badge
|
|
*/
|
|
public function test_issue_shows_status_badge(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'title' => '狀態測試議題',
|
|
'status' => Issue::STATUS_IN_PROGRESS,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.index'))
|
|
->assertSee('狀態測試議題')
|
|
->assertSee('進行中');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can assign issue
|
|
*/
|
|
public function test_can_assign_issue(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
$assignee = User::factory()->create(['name' => '被指派者']);
|
|
|
|
$issue = Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'assignee_id' => null,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $issue) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.show', $issue))
|
|
->assertSee('指派')
|
|
->select('assignee_id', '被指派者');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can add comment
|
|
*/
|
|
public function test_can_add_comment(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
$issue = Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $issue) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.show', $issue))
|
|
->type('content', '這是一則測試留言')
|
|
->press('新增留言')
|
|
->waitForText('這是一則測試留言')
|
|
->assertSee('這是一則測試留言');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can change issue status
|
|
*/
|
|
public function test_can_change_issue_status(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
$issue = Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'status' => Issue::STATUS_NEW,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $issue) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.show', $issue))
|
|
->select('status', Issue::STATUS_IN_PROGRESS)
|
|
->press('更新狀態')
|
|
->waitForText('進行中');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can filter by status
|
|
*/
|
|
public function test_can_filter_by_status(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'title' => '新議題',
|
|
'status' => Issue::STATUS_NEW,
|
|
]);
|
|
|
|
Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'title' => '已關閉議題',
|
|
'status' => Issue::STATUS_CLOSED,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.index'))
|
|
->select('status', Issue::STATUS_NEW)
|
|
->press('篩選')
|
|
->assertSee('新議題')
|
|
->assertDontSee('已關閉議題');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can filter by priority
|
|
*/
|
|
public function test_can_filter_by_priority(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'title' => '高優先議題',
|
|
'priority' => Issue::PRIORITY_HIGH,
|
|
]);
|
|
|
|
Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
'title' => '低優先議題',
|
|
'priority' => Issue::PRIORITY_LOW,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.index'))
|
|
->select('priority', Issue::PRIORITY_HIGH)
|
|
->press('篩選')
|
|
->assertSee('高優先議題')
|
|
->assertDontSee('低優先議題');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test issue number is displayed
|
|
*/
|
|
public function test_issue_number_is_displayed(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
|
|
$issue = Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $issue) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.show', $issue))
|
|
->assertSee($issue->issue_number);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test can add labels to issue
|
|
*/
|
|
public function test_can_add_labels_to_issue(): void
|
|
{
|
|
$admin = $this->createAdmin();
|
|
$label = IssueLabel::factory()->create(['name' => '緊急']);
|
|
|
|
$issue = Issue::factory()->create([
|
|
'created_by_user_id' => $admin->id,
|
|
]);
|
|
|
|
$this->browse(function (Browser $browser) use ($admin, $issue) {
|
|
$browser->loginAs($admin)
|
|
->visit(route('admin.issues.show', $issue))
|
|
->assertPresent('.labels-section');
|
|
});
|
|
}
|
|
}
|