From ef0b0198fe789e7e326b62987070dea0e08d8065 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 14 Oct 2024 23:26:37 +0200 Subject: [PATCH] Mod Component Test --- .../tests/DashboardComponentTest.php | 9 ++- tests/Feature/DashboardTest.php | 62 ------------------- 2 files changed, 8 insertions(+), 63 deletions(-) delete mode 100644 tests/Feature/DashboardTest.php diff --git a/modules/Dashboard/tests/DashboardComponentTest.php b/modules/Dashboard/tests/DashboardComponentTest.php index d2e38264..949a44a7 100644 --- a/modules/Dashboard/tests/DashboardComponentTest.php +++ b/modules/Dashboard/tests/DashboardComponentTest.php @@ -25,7 +25,14 @@ it('renders successfully', function () { it('renders page successfully', function () { $this->login()->loginNami(); - $this->get('/')->assertOk()->assertSee('Dashboard'); + $this->get('/')->assertSeeLivewire(DashboardComponent::class)->assertSee('Dashboard'); +}); + +it('shows member component', function () { + $this->login()->loginNami(); + + Livewire::test(DashboardComponent::class) + ->assertSee('Gruppierungs-Verteilung'); }); class ExampleBlock extends Block diff --git a/tests/Feature/DashboardTest.php b/tests/Feature/DashboardTest.php deleted file mode 100644 index 62d3120e..00000000 --- a/tests/Feature/DashboardTest.php +++ /dev/null @@ -1,62 +0,0 @@ -withoutExceptionHandling(); - app(DashboardFactory::class)->purge(); - app(DashboardFactory::class)->register(ExampleBlock::class); - - $this->login()->loginNami(); - - $response = $this->get('/'); - - $this->assertInertiaHas(['class' => 'name'], $response, 'blocks.0.data'); - $this->assertInertiaHas('Example', $response, 'blocks.0.title'); - $this->assertInertiaHas('exa', $response, 'blocks.0.component'); - } - - public function testItDisplaysUserAvatar(): void - { - $this->withoutExceptionHandling(); - - $this->login()->loginNami(); - auth()->user()->update(['firstname' => 'Bob', 'lastname' => 'Dylan', 'email' => 'max@email.com']); - - $this->get('/') - ->assertInertiaPath('auth.user.firstname', 'Bob') - ->assertInertiaPath('auth.user.avatar_url', 'https://www.gravatar.com/avatar/' . hash('sha256', 'max@email.com')) - ->assertInertiaPath('auth.user.lastname', 'Dylan'); - } -} - -class ExampleBlock extends Block -{ - public function title(): string - { - return 'Example'; - } - - /** - * @return array - */ - public function data(): array - { - return ['class' => 'name']; - } - - public function component(): string - { - return 'exa'; - } -}