Fixed three issues preventing the "new image" quick action from working: 1. Frontend matching logic wasn't checking the quickcommand field - Added check for item.quickcommand in the matching logic - Now "new image" matches docker-image via its quickcommand "(type: new image)" 2. Search query remained populated after triggering selection flow - Clear searchQuery in navigateToResourceCreation() to show selection UI - This switches the UI from creatable items list to server selection 3. Redirect wasn't using Livewire's redirect method - Changed from redirect()->route() to $this->redirect(route()) - Ensures proper Livewire component redirect behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.8 KiB
PHP
44 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Unit tests to verify that the "new image" quick action properly matches
|
|
* the docker-image type using the quickcommand field.
|
|
*
|
|
* This test verifies the fix for the issue where typing "new image" would
|
|
* not match because the frontend was only checking name and type fields,
|
|
* not the quickcommand field.
|
|
*/
|
|
it('ensures GlobalSearch blade template checks quickcommand field in matching logic', function () {
|
|
$bladeFile = file_get_contents(__DIR__.'/../../resources/views/livewire/global-search.blade.php');
|
|
|
|
// Check that the matching logic includes quickcommand check
|
|
expect($bladeFile)
|
|
->toContain('item.quickcommand')
|
|
->toContain('quickcommand.toLowerCase().includes(trimmed)');
|
|
});
|
|
|
|
it('ensures GlobalSearch clears search query when starting resource creation', function () {
|
|
$globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php');
|
|
|
|
// Check that navigateToResourceCreation clears the search query
|
|
expect($globalSearchFile)
|
|
->toContain('$this->searchQuery = \'\'');
|
|
});
|
|
|
|
it('ensures GlobalSearch uses Livewire redirect method', function () {
|
|
$globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php');
|
|
|
|
// Check that completeResourceCreation uses $this->redirect()
|
|
expect($globalSearchFile)
|
|
->toContain('$this->redirect(route(\'project.resource.create\'');
|
|
});
|
|
|
|
it('ensures docker-image item has quickcommand with new image', function () {
|
|
$globalSearchFile = file_get_contents(__DIR__.'/../../app/Livewire/GlobalSearch.php');
|
|
|
|
// Check that Docker Image has the correct quickcommand
|
|
expect($globalSearchFile)
|
|
->toContain("'name' => 'Docker Image'")
|
|
->toContain("'quickcommand' => '(type: new image)'")
|
|
->toContain("'type' => 'docker-image'");
|
|
});
|