Skip to content

Commit 529da7f

Browse files
committed
updated tests
1 parent e7c60a1 commit 529da7f

7 files changed

+47
-21
lines changed

stubs/database/factories/AuditTrailsFactory.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Database\Factories;
44

55
use App\Models\AuditTrail;
6+
use App\Models\User;
67
use Illuminate\Database\Eloquent\Factories\Factory;
78

89
class AuditTrailsFactory extends Factory
@@ -12,7 +13,7 @@ class AuditTrailsFactory extends Factory
1213
public function definition(): array
1314
{
1415
return [
15-
'user_id' => $this->faker->uuid(),
16+
'user_id' => User::factory()->create()->id,
1617
'reference_id' => $this->faker->uuid(),
1718
'title' => $this->faker->title(),
1819
'section' => $this->faker->title(),

stubs/database/migrations/2014_10_12_000000_create_audit_trails_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public function up()
1010
{
1111
Schema::create('audit_trails', function (Blueprint $table) {
1212
$table->uuid('id')->primary();
13-
$table->uuid('user_id')->nullable();
13+
$table->foreignUuid('user_id')->nullable()->constrained('users')->onDelete('cascade');
1414
$table->string('title');
1515
$table->text('link')->nullable();
16-
$table->uuid('reference_id')->nullable();
16+
$table->foreignUuid('reference_id')->nullable();
1717
$table->string('section');
1818
$table->string('type');
1919
$table->timestamps();

stubs/database/migrations/2014_10_12_000000_create_users_table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function up(): void
2525
$table->timestamp('last_logged_in_at')->nullable();
2626
$table->boolean('two_fa_active')->default(false);
2727
$table->string('two_fa_secret_key')->nullable();
28-
$table->uuid('invited_by')->nullable();
28+
$table->foreignUuid('invited_by')->nullable()->constrained('users', 'id')->onDelete('cascade');
2929
$table->timestamp('invited_at')->nullable();
3030
$table->timestamp('joined_at')->nullable();
3131
$table->string('invite_token')->nullable();

stubs/tests/Feature/HelpMenuTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
use App\Http\Livewire\Admin\HelpMenu;
4+
use function Pest\Livewire\livewire;
5+
6+
beforeEach(function () {
7+
$this->authenticate();
8+
});
9+
10+
test('can see help menu', function () {
11+
$this
12+
->get(route('dashboard'))
13+
->assertSeeLivewire(HelpMenu::class);
14+
});
15+
16+
test('can see help menu item', function() {
17+
livewire(HelpMenu::class)
18+
->assertSee('Theme Docs');
19+
});
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use App\Http\Livewire\Admin\NotificationsMenu;
4+
use function Pest\Livewire\livewire;
5+
6+
beforeEach(function () {
7+
$this->authenticate();
8+
});
9+
10+
test('can see notification', function() {
11+
livewire(NotificationsMenu::class)
12+
->assertSet('unseenCount', 0);
13+
});

stubs/tests/Feature/Roles/RolesTest.php

-16
This file was deleted.

stubs/tests/Feature/Roles/CreateTest.php renamed to stubs/tests/Feature/RolesTest.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<?php
22

3-
use App\Http\Livewire\Admin\Roles\Create;
43
use App\Models\Role;
4+
use App\Http\Livewire\Admin\Roles\Create;
55
use Livewire\Livewire;
66

77
beforeEach(function () {
88
$this->authenticate();
99
});
1010

11+
test('can see roles page with admin role', function () {
12+
$this->get(route('admin.settings.roles.index'))->assertOk();
13+
});
14+
1115
test('can create role', function () {
1216
Livewire::test(Create::class)
1317
->set('role', 'Editor')
@@ -36,3 +40,8 @@
3640
->call('cancel')
3741
->assertDispatchedBrowserEvent('close-modal');
3842
});
43+
44+
test('can see edit role', function () {
45+
$role = Role::where('name', 'admin')->first();
46+
$this->get(route('admin.settings.roles.edit', $role))->assertOk();
47+
});

0 commit comments

Comments
 (0)