Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: add inertia support for custom hints? #243

Open
kimhout-sam opened this issue Feb 10, 2025 · 1 comment
Open

[Feature]: add inertia support for custom hints? #243

kimhout-sam opened this issue Feb 10, 2025 · 1 comment

Comments

@kimhout-sam
Copy link

kimhout-sam commented Feb 10, 2025

Feature Description

appreciate your time with extension, but if we support inertia hint like in provider

    // their private module entry provider
    public function boot(): void
    {
        if ($this->app->has('inertia.testing.view-finder')) {
            $finder = app('inertia.testing.view-finder');

            $finder->addNamespace('Admin', base_path('modules/Admin/resources/js/pages'));

            $this->app->bind('inertia.testing.view-finder', fn () => $finder);
        }
    }

file modules tree

modules
├─── ...[more modules]
└── Admin
    ├── app
    │   ├── Http
    │   │   └── Controllers
    │   │       └── AdminController.php
    │   └── Providers
    │       ├── AdminServiceProvider.php
    │       ├── EventServiceProvider.php
    │       └── RouteServiceProvider.php
    ├── composer.json
    ├── config
    │   └── config.php
    ├── database
    │   ├── factories
    │   ├── migrations
    │   └── seeders
    │       └── AdminDatabaseSeeder.php
    ├── module.json
    ├── resources
    │   └── js
    │       └── pages
    │           └── index.tsx
    ├── routes
    │   ├── api.php
    │   └── web.php
    └── tests
        ├── Feature
        └── Unit

and usage

Admin::index that mapped to file [project]/modules/Admin/resources/js/pages/index.tsx

so user with ease testing when controller action

Route::get('/admin', fn() => inertia('Admin::index', ['hello' => 'world']));

where as author can test using component key with they return on action.

use Inertia\Testing\AssertableInertia as Assert;

class PodcastsControllerTest extends TestCase
{
    public function test_can_view_podcast()
    {
        $this->get('/admin')
            ->assertInertia(fn (Assert $page) => $page
                ->component('Admin::index')
                ->has('hello','world');
    }
}

Beneficial for folk using:

  • project using laravel-modules or modular for create their private business logic that don't want to publish as package
  • composer package author that want to detached inertia views in their package
  • with ease of use when come to testing inertia component in their modules

Proof

Image

Source: https://github.com/kimhout-sam/vs-code-extension
Example: https://github.com/cynonexus-platform/laravel-templates

@sebsobseb
Copy link

This would be a great feature

@kimhout-sam kimhout-sam changed the title [Feature]: how add inertia support for custom hints? [Feature]: add inertia support for custom hints? Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants