Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenjude committed Sep 22, 2024
1 parent 9c27c17 commit 2e12554
Showing 1 changed file with 54 additions and 85 deletions.
139 changes: 54 additions & 85 deletions tests/DebuggerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Filament\Navigation\NavigationItem;
use Stephenjude\FilamentDebugger\DebuggerPlugin;

it('will not use debugging functions')
Expand All @@ -13,119 +12,89 @@
expect($panel->getPlugin('filament-debugger'))
->not()
->toThrow(Exception::class);

expect($panel->getNavigationItems())->toHaveCount(3);

$plugin = $panel->getPlugin('filament-debugger');

expect($plugin)->hasHorizon()->toBeTrue();

expect($plugin)->hasTelescope()->toBeTrue();

expect($plugin)->hasPulse()->toBeTrue();
});

it('authorizes plugin', function () {
$panel = filament()->getCurrentPanel()->plugin(DebuggerPlugin::make()->authorize(false));

expect($panel->getNavigationItems())->toHaveCount(0);
});

it('groups plugin navigation items', function () {
$panel = filament()->getCurrentPanel()
->plugin(
DebuggerPlugin::make()->groupNavigation(
condition: fn () => true,
label: 'Laravel Debuggers'
)
);

collect($panel->getNavigationItems())
->each(
fn (NavigationItem $navigationItem) => expect($navigationItem)->getGroup()->toBe('Laravel Debuggers')
);
});

it('customizes telescope navigation', function () {
$panel = filament()->getCurrentPanel()->plugin(
DebuggerPlugin::make()
->horizonNavigation(false)
->pulseNavigation(false)
->telescopeNavigation(
condition: fn () => true,
label: 'Laravel Telescope',
icon: 'heroicon-o-users',
url: 'telescope/requests',
openInNewTab: fn () => false
)
);
$plugin = DebuggerPlugin::make()
->horizonNavigation(false)
->pulseNavigation(false)
->telescopeNavigation(
condition: fn() => true,
label: 'Laravel Telescope',
icon: 'heroicon-o-users',
url: 'telescope/requests',
openInNewTab: fn() => false
);

expect($plugin->hasHorizon())->toBeFalse();

expect($panel->getNavigationItems())->toHaveCount(1);
expect($plugin->hasPulse())->toBeFalse();

/** @var NavigationItem $navigationItem */
$navigationItem = $panel->getNavigationItems()[0];
expect($plugin->hasTelescope())->toBeTrue();

expect($navigationItem)->getLabel()->toBe('Laravel Telescope');
expect($plugin->getTelescopeIcon())->toBe('heroicon-o-users');

expect($navigationItem)->getIcon()->toBe('heroicon-o-users');
expect($plugin->getTelescopeLabel())->toBe('Laravel Telescope');

expect($navigationItem)->getUrl()->toBe('telescope/requests');
expect($plugin->getTelescopeUrl())->toContain('telescope/requests');

expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse();
expect($plugin->getTelescopeOpenInNewTab())->toBeFalse();
});

it('customizes horizon navigation', function () {
$panel = filament()->getCurrentPanel()->plugin(
DebuggerPlugin::make()
->telescopeNavigation(false)
->pulseNavigation(false)
->horizonNavigation(
condition: fn () => true,
label: 'Laravel Horizon',
icon: 'heroicon-o-users',
url: url('horizon/requests'),
openInNewTab: fn () => false
)
);
$plugin = DebuggerPlugin::make()
->telescopeNavigation(false)
->pulseNavigation(false)
->horizonNavigation(
condition: fn() => true,
label: 'Laravel Horizon',
icon: 'heroicon-o-users',
url: url('horizon/requests'),
openInNewTab: fn() => false
);

expect($plugin->hasPulse())->toBeFalse();

expect($panel->getNavigationItems())->toHaveCount(1);
expect($plugin->hasTelescope())->toBeFalse();

/** @var NavigationItem $navigationItem */
$navigationItem = $panel->getNavigationItems()[0];
expect($plugin->hasHorizon())->toBeTrue();

expect($navigationItem)->getLabel()->toBe('Laravel Horizon');
expect($plugin->getHorizonIcon())->toBe('heroicon-o-users');

expect($navigationItem)->getIcon()->toBe('heroicon-o-users');
expect($plugin->getHorizonLabel())->toBe('Laravel Horizon');

expect($navigationItem)->getUrl()->toBe(url('horizon/requests'));
expect($plugin->getHorizonUrl())->toContain('horizon/requests');

expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse();
expect($plugin->getHorizonOpenInNewTab())->toBeFalse();
});

it('customizes pulse navigation', function () {
$panel = filament()->getCurrentPanel()->plugin(
DebuggerPlugin::make()
->horizonNavigation(false)
->telescopeNavigation(false)
->pulseNavigation(
condition: fn () => true,
label: 'Laravel Pulse',
icon: 'heroicon-o-users',
url: 'pulse/requests',
openInNewTab: fn () => false
)
);
$plugin = DebuggerPlugin::make()
->horizonNavigation(false)
->telescopeNavigation(false)
->pulseNavigation(
condition: fn() => true,
label: 'Laravel Pulse',
icon: 'heroicon-o-users',
url: 'pulse/requests',
openInNewTab: fn() => false
);

expect($plugin->hasHorizon())->toBeFalse();

expect($panel->getNavigationItems())->toHaveCount(1);
expect($plugin->hasTelescope())->toBeFalse();

/** @var NavigationItem $navigationItem */
$navigationItem = $panel->getNavigationItems()[0];
expect($plugin->hasPulse())->toBeTrue();

expect($navigationItem)->getLabel()->toBe('Laravel Pulse');
expect($plugin->getPulseIcon())->toBe('heroicon-o-users');

expect($navigationItem)->getIcon()->toBe('heroicon-o-users');
expect($plugin->getPulseLabel())->toBe('Laravel Pulse');

expect($navigationItem)->getUrl()->toBe('pulse/requests');
expect($plugin->getPulseUrl())->toContain('pulse/requests');

expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse();
expect($plugin->getPulseOpenInNewTab())->toBeFalse();
});

0 comments on commit 2e12554

Please sign in to comment.